Shop OBEX P1 Docs P2 Docs Learn Events
Combining Float32full and floatstring without wasting cogs or memory — Parallax Forums

Combining Float32full and floatstring without wasting cogs or memory

KeezinatorKeezinator Posts: 21
edited 2008-09-16 23:04 in Propeller 1
I·need the log() function for a little object to calculate either the resistance or the capacitance (the other needs to be known off course) on a resistor capcitor circuit connected to one of the pins of the propellor. A more general·extension to the RCTIME.spin.

So I figured out this is one of the functions in the Float32Full object.

I also need (some of) the FloatString.spin functions.

All works fine, but now I am using 2 cogs for the Float32Full object and also load the FloatMath object because it is needed by FloatString.

The·waste: 2 implementations of the same function laoded.

So I figured, why not adapt the FloatString object to use the Float32Full (or Float32a) object?

Unfortunately, both my own object AND the floatsstring object would need to 'start' the Float32Full and it would take 4 cogs. Off course I could start/stop float32Full, but that would introduce a lot of overhead and result in awfull code.

So, my question, finally confused.gif

Before I embark on trying·make MathString to use·MathFull without wasting cogs ...

Has anyone tried this before? Where is it? Why hasn't anyone?

Would anyone be interested in the result?

Any comments on the approaches I am thinking of:

1: build a 'start' method that allow passing the addresses of the·'permanent' variables and cogs of the two float32full objects that are used. Pro: Simple, Con: Not transparant,·more complex to use the object(s)

2: implement the 'permanent' variables as DAT (assuming nobody would need two cogs making floating point calculations at the same time. Pro: Transparant, Con: I have not tried Spin assembler (yet)

Comments

  • KeezinatorKeezinator Posts: 21
    edited 2008-09-09 21:46
    Found 'dynamic mathlib' in the obex. I found it a bit kludgy. does not save memory (compared to usssing both MathFull and MathLib). and still uses 2 cogs. But: not bad at all!
  • M. K. BorriM. K. Borri Posts: 279
    edited 2008-09-09 23:03
    Try the newer version, it only uses either 1 or 0 cogs (dynamic math lib - nav optimized).

    You may have to decomment some functions that aren't used in navigation.

    Also, here's a companion string library that uses dynmathlib and has decently less overhead. It will also read decimal numbers in either as ints or floats.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
  • KeezinatorKeezinator Posts: 21
    edited 2008-09-16 20:07
    Thanks. I'll give it a try.

    I am thinking of some enhancements:

    1. Like isolating the nav functions in its own library, so they don't have to be commented out (or uncommented in) for users that only need the 'bare' essentials.

    2. Implement the various functions as a 'table lookup', so the coded to start the cog and to force 'slow' mode do not need to be repeated for every function.

    3. Clean up by removing the commented code and improving documentation a bit

    Would you mind using my enhancements in your version? I feel this float library could be the 'standard' float library if we work together on this.

    I get started and will send you the result by PM...
  • M. K. BorriM. K. Borri Posts: 279
    edited 2008-09-16 20:16
    Thanks!

    Please do feel free to go nuts on it [noparse]:D[/noparse] also, yeah, nav stuff should've been given its own module probably... but I've mostly been using the Prop to make unmanned vehicles [noparse]:)[/noparse]

    (3 boats, 2 rovers and 1 plane so far -- old source is on my website, new source will be released when we finish doing the sccripting language for it)

    As an aside, the geodesy formulas have been calibrated to match exactly with Google Earth, so if you want to change the constants to a different stanard, please keep the existing ones around as a comment.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
  • KeezinatorKeezinator Posts: 21
    edited 2008-09-16 21:04
    Already started, but one thing leads to another etc. etc. wink.gif)

    A whole load of commands were commented out, (ASincmd to FMul2Cmd). Why? Is there a slow implementation somewhere?

    Another question: You mentioned this object would reuse the same cog, even if loaded twice (from two other objects for instance). Is that correct? Aren't new instances of the cod and coglock variables loaded in such a case? This would causing a new cog to be started. Off course that may be desirable in a genuine parallel processing application, but not needed if in most applications.
  • M. K. BorriM. K. Borri Posts: 279
    edited 2008-09-16 23:04
    what I meant is that the cog is started, the op run, (a slow op is run in parallel by the starter if required), then the cog stops. Basically what I did for my stuff was make my app always use 5 cogs, and the other three would do duty as FPU's on a first come first serve...

    hope it helps [noparse]:)[/noparse] best i could do at the time!


    fadd2 and fmul2 were added to the Float32A assembly dat block so that I wouldnt have to unload F32A and load F32 when calculating distance between two points.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://forums.parallax.com/showthread.php?p=650217

    meow, i have my own topic now? (sorta)
Sign In or Register to comment.