Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 29, 2010 Results are in: static foreach is a slower than hand unrolling your loops or using mixins. | ||||
---|---|---|---|---|
| ||||
I managed to get some free time to look at this and it would appear that static foreach is slower than hand unrolling a loop. Fortunately there are no detectable differences between hand unrolling a loop and building the body of the loop in a compile time string and using a mixin. Results are here: http://github.com/gcharnock/phoboslinalgebra/blob/4d1f62ce2f866acf24f237be77a2b59158571de0/staticloop_results.txt Test program is here: http://github.com/gcharnock/phoboslinalgebra/blob/4d1f62ce2f866acf24f237be77a2b59158571de0/staticloops.d |
April 29, 2010 Re: Results are in: static foreach is a slower than hand unrolling your loops or using mixins. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gareth Charnock | Correction, two of the loops were going backwards (mixin and hand unrolled). Fixed this but the conclusion remains the same.
Gareth Charnock wrote:
> I managed to get some free time to look at this and it would appear that static foreach is slower than hand unrolling a loop. Fortunately there are no detectable differences between hand unrolling a loop and building the body of the loop in a compile time string and using a mixin. Results are here:
>
> http://github.com/gcharnock/phoboslinalgebra/blob/4d1f62ce2f866acf24f237be77a2b59158571de0/staticloop_results.txt
>
>
> Test program is here:
>
> http://github.com/gcharnock/phoboslinalgebra/blob/4d1f62ce2f866acf24f237be77a2b59158571de0/staticloops.d
>
|
April 30, 2010 Re: Results are in: static foreach is a slower than hand unrolling your | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gareth Charnock | You can try LDC compiler too (D1 only) with few changes. Note: LDC isn't using LLVM 2.7 yet. Bye, bearophile |
April 30, 2010 Re: Results are in: static foreach is a slower than hand unrolling yourloops or using mixins. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gareth Charnock | Hello Gareth, > I managed to get some free time to look at this and it would appear > that static foreach is slower than hand unrolling a loop. Fortunately > there are no detectable differences between hand unrolling a loop and > building the body of the loop in a compile time string and using a > mixin. Results are here: Last time I checked, static foreach tended to load the index onto the stack for each iteration even if it was never used. Did you take a look at the ASM? -- ... <IXOYE>< |
April 30, 2010 Re: Results are in: static foreach is a slower than hand unrolling yourloops or using mixins. | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | I don't actually know assembly language so no, this is all purely empirical.
BCS wrote:
> Hello Gareth,
>
>> I managed to get some free time to look at this and it would appear
>> that static foreach is slower than hand unrolling a loop. Fortunately
>> there are no detectable differences between hand unrolling a loop and
>> building the body of the loop in a compile time string and using a
>> mixin. Results are here:
>
> Last time I checked, static foreach tended to load the index onto the stack for each iteration even if it was never used. Did you take a look at the ASM?
>
|
Copyright © 1999-2021 by the D Language Foundation