Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #23573
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: Integer/Fixedpoint to 32 bit float |
| Date | 2016-04-07 13:52 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <ne5hfl$emc$1@dont-email.me> (permalink) |
| References | (1 earlier) <ne5547$3u2$1@dont-email.me> <ne55hg$4v2$1@dont-email.me> <ne5693$7q5$1@dont-email.me> <ne56lk$8lu$1@dont-email.me> <ne5e20$avb$1@gioia.aioe.org> |
On 07/04/16 12:50, Vincent vB wrote: > > On 7-4-2016 at 10:47, Dimiter_Popoff wrote: >> On 07.4.2016 г. 11:41, David Brown wrote: >>> On 07/04/16 10:28, Dimiter_Popoff wrote: >>>> On 07.4.2016 г. 11:21, David Brown wrote: >>>>> ... >>>>> The LatticeMicro 32 compiler is gcc. Use the "-ffast-math" option to >>>>> tell it that you are happy with a bit of obvious code re-arrangements >>>>> rather than insisting on perfect IEEE operation - this lets you >>>>> write "* >>>>> 2.0f / 32768" to clearly express your intent in the code, while the >>>>> /compiler/ turns it into "* (1f/32768f)". >>>>> >>>>> Write your code clearly and correctly, and let the tools do the work. >>>>> >>>>> Then all you need to do is make sure that you give the tools the best >>>>> chance to generate fast code (such as -O2 -ffast-math, and whatever >>>>> LM32 >>>>> flags such as -mbarrel-shift-enabled and -mmultiply-enabled are >>>>> appropriate for your particular cpu). >>>>> >>>>> >>>> >>>> Are you saying this will work without the compiler bringing in >>>> an FP library? >>>> >>> >>> Almost certainly the compiler will bring in parts of its FP library. >> >> The question you replied to was how to do the conversion _without_ >> bringing in an FP library. >> >> Dimiter >> > > I wrote a test, creating the fltFromI16 using floats, as suggested by > expert David Brown. > > I think I wrote my code clearly and correctly and let the /compiler/ do > the work, with the following additional objects as result: > > /libgcc.a(_mul_sf.o) > /libgcc.a(_div_sf.o) > /libgcc.a(_si_to_sf.o) > /libgcc.a(_thenan_sf.o) > /libgcc.a(_muldi3.o) > /libgcc.a(_lshrdi3.o) > /libgcc.a(_clzsi2.o) > /libgcc.a(_pack_sf.o) > /libgcc.a(_unpack_sf.o) > /libgcc.a(_mulsi3.o) > /libgcc.a(_udivmodsi4.o) > /libgcc.a(_clz.o) > > Used GCC flags that matter: > -mbarrel-shift-enabled -mmultiply-enabled > -msign-extend-enabled -Os -ffast-math > > 'The tools' also required 2736 more bytes for the same task than my > highly flawed and inferior code. > Whether your own code is flawed or not depends on whether or not it works, and what coding standards or practices you follow. And whether it is inferior or not depends on your requirements - some would say that baking the scaling constants into a somewhat complicated manually optimised function is inferior, while others would say that requiring a couple of extra KB of library code is inferior. I can't tell you what /you/ need for /your/ design. But I can ask you - are you so short on code space that these 2.7 KB is a significant issue? Or is it just that it "feels wrong" to "waste" this space? If it is the former (which is not unlikely if the code is in "rom" inside a small FPGA), then that's fine. If it is the later, then think about what is really the /best/ solution for you, the project, and the customer.
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-06 15:17 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 17:16 +0300
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 17:21 +0300
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 14:40 +0000
Re: Integer/Fixedpoint to 32 bit float Dave Nadler <drn@nadler.com> - 2016-04-06 08:21 -0700
Re: Integer/Fixedpoint to 32 bit float Robert Wessel <robertwessel2@yahoo.com> - 2016-04-06 12:33 -0500
Re: Integer/Fixedpoint to 32 bit float Robert Wessel <robertwessel2@yahoo.com> - 2016-04-06 12:36 -0500
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 17:56 +0000
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-06 22:45 +0300
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:06 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 11:26 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 11:29 +0200
Re: Integer/Fixedpoint to 32 bit float Wouter van Ooijen <wouter@voti.nl> - 2016-04-06 18:00 +0200
Re: Integer/Fixedpoint to 32 bit float Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2016-04-06 21:35 +0300
Re: Integer/Fixedpoint to 32 bit float Grant Edwards <invalid@invalid.invalid> - 2016-04-06 18:47 +0000
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 08:52 +0200
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <seemywebsite@myfooter.really> - 2016-04-06 16:05 -0500
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 00:23 +0300
Re: Integer/Fixedpoint to 32 bit float Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-06 21:30 +0000
Re: Integer/Fixedpoint to 32 bit float Clifford Heath <no.spam@please.net> - 2016-04-07 09:23 +1000
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:07 +0200
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <tim@seemywebsite.com> - 2016-04-07 11:14 -0500
Re: Integer/Fixedpoint to 32 bit float Tim Wescott <seemywebsite@myfooter.really> - 2016-04-06 18:36 -0500
Re: Integer/Fixedpoint to 32 bit float lasselangwadtchristensen@gmail.com - 2016-04-06 17:03 -0700
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 09:04 +0200
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 10:21 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 11:28 +0300
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 10:41 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 11:47 +0300
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 11:40 +0200
Re: Integer/Fixedpoint to 32 bit float Vincent vB <embedded@spam.com> - 2016-04-07 12:50 +0200
Re: Integer/Fixedpoint to 32 bit float David Brown <david.brown@hesbynett.no> - 2016-04-07 13:52 +0200
Re: Integer/Fixedpoint to 32 bit float Dimiter_Popoff <dp@tgi-sci.com> - 2016-04-07 22:14 +0300
Re: Integer/Fixedpoint to 32 bit float Nobody <nobody@nowhere.invalid> - 2016-04-08 03:39 +0100
csiph-web