Shop OBEX P1 Docs P2 Docs Learn Events
Wondering about memory modes and multiple cogs — Parallax Forums

Wondering about memory modes and multiple cogs

4x5n4x5n Posts: 745
edited 2012-07-03 20:54 in Propeller 1
I've finally far enough along with a project I'm working on using spin to be able to spend some time with C and with luck C++.

The first thing that came up has to do with the various memory modes. My question (for now and I'm sure I'll have more in time) is if I have a largish program that doesn't fit in it's entirety in a cog but has a number of subroutines that will fit in a single cog and is intended to run in that single cog. If I compile the program in lmm mode or one of the xmm modes is the compiler "smart" enough to load the entire subroutine into cog memory and run it there?

Comments

  • jazzedjazzed Posts: 11,803
    edited 2012-07-03 03:38
    4x5n wrote: »
    If I compile the program in lmm mode or one of the xmm modes is the compiler "smart" enough to load the entire subroutine into cog memory and run it there?


    By default in LMM and XMMC modes, the compiler will have the kernel load small routines of 128 bytes or less into COG and run them. You can also flag XMM functions to run as LMM with HUBTEXT.
  • 4x5n4x5n Posts: 745
    edited 2012-07-03 18:05
    jazzed wrote: »
    By default in LMM and XMMC modes, the compiler will have the kernel load small routines of 128 bytes or less into COG and run them. You can also flag XMM functions to run as LMM with HUBTEXT.

    128B isn't a lot of code for a subroutine.

    BTW - I'm not referring to a simple call in the same cog but a subroutine started in it's own cog with "coginit" (or its equivalent) I should be able to get more then 128 bytes of PASM launched into it's own COG!
  • KyeKye Posts: 2,200
    edited 2012-07-03 20:54
    No, what he means is that if you have a function that's less than 128 bytes, it will be loaded into the cog and execute at native speed by the LMM interpreter.

    Think of it as FAST caching. So, if you have some small loop that needs to run ultra fast, then this feature helps.

    If you want to start a cog with .cogc code then that is different. Then you have the full 496 longs, minus register space.

    Thanks,
Sign In or Register to comment.