COG vs LMM
User Name
Posts: 1,451
I gave Propellergcc a spin for the first time today and was totally impressed with all that has been done!
I apologize if this question has already been addressed ad nauseum.... Given that the COG memory model has severe space limitations, is there a document detailing what can and can't be done in COG mode?
I was puzzled when the use of the sprintf command produced an error message. Couldn't see anything wrong with the code, so I switched to LMM memory model (what else was there to try?) and it compiled like a champ. Nothing in the error message indicated (to me anyway) that the problem was one of space limitation.
I apologize if this question has already been addressed ad nauseum.... Given that the COG memory model has severe space limitations, is there a document detailing what can and can't be done in COG mode?
I was puzzled when the use of the sprintf command produced an error message. Couldn't see anything wrong with the code, so I switched to LMM memory model (what else was there to try?) and it compiled like a champ. Nothing in the error message indicated (to me anyway) that the problem was one of space limitation.
Comments
https://code.google.com/p/propgcc/source/browse/lib/cog/miniprintf.c
Just a couple follow-up comments:
* I noticed that on some simple port toggling experiments I got identical speeds with COG and LMM settings, which means to me that both tests were using the same mode, despite the setting.
* On a side-by-side comparison with an ARM Cortex M0 (LPC1114FN28) clocking at 48MHz (50 MHz is max for the device) running identical pin toggling C code, the Prop was more than 3.2x faster. This actually surprises me, since the ARM Cortex architecture was tailored around the needs of a C compiler. Clearly there are far faster ARM chips than the one I'm using, but they're not available in convenient-to-use DIPs.
Anyway, I'm quickly warming to gcc on the Prop. I applaud the effort and genius that went into this project. Suddenly I can understand the enthusiasm for gcc on the P2!
You're seeing the effect of FCACHE ("fast cache"), an idea Bill Henning came up with. In LMM mode, small loops are compiled with a prefix that loads them into COG memory, and they run from there. So a small loop can run as fast in LMM mode as in COG mode. Simple programs like pin toggling tend to run at almost the same speed both ways.
Eric
You might try the flag "-mno-fcache" to see if that slows things down.
This is intriguing. It demands another bunch of tests to explore the boundaries of the feature. I like it a lot, and I want to write code in a way that makes the most of it.