#147 faster ___fsdiv.c file to contribute, if wanted

None
closed-out-of-date
None
5
2013-07-19
2009-11-03
Jon Kirwan
No

I installed the SDCC c compiler for use with SiLabs 8051 micro about a month ago. I finished my application but in the process I've also branched some of the code off and written a faster 32-bit floating division routine for most any 8051 core device. It follows the special case and error handling of the existing library routine, so it shouldn't break anything there. Roughly speaking, it is about twice as fast as the ___fsdiv.c file I found in sdcc\lib\src, based on the assembly version and not the generic GNU c code for it. It's a non-restoring division version, with 4 unrolled bits generated per loop. It is well-documented in the source file, as well. Extremely well documented.

Yes, it's larger. No, although I think it is well crafted, it is not well tested as yet and I've not walked it through a code review with anyone. Like the existing library, it does not do much more with denormals than recognize them as effectively zero. I didn't want to break anything by adding better denormal handling. Like the existing routine, it does not preserve sign when INF or NaN is generated. Again, not wanting to break things that may already depend on existing behavior.

Not sure how to contribute it, but I'm willing to consider doing that if it may be wanted. If not, that's fine. I can post it up on my web site.

Jon

PS. I do NOT come here often and I'm not sure when I next may do so. I can be contacted directly at jkirwan@infinitefactors.org.

Discussion

  • Maarten Brock
    Maarten Brock
    2009-11-03

    Jon,

    This is no bug. It's not even a patch yet, since the file is not attached, still that category fits best.

    I assume you filled in a valid email address when registering at sourceforge and therefor assume you will be notified of this comment automatically.

    Are you running sdcc on a *nix like machine? If so, you can run the regression tests by running make in sdcc/support/regression to test your modified _fsdiv. And if you think there are bugs in it or things that can/should be improved, please do not hesitate.

    I welcome your effort, please attach the file here.

    Maarten

     
  • Maarten Brock
    Maarten Brock
    2009-11-03

    • labels: 410691 -->
    • milestone: 100455 -->
     
  • Jon Kirwan
    Jon Kirwan
    2009-11-03

    8051 ___fsdiv() source code

     
    Attachments
  • Jon Kirwan
    Jon Kirwan
    2009-11-03

    I'm completely aware it's not a bug. It was my own lack of knowing where or how to present the idea that led me to write it up as I did. I need an education, I suppose. I apologize if the method I chose was inappropriate had I known better than I do.

    I do have a valid address with sourceforge and I did receive your email. Thanks.

    I'm running SDCC under Windows XP, right now. Further, I'm using the SiLabs IDE with SDCC integrated under it. I gather from the implications reading between the lines of your comment that this means I cannot run the regression tests here. I'd be happy to do so, though, if there are instructions for attempting this under Windows XP.

    I've attached the file, with an appropriate LGPL notice included. I did NOT use the #ifdef features of the current _fsdiv.c module because I felt that the exact setup was best handled by those better informed about the details of integration. Plus, that module includes some libgcc code from Pipeline Associates, 1991, and I felt it best to focus on conveying what I have and understand well rather than appending their code to this module and attempting to use/misuse #defines I have very little experience with.

    I merely figured that others might benefit from the work I did and hoped that someone better informed about what is needed for regression tests and final inclusion at your end could do the remaining edit/cuts to put it in proper final form. I'd be happy to be pointed to the right documentation to become better informed on my own, if that would reduce the load this represents.

    Jon

     
  • Jon Kirwan
    Jon Kirwan
    2009-11-06

    I did use SVN today to siphon down the sdcc/trunk set of sources and looked into the support/regression directories for floating point test files. I cannot say that I could get the make/build files operating under WinXP but I found the 'simplefloat.c' file and ran the tests in it (they aren't at all complicated or exhaustive.) The spare results available were, however, perfect. So far as I'm able to observe. (As they also were for other tests I'd already created and applied.)

    Well, I've done what I know how to do at this point. Use it or not. But for some, the doubling of division speed and the careful crafting of the code may be of some small use.

    I'm uploading a modified version of the file -- only the comments have been modified to remove some of the 'folksy' language, correct a few errors, and improve the overall flow, slightly.

    Jon

     
  • Jon Kirwan
    Jon Kirwan
    2009-11-06

    updated version for improved commentary

     
    Attachments
    • status: open --> closed-out-of-date
    • assigned_to: Philipp Klaus Krause
    • Group: -->