Why does Float32 need its own cog?
I've been using Float32 for a while without getting too deep into how it works. I know that it allocates and uses an additional cog above and beyond the one that it is launched in. This was OK, but now after some modifications to my project, I have run out of cogs and need one back.
I took a look at the Float32 code, and fundamentally, I don't quite understand why it is using an extra cog in the first place since all the computation is serialized. When a Float32 function is called, my calling routine is forced to wait for a result from Float32, so it can't go ahead an execute more code in parallel. And upon inspection of the Float32 code, it uses the primary cog to submit an instruction to that second cog and then it uses a repeat until loop waiting for the answer to be returned from a second cog. Given that the first cog is just spinning waiting on a result from the second cog, why isn't the actual computation done in the same first cog? I'm sure there's a good reason for it, but it's not obvious why the second cog is needed. Ultimately, I am still looking for a way to call my Float routines without requiring the use of a second cog. I'm using the multiply, divide, add, subtract, FFloat, sin and cos functions.
I appreciate that I could convert all the computation to fixed point arithmetic, but that's not something I've looked at too closely yet. If that's the only solution, I'll do that, but I prefer to keep it simple and keep the computations working with native float data types so that it's easier for me to work with. If someone has a tutorial on converting floating point expressions to fixed point expressions, I'd be happy to read up.
Thanks,
Joel-
![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
I appreciate that I could convert all the computation to fixed point arithmetic, but that's not something I've looked at too closely yet. If that's the only solution, I'll do that, but I prefer to keep it simple and keep the computations working with native float data types so that it's easier for me to work with. If someone has a tutorial on converting floating point expressions to fixed point expressions, I'd be happy to read up.
Thanks,
Joel-
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.