Shop OBEX P1 Docs P2 Docs Learn Events
Interaction between cogs? — Parallax Forums

Interaction between cogs?

port513port513 Posts: 50
edited 2008-09-10 11:30 in Propeller 1
First of all, I'm new to this!

Is there a way to have cog1 to read temperatures etc and then pass this information to cog2 without using a public variable etc?


/Henke

Comments

  • AleAle Posts: 2,363
    edited 2008-09-09 09:27
    Short: No.
    Long: there is no communication other than shared memory (HUB memory) between the cogs. You may use some external device (memory) that both can use... but it may be too complicated. A shared portion of HUB ram can be easily used for both cogs using the PAR register to pass the address. Simple semaphores can be implemented using the lock instructions... but variables... no.
    I thought for a project that would read an external memory that 4 cogs read simultaneously and process the data the 4 of them at the same time. That way the work could be balanced (shared for better use of cog ram).
  • heaterheater Posts: 3,370
    edited 2008-09-09 10:06
    Longer: Yes. I believe you can transmit data serially or in parallel by outputting to pins on one COG and reading those pins on another COG. I have never tried this.

    May be a tad faster than using hub RAM in some circumstances for example just setting a synchronization flag. Wastes pins of course.

    One could set up a "covert" serial channel by setting and unsetting a lock with with some clever timing (or use multiple locks for parallel) but that would be just weird.

    Weirder still: You could modulate data on to the system clock mode using CLKSET.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • hippyhippy Posts: 1,981
    edited 2008-09-09 10:18
    Question : Port B ( DIRB, OUTB, INB ) ... how are these wired in chip or are they not ?
  • heaterheater Posts: 3,370
    edited 2008-09-09 10:33
    "Question : Port B ( DIRB, OUTB, INB ) ... how are these wired in chip or are they not ?"

    That question has come up before, as far as I remember Port B is not wired. So no joy there. Can't find the thread about it just now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • ErNaErNa Posts: 1,751
    edited 2008-09-09 10:43
    If you measure temperature, then there is no reason, not to communicate via HUB (global) memory. Temperature date never will be very fast coming in. If you become more experienced, you will feel unhappy that there is no commonly used mechanism to communicate between different processes. But until than: enjoy the propeller! smile.gif
  • heaterheater Posts: 3,370
    edited 2008-09-09 10:51
    ErNa: That's why every time chip starts up a discussion about the Prop II I have suggested some high speed links between COGS. Seems to be always quietly ignored. I realize now that Prop II will have significant speed up in HUB access probably making inter COG links unnecessary for speed reasons.

    However I still think it might be worth it just to avoid using HUB RAM and all that dicking around with pointers, semaphores and locks etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • ErNaErNa Posts: 1,751
    edited 2008-09-09 11:19
    The past will never be over. The transputer had the concept of chanels, that made communication straigth forward and independend of the real hardware layout. A processor hosted processes (virtual cogs wink.gif ), that could communicate. By using more processors the available computation power could be adopted to the real problem. And (in limits without changing the software) the "virtual" channels between the processes where mapped to physical ports. I miss such an element in SPIN. I only Chips father had a transputer made a gift to him wink.gif
  • mirrormirror Posts: 322
    edited 2008-09-09 11:36
    I always find these discussions about alternative cog communications a bit strange!!

    A cog can access the hub every 16 clocks, and at that time transfer a long word (32 bits).

    So if you have a clock of 80MHz, then the transfer rate is 80 MHz / 16 x 32 bits per second = 160 M bits per second. Note that this is the transfer rate per cog. The gross inter-cog transfer rate is x 8 = 1.28 G bits per second.

    The fastest demonstrated serial comms between cogs is burst rates of 8 M bits per second over a single wire connection. So you would need 20 pins connecting 2 cogs to even get close to the speed of optimised hub transfers, and that is only for one way communication between 2 cogs.

    Although this question raises its head from time to time, my personal belief is that it is of academic interest only. Just use shared hub memory locations. They really are quite fast.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-09 19:20
    Hi mirror.

    Yes and NO.
    It is not alwais speed that is important. But fuly important is Prop to Prop comunication with few pins (1 clock and 1-2 in/out.
    That comunication has many use with 2 and more Props. Comunication COG to COG with that construction reached automaticaly
    and only programers programing skill can utillize that capablity.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
  • M. K. BorriM. K. Borri Posts: 279
    edited 2008-09-09 23:08
    The prop 2 is supposed to use portb for intercog comms (as in, the pins won't be accessible to the outside of the die)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-09 23:13
    Hi M. K. Borri

    As I know all 64 Pins will be accessible outside Prop II

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.

    Sapieha
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-09-10 01:48
    I agree with Mirror. Access between cogs via hub is fine. It only becomes a bottleneck if you are shifting lots of data and a fast serial link will not fix that.

    There are simple mechanisms to pass data between cogs via hub (see FullDuplexSerial even though it is spin passing, PASM could be used). Mostly, because of determinism, locks are not required. The only thing that may be requires is a fast synching mechanism, and that can be done by wasting a pin (sitting on waitpeq). Alternately, set the cnt parameter in hub and synchronise to that. This is what I did in my DataLogger - uses 4 cogs interleaved to sample all 32 pins at 12.5nS (about 480*4 samples, but could have used 8 cogs for 480*8 samples). The Prop II will be twice as fast.
  • heaterheater Posts: 3,370
    edited 2008-09-10 08:03
    mirror: "Although this question raises its head from time to time, my personal belief is that it is of academic interest only. Just use shared hub memory locations. They really are quite fast."

    Yes I agree, most of the time. Consider what happens now when all your cogs are in use but you want to add a few more processes, device drivers, whatever. Easy, add a second Prop to your design. But then you have to create some inter Prop communications in hardware and software. Then you have to modify some of you objects to communicate through that new "channel" from Prop to Prop. Any existing obects from obex or wherever would need serious changes to move from using HUB ram to the whatever new channel mechanism you have come up with.

    Now, IF that concept of a "channel" were built into the Spin language one would only have to make a small change somewhere to the definition of "channel" to change from COG to Prop to Prop link. Objects using this mechanism could be easily migrated from Prop to Prop.

    The physical reality of "channel" could well be through HUB RAM in a single Prop case but would automatically use Prop to Prop links when configured to do so.

    As it stands we don't care (or know) which COG a process runs on when we write an object. With a "channel" mechanism we would similarly not neeed to know which Prop the processes run on.

    Given the wonderful idea we have now of COGs as general purpose "devices" it would be great to extend that idea out of a the bounds of a single Prop.

    Serial links between Props could be very fast using video shifter like hardware.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • hippyhippy Posts: 1,981
    edited 2008-09-10 11:30
    heater said...
    Given the wonderful idea we have now of COGs as general purpose "devices" it would be great to extend that idea out of a the bounds of a single Prop.

    Serial links between Props could be very fast using video shifter like hardware.

    Agreed, and it doesn't really matter how it's implemented as long as it's there.

    A Cog ( or code it is interpreting ) shouldn't care if it's talking to another Cog/Program on the same chip or on a different one, or even via another Cog, over the internet, and through another Cog on a different system on the other side of the world.

    This isn't so much bottle-neck solving nor speed improvement but transparent comms.
Sign In or Register to comment.