Shop OBEX P1 Docs P2 Docs Learn Events
Several Cogs that use the same cog — Parallax Forums

Several Cogs that use the same cog

grasshoppergrasshopper Posts: 438
edited 2008-09-24 15:58 in Propeller 1
I am running some 5 cogs that all require the Float32 cog. I want to run all 5 cogs, but not running the Float32 cog 5 times also. How can I implement Float32 in each of my 5 cogs without exceeding my cog limit?

Is this possible?

Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-23 16:56
    The 5 cogs have to share a single copy of the Float32 cog(s). This is done using the LOCKxxx instructions.
    The details of how you would do this depend on how your program is structured and how the cogs interact.
  • dbpagedbpage Posts: 217
    edited 2008-09-23 20:31
    Possibilities:
    1. Create 5 Float32[noparse][[/noparse]x] objects (refer to Eight Talking Cogs in OBEX)
    2. Use Semaphores as Mike Green suggested in his post above (refer to Eight Talking Cogs)
    3. Save Float32 under five different filenames and use COGNEW/COGSTOP to run each different Float32x object in a cog one or two at a time (depending on the number of spare cogs available)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dennis B. Page, Page Radio Company
  • grasshoppergrasshopper Posts: 438
    edited 2008-09-24 04:15
    Would things slow down dramatically if I just start the float32 cog, calculate at that moment - then stop the cog?

    Mike listed some real complex things that I just cant understand at the moment.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-24 04:27
    It takes on the order of 150us to start up a copy of Float32 and a few microseconds to stop it.

    Whether that would make any practical difference in how well your application works depends
    on what you're trying to do.
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-24 04:28
    Hi grasshopper.

    It is one more alternative..
    Revrite float32 to have 5 banks registers one bank for one procesand 5 same banks in HUB.
    Programet write to HUB Vars that hold VARs to calkulate and write in HUB Flag register Flag for float32 to get it to calculate
    Then have 5 HUB VARs in You program with results from float32 with one flag register on Result complete

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • dbpagedbpage Posts: 217
    edited 2008-09-24 13:25
    Creating five Float32[noparse][[/noparse]x] objects does what Sapieha suggests. Using an object array provides a separate copy of Float32[noparse][[/noparse]x] to each cog that needs it. Examples 7 & 8 in the Propeller Manual describe object arrays; however, in Example 8, each Blinker2.spin object runs in its own cog. In your case, each Float32[noparse][[/noparse]x] object would run in each of your five previously-assigned cogs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dennis B. Page, Page Radio Company
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-24 14:07
    Hi Dennis B.

    Reread My Post.
    I sugest to revrite Float32 to serve 5 proceses in one COG using fuly Multiproces techniqe.
    Not to have 5 COGs of same Float32.



    Ps. Sorry·but I will say "" You have one FERRARI but RUN it how it was old T-FORD""

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha

    Post Edited (Sapieha) : 9/24/2008 2:18:28 PM GMT
  • dbpagedbpage Posts: 217
    edited 2008-09-24 15:58
    Sapieha,
    That is another possibility; however, the one cog running 5 Float32 multiprocesses will advance one of the 5 Float32 multiprocesses per hub cycle whereas five cogs of the same Float32 object array will advance 5 Float32 processes per hub cycle. Thus, faster processing is achieved without the burden of writing a custom multiprocess for Float32.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dennis B. Page, Page Radio Company

    Post Edited (Dennis B. Page, Page Radio Company) : 9/24/2008 5:34:53 PM GMT
Sign In or Register to comment.