A simple question about Main RAM and Cog RAM
ElectricAye
Posts: 4,561
Hi all,
I'm suddenly confused about how big my SPIN program is allowed to be. My current program is intended to run on just a single COG. Up till now I've been blithely writing code and, by using the Propeller Tool and the handy RAM usage panel, I've been watching how much memory space is being consumed by variables, etc.. and everything seemed to be within the limits displayed by the RAM usage panel. But now it occurs to me that maybe I've never truly understood how the Propeller executes code. I guess it's possible that a program might fit perfectly well within the RAM usage panel, but the Cog RAM of a single Cog might be way too small to run the program. Is this true?
Or, putting the question another way: when using only a single cog to run your application, must the ENTIRE program that is read from the Main RAM fit completely inside the cog RAM in order for that cog to run it? Or is there some kind of dance that takes place that writes part of the application out of Main Ram, runs it on the cog, then writes the next part of the application out of Main Ram, runs that part on the cog, and so on and so forth?
thanks,
Mark
I'm suddenly confused about how big my SPIN program is allowed to be. My current program is intended to run on just a single COG. Up till now I've been blithely writing code and, by using the Propeller Tool and the handy RAM usage panel, I've been watching how much memory space is being consumed by variables, etc.. and everything seemed to be within the limits displayed by the RAM usage panel. But now it occurs to me that maybe I've never truly understood how the Propeller executes code. I guess it's possible that a program might fit perfectly well within the RAM usage panel, but the Cog RAM of a single Cog might be way too small to run the program. Is this true?
Or, putting the question another way: when using only a single cog to run your application, must the ENTIRE program that is read from the Main RAM fit completely inside the cog RAM in order for that cog to run it? Or is there some kind of dance that takes place that writes part of the application out of Main Ram, runs it on the cog, then writes the next part of the application out of Main Ram, runs that part on the cog, and so on and so forth?
thanks,
Mark
Comments
Okay, again you saved me from a late night panic attack. At least as a rough approximation, the RAM usage panel is therefore the first quick glance at how close to a memory problem a cog is likely to suffer.
thank you!
Mark
as long as you program in SPIN a single cog can NOT suffer a out of COG-RAM memory problem. Because ALL COG-ram is ocupied by the SPIN-interpreter already.
a SPIN-cog uses HUB-RAM for everything.
IN SPIN it is the WHOLE CHIP who might have a out of memory-problem . Because all cogs SHARE the HUB-RAM of 32kB. And therefore it is regardless if one two or all eight cogs are running
they SHARE the HUB-RAM. A cog running PASM-code has its own COG-RAM excusively for privat (2kB of COG-ram). Of course PASM-code can access
HUB-RAM. This means for checking how much HUB-RAM is left you have to compile your TOP-Object-file and take a look on the RAM usage-panel.
If you compile any relatied SUB-objectfile you will get a smaller result of RAM-usage because then only these parts are compiled that are needed by this SUB-object
best regards
Stefan
thank you for adding this comment. I was reading about assembly language when my original worry cropped up. Your explanation helps clarify some of my confusion between working with SPIN and working with assembly.
have a good weekend,
Mark
that certainly helps complete the picture of how all this works.
thank you!