Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #21625 > unrolled thread
| Started by | Tim Wescott <seemywebsite@myfooter.really> |
|---|---|
| First post | 2015-08-04 12:59 -0500 |
| Last post | 2015-08-06 12:56 +1000 |
| Articles | 3 on this page of 43 — 17 participants |
Back to article view | Back to comp.arch.embedded
Slightly OT: speed of operation on a PC Tim Wescott <seemywebsite@myfooter.really> - 2015-08-04 12:59 -0500
Re: Slightly OT: speed of operation on a PC rickman <gnuarm@gmail.com> - 2015-08-04 14:06 -0400
Re: Slightly OT: speed of operation on a PC Lanarcam <lanarcam1@yahoo.fr> - 2015-08-04 20:06 +0200
Re: Slightly OT: speed of operation on a PC Tim Wescott <seemywebsite@myfooter.really> - 2015-08-04 13:27 -0500
Re: Slightly OT: speed of operation on a PC Lanarcam <lanarcam1@yahoo.fr> - 2015-08-04 20:33 +0200
Re: Slightly OT: speed of operation on a PC rickman <gnuarm@gmail.com> - 2015-08-04 17:05 -0400
Re: Slightly OT: speed of operation on a PC Tim Wescott <seemywebsite@myfooter.really> - 2015-08-04 18:54 -0500
Re: Slightly OT: speed of operation on a PC glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-05 00:09 +0000
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-04 17:32 -0700
Re: Slightly OT: speed of operation on a PC Clifford Heath <no.spam@please.net> - 2015-08-05 17:25 +1000
Re: Slightly OT: speed of operation on a PC Anders.Montonen@kapsi.spam.stop.fi.invalid - 2015-08-05 08:34 +0000
Re: Slightly OT: speed of operation on a PC Philipp Klaus Krause <pkk@spth.de> - 2015-08-11 11:04 +0200
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-04 11:07 -0700
Re: Slightly OT: speed of operation on a PC Tim Wescott <seemywebsite@myfooter.really> - 2015-08-04 13:28 -0500
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-04 11:37 -0700
Re: Slightly OT: speed of operation on a PC Tom Gardner <spamjunk@blueyonder.co.uk> - 2015-08-04 22:20 +0100
Re: Slightly OT: speed of operation on a PC glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-04 21:45 +0000
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-04 15:34 -0700
Re: Slightly OT: speed of operation on a PC glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-05 00:00 +0000
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-04 17:36 -0700
Re: Slightly OT: speed of operation on a PC glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-08-05 05:43 +0000
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-05 00:44 -0700
Re: Slightly OT: speed of operation on a PC Clifford Heath <no.spam@please.net> - 2015-08-05 19:14 +1000
Re: Slightly OT: speed of operation on a PC Don Y <this@is.not.me.com> - 2015-08-05 08:04 -0700
Re: Slightly OT: speed of operation on a PC Clifford Heath <no.spam@please.net> - 2015-08-05 17:28 +1000
Re: Slightly OT: speed of operation on a PC Paul Rubin <no.email@nospam.invalid> - 2015-08-04 11:13 -0700
Re: Slightly OT: speed of operation on a PC "Bill Davy" <Bill@SynectixLtd.com> - 2015-08-04 19:19 +0100
Re: Slightly OT: speed of operation on a PC Tom Gardner <spamjunk@blueyonder.co.uk> - 2015-08-04 22:18 +0100
Re: Slightly OT: speed of operation on a PC Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2015-08-05 10:25 +0000
Re: Slightly OT: speed of operation on a PC Tom Gardner <spamjunk@blueyonder.co.uk> - 2015-08-05 11:42 +0100
Re: Slightly OT: speed of operation on a PC Anders.Montonen@kapsi.spam.stop.fi.invalid - 2015-08-05 11:23 +0000
Re: Slightly OT: speed of operation on a PC David Brown <david.brown@hesbynett.no> - 2015-08-05 13:58 +0200
Re: Slightly OT: speed of operation on a PC Robert Wessel <robertwessel2@yahoo.com> - 2015-08-06 00:24 -0500
Re: Slightly OT: speed of operation on a PC David Brown <david.brown@hesbynett.no> - 2015-08-05 12:59 +0200
Re: Slightly OT: speed of operation on a PC Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-08-04 23:30 +0200
Re: Slightly OT: speed of operation on a PC Philipp Klaus Krause <pkk@spth.de> - 2015-08-11 11:19 +0200
Re: Slightly OT: speed of operation on a PC David Brown <david.brown@hesbynett.no> - 2015-08-05 08:32 +0200
Re: Slightly OT: speed of operation on a PC Stefan Reuther <stefan.news@arcor.de> - 2015-08-05 18:43 +0200
Re: Slightly OT: speed of operation on a PC edward.ming.lee@gmail.com - 2015-08-05 10:31 -0700
Re: Slightly OT: speed of operation on a PC Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-08-05 20:11 +0200
Re: Slightly OT: speed of operation on a PC rickman <gnuarm@gmail.com> - 2015-08-05 20:19 -0400
Re: Slightly OT: speed of operation on a PC edward.ming.lee@gmail.com - 2015-08-05 19:45 -0700
Re: Slightly OT: speed of operation on a PC Clifford Heath <no.spam@please.net> - 2015-08-06 12:56 +1000
Page 3 of 3 — ← Prev page 1 2 [3]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2015-08-05 20:19 -0400 |
| Message-ID | <mpu93f$o7o$2@dont-email.me> |
| In reply to | #21675 |
On 8/5/2015 1:31 PM, edward.ming.lee@gmail.com wrote: > On Tuesday, August 4, 2015 at 10:59:08 AM UTC-7, Tim Wescott wrote: >> Which do you think is quicker on a PC, with the latest gnu compiler: >> >> double a = something; >> double b = something else; >> >> if (a >= 0.0 && b < 0.0) >> >>>> or << >> >> if (a * b <= 0) >> >> Thank you for your time. > > I just wrote a test program. The first statement is 10% faster than the second. You can argue all you want, but nothing beat benchmarking. What code is generated? Seems like 10% is close enough that "faster" may change with different hardware and tools. -- Rick
[toc] | [prev] | [next] | [standalone]
| From | edward.ming.lee@gmail.com |
|---|---|
| Date | 2015-08-05 19:45 -0700 |
| Message-ID | <7e012cd1-291e-4388-ab69-a5029a3ad7f9@googlegroups.com> |
| In reply to | #21682 |
On Wednesday, August 5, 2015 at 5:19:31 PM UTC-7, rickman wrote:
> On 8/5/2015 1:31 PM, edward.ming.lee@gmail.com wrote:
> > On Tuesday, August 4, 2015 at 10:59:08 AM UTC-7, Tim Wescott wrote:
> >> Which do you think is quicker on a PC, with the latest gnu compiler:
> >>
> >> double a = something;
> >> double b = something else;
> >>
> >> if (a >= 0.0 && b < 0.0)
> >>
> >>>> or <<
> >>
> >> if (a * b <= 0)
> >>
> >> Thank you for your time.
> >
> > I just wrote a test program. The first statement is 10% faster than the second. You can argue all you want, but nothing beat benchmarking.
>
> What code is generated? Seems like 10% is close enough that "faster"
> may change with different hardware and tools.
I timed two loops, looking at the user time.
t1.c:
for(i=0; i<10000000; i++)
{
if (a >= 0.0 && b < 0.0)
j++;
}
t2.c:
for(i=0; i<10000000; i++)
{
if (a * b <= 0)
j++;
}
Actually, t1 is 10% faster if a & b are integers and 20% faster if a & b are doubles.
----------------------------------
.file "t1.c"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-8, %esp
subl $32, %esp
movl $0, 8(%esp)
jmp .L2
.L6:
fldl 16(%esp)
fldz
fxch %st(1)
fucomip %st(1), %st
fstp %st(0)
jb .L3
.L7:
fldz
fldl 24(%esp)
fxch %st(1)
fucomip %st(1), %st
fstp %st(0)
jbe .L3
.L8:
addl $1, 12(%esp)
.L3:
addl $1, 8(%esp)
.L2:
cmpl $9999999, 8(%esp)
jle .L6
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
.section .note.GNU-stack,"",@progbits
----------------------------------
.file "t2.c"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-8, %esp
subl $32, %esp
movl $0, 8(%esp)
jmp .L2
.L5:
fldl 16(%esp)
fmull 24(%esp)
fldz
fucomip %st(1), %st
fstp %st(0)
jb .L3
.L6:
addl $1, 12(%esp)
.L3:
addl $1, 8(%esp)
.L2:
cmpl $9999999, 8(%esp)
jle .L5
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
.section .note.GNU-stack,"",@progbits
[toc] | [prev] | [next] | [standalone]
| From | Clifford Heath <no.spam@please.net> |
|---|---|
| Date | 2015-08-06 12:56 +1000 |
| Message-ID | <v0Awx.3$_D5.0@fx21.iad> |
| In reply to | #21683 |
On 06/08/15 12:45, edward.ming.lee@gmail.com wrote:
> On Wednesday, August 5, 2015 at 5:19:31 PM UTC-7, rickman wrote:
>> On 8/5/2015 1:31 PM, edward.ming.lee@gmail.com wrote:
>>> On Tuesday, August 4, 2015 at 10:59:08 AM UTC-7, Tim Wescott wrote:
>>>> Which do you think is quicker on a PC, with the latest gnu compiler:
>>>> double a = something;
>>>> double b = something else;
>>>> if (a >= 0.0 && b < 0.0)
>>>>>> or <<
>>>> if (a * b <= 0)
>>>> Thank you for your time
>>> I just wrote a test program. The first statement is 10% faster than the second. You can argue all you want, but nothing beat benchmarking
>> What code is generated? Seems like 10% is close enough that "faster"
>> may change with different hardware and tools.
> I timed two loops, looking at the user time.
If you enable the optimiser, neither of these two executes the loop.
Since a and b don't change inside the loop, j will always be either
unchanged or incremented by 10000000, and the compiler figures that out
and removes the loop.
Clifford Heath.
> t1.c:
> for(i=0; i<10000000; i++)
> {
> if (a >= 0.0 && b < 0.0)
> j++;
> }
>
> t2.c:
> for(i=0; i<10000000; i++)
> {
> if (a * b <= 0)
> j++;
> }
>
> Actually, t1 is 10% faster if a & b are integers and 20% faster if a & b are doubles.
>
> ----------------------------------
>
> .file "t1.c"
> .text
> .globl main
> .type main, @function
> main:
> .LFB0:
> .cfi_startproc
> pushl %ebp
> .cfi_def_cfa_offset 8
> .cfi_offset 5, -8
> movl %esp, %ebp
> .cfi_def_cfa_register 5
> andl $-8, %esp
> subl $32, %esp
> movl $0, 8(%esp)
> jmp .L2
> .L6:
> fldl 16(%esp)
> fldz
> fxch %st(1)
> fucomip %st(1), %st
> fstp %st(0)
> jb .L3
> .L7:
> fldz
> fldl 24(%esp)
> fxch %st(1)
> fucomip %st(1), %st
> fstp %st(0)
> jbe .L3
> .L8:
> addl $1, 12(%esp)
> .L3:
> addl $1, 8(%esp)
> .L2:
> cmpl $9999999, 8(%esp)
> jle .L6
> leave
> .cfi_restore 5
> .cfi_def_cfa 4, 4
> ret
> .cfi_endproc
> .LFE0:
> .size main, .-main
> .ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
> .section .note.GNU-stack,"",@progbits
>
> ----------------------------------
>
> .file "t2.c"
> .text
> .globl main
> .type main, @function
> main:
> .LFB0:
> .cfi_startproc
> pushl %ebp
> .cfi_def_cfa_offset 8
> .cfi_offset 5, -8
> movl %esp, %ebp
> .cfi_def_cfa_register 5
> andl $-8, %esp
> subl $32, %esp
> movl $0, 8(%esp)
> jmp .L2
> .L5:
> fldl 16(%esp)
> fmull 24(%esp)
> fldz
> fucomip %st(1), %st
> fstp %st(0)
> jb .L3
> .L6:
> addl $1, 12(%esp)
> .L3:
> addl $1, 8(%esp)
> .L2:
> cmpl $9999999, 8(%esp)
> jle .L5
> leave
> .cfi_restore 5
> .cfi_def_cfa 4, 4
> ret
> .cfi_endproc
> .LFE0:
> .size main, .-main
> .ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
> .section .note.GNU-stack,"",@progbits
>
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.arch.embedded
csiph-web