Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2553 > unrolled thread
| Started by | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| First post | 2012-12-01 12:39 +0000 |
| Last post | 2012-12-03 10:22 +0000 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.programming
integer Vs floating point efficiency? Rui Maciel <rui.maciel@gmail.com> - 2012-12-01 12:39 +0000
integer Vs floating point efficiency? Rui Maciel <rui.maciel@gmail.com> - 2012-12-01 12:41 +0000
Re: integer Vs floating point efficiency? Herman Rubin <hrubin@skew.stat.purdue.edu> - 2012-12-02 23:10 +0000
Re: integer Vs floating point efficiency? Robin Vowels <robin.vowels@gmail.com> - 2012-12-02 16:36 -0800
Re: integer Vs floating point efficiency? Rui Maciel <rui.maciel@gmail.com> - 2012-12-03 10:03 +0000
Re: integer Vs floating point efficiency? BGB <cr88192@hotmail.com> - 2012-12-01 16:49 -0600
Re: integer Vs floating point efficiency? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-12-03 10:22 +0000
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-12-01 12:39 +0000 |
| Subject | integer Vs floating point efficiency? |
| Message-ID | <k9ctp5$56j$1@dont-email.me> |
Is there any information on the relative efficiency of modern CPUs with regards to algebraic operations on integer and floating point data types? If there is, where can I get my hands on it? Thanks in advance, Rui Maciel
[toc] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-12-01 12:41 +0000 |
| Message-ID | <k9ctth$56j$2@dont-email.me> |
| In reply to | #2553 |
Gratuitous cross-posting to extend this query to s.m.num-analysis. Rui Maciel wrote: > Is there any information on the relative efficiency of modern CPUs with > regards to algebraic operations on integer and floating point data types? > > If there is, where can I get my hands on it? > > > Thanks in advance, > Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | Herman Rubin <hrubin@skew.stat.purdue.edu> |
|---|---|
| Date | 2012-12-02 23:10 +0000 |
| Message-ID | <slrnkbnnvl.mfi.hrubin@skew.stat.purdue.edu> |
| In reply to | #2554 |
On 2012-12-01, Rui Maciel <rui.maciel@gmail.com> wrote: > Gratuitous cross-posting to extend this query to s.m.num-analysis. > Rui Maciel wrote: >> Is there any information on the relative efficiency of modern CPUs with >> regards to algebraic operations on integer and floating point data types? >> If there is, where can I get my hands on it? >> Thanks in advance, >> Rui Maciel It depends on the operations. Unless the operations are integer operations, there is always conversion of integer to float. This conversion is not that efficient; it typically requires putting the integer in an integer register, shifting if necessary, placing an exponent in that register, putting it back in memory, reading it into a floating point register, and subtracting what the result would have been if it were 0. Even if memory references were not needed, and shifing not needed, and the same registers could be used for integers and floats, there are at least two operations required if the needed constants were already in memory. This is converting "single precision" integers into "double precision" floats. Getting the integer part of a float is even worse if not hardware. -- This address is for information only. I do not claim that these views are those of the Statistics Department or of Purdue University. Herman Rubin, Department of Statistics, Purdue University hrubin@stat.purdue.edu Phone: (765)494-6054 FAX: (765)494-0558
[toc] | [prev] | [next] | [standalone]
| From | Robin Vowels <robin.vowels@gmail.com> |
|---|---|
| Date | 2012-12-02 16:36 -0800 |
| Message-ID | <afbcb870-5d35-4ff8-9479-560097ce5c4f@r10g2000pbd.googlegroups.com> |
| In reply to | #2568 |
On Dec 3, 10:10 am, Herman Rubin <hru...@skew.stat.purdue.edu> wrote: > On 2012-12-01, Rui Maciel <rui.mac...@gmail.com> wrote: > > > Gratuitous cross-posting to extend this query to s.m.num-analysis. > > Rui Maciel wrote: > >> Is there any information on the relative efficiency of modern CPUs with > >> regards to algebraic operations on integer and floating point data types? > >> If there is, where can I get my hands on it? > >> Thanks in advance, > >> Rui Maciel > > It depends on the operations. Unless the operations are integer > operations, there is always conversion of integer to float. This > conversion is not that efficient; it typically requires putting > the integer in an integer register, shifting if necessary, placing > an exponent in that register, putting it back in memory, reading > it into a floating point register, and subtracting what the result > would have been if it were 0. Even if memory references were not > needed, and shifing not needed, and the same registers could be > used for integers and floats, there are at least two operations > required if the needed constants were already in memory. This > is converting "single precision" integers into "double precision" > floats. > > Getting the integer part of a float is even worse if not hardware. On Intel, instructions are provided to convert directly from integer to float, and vice-versa, and without referencing memory.. But the OP wanted to know the speed differences between performing operations on integers compared to performing operations on floats (and not the conversions between integers an floats).
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-12-03 10:03 +0000 |
| Message-ID | <k9htdd$gcj$1@dont-email.me> |
| In reply to | #2554 |
Gordon Sande wrote: > On 2012-12-01 08:41:21 -0400, Rui Maciel said: > > Instruction timings etc are to be found in the processor's data sheets. > Ask the manufacturer of one. The web sites will have copies or request > pages. I've followed your advice, and I'm in the process of digesting AMD and Intel's docs that cover this subject. If anyone is interested, the documents are available at: http://support.amd.com/us/psearch/Pages/psearch.aspx?type=2.1%3b2.12&product=2.1.2&contentType=Tech%20Doc%20Processor http://www.intel.com/content/www/us/en/processors/architectures-software- developer-manuals.html Unfortunately, the information isn't compiled or easily accessible. To make matters worse, I've stumbled on a claim that Intel's docs have been "incomplete and full of errors", which isn't very reassuring. Nevertheless, some info on this subject has been compiled by third parties, such as the following article: http://www.agner.org/optimize/instruction_tables.pdf As should be expected, latency varies with the make and model of the processor, and instruction latency alone doesn't say everything there is to say (or, possibly, anything) about the inherent efficiency of integer Vs floating point data types. In addition, there are more than a way to skin some numerical cats with the AMD64 platform, which adds to the complexity of this issue. Nevertheless, from what I gathered so far it appears that, in general, integer operations do present a small, but possibly entirely meaningless, efficiency advantage. Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Date | 2012-12-01 16:49 -0600 |
| Message-ID | <k9e1na$pl3$1@news.albasani.net> |
| In reply to | #2553 |
On 12/1/2012 6:39 AM, Rui Maciel wrote: > Is there any information on the relative efficiency of modern CPUs with > regards to algebraic operations on integer and floating point data types? > > If there is, where can I get my hands on it? > informal results are that integer is slightly faster, especially when working with integer data (because integer<->float conversions are expensive). the difference at this point is "modest" though, as both seem to be more at the whim of "how quickly the CPU can perform operations". the main advantage of integer though is that it is possible to more precisely control round-off behavior (allowing for more determinism), which, combined with it not suffering from conversion-performance issues, makes integer math better suited to things like signal processing and A/V codecs (which are typically, mostly, integer and fixed-point math). there are downsides to fixed-point though (vs floats), namely that it is more awkward than floating-point math (since manual handling of rounding and lots of shifts are needed), if used naively may be actually slower than floats, and typically has a more limited value-range (the number of bits above and below the decimal point may become an important factor in the operation of an algorithm). > > Thanks in advance, > Rui Maciel >
[toc] | [prev] | [next] | [standalone]
| From | "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> |
|---|---|
| Date | 2012-12-03 10:22 +0000 |
| Message-ID | <e7-dnUCPxvkm4iHNnZ2dnUVZ8vGdnZ2d@bt.com> |
| In reply to | #2553 |
Rui Maciel wrote:
> Is there any information on the relative efficiency of modern CPUs with
> regards to algebraic operations on integer and floating point data types?
A very valuable resource, comprehensive, and apparently expert (not being an
expert myself, I can't really tell):
http://www.agner.org/optimize/
Not sure how well he addresses your specific question (think he does but I
can't remember for certain), but a great source of understanding of these
highly non-trivial architectures.
-- chris
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web