|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>
> On 11 Feb 2002 07:18:33 -0500, Warp <war### [at] tagpovrayorg> wrote:
> > : Any comments ?
> >
> > One of the oldest tricks known, loop unrolling, should speed up as well.
>
> Nobody likes unrolling 1000000 iterations ;-)
But what is then the shell for ?
I can use it to generate the 1000000 iteration steps... a big file.
but that's about only 80 megs for a single step of 80 chars.
Upto 2 Giga, there should not be any problem.
PS: Given that there is nothing in your loop, what about
#local C=0;
#local C=100000;
Instead ?
--
Non Sine Numine
http://grimbert.cjb.net/
Puis, s'il advient d'un peu triompher, par hasard,
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 11 Feb 2002 07:43:27
Message: <3c67bc6e@news.povray.org>
|
|
|
| |
| |
|
|
: Nobody likes unrolling 1000000 iterations ;-)
That's not what loop unrolling means.
It means that you take a divisor of the number of loops to perform and
"unroll" the body of the loop that many times and decrease the loop index by
that amount.
That is, if your loop is something like:
#declare Ind = 1000000;
#while(Ind)
do_something()
#declare Ind = Ind-1;
#end
you convert it to something like:
#declare Ind = 1000000;
#while(Ind)
do_something()
do_something()
do_something()
do_something()
do_something()
do_something()
do_something()
do_something()
do_something()
do_something()
#declare Ind = Ind-10;
#end
This should parse faster.
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
<jer### [at] atosorigincom> wrote:
> > Nobody likes unrolling 1000000 iterations ;-)
>
> But what is then the shell for ?
It was general experiment to show:
"if you have to use loop then use it this way becouse it's faster"
If there is no need to use loop then of course
this experiment has nothing to do.
I hope there are other users who appreciate result of this experiment.
> PS: Given that there is nothing in your loop, what about
> #local C=0;
> #local C=100000;
> Instead ?
What about one line version:
#local C=1e6;
instead ?
ABX
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 11 Feb 2002 07:43:27 -0500, Warp <war### [at] tagpovrayorg> wrote:
> : Nobody likes unrolling 1000000 iterations ;-)
>
> That's not what loop unrolling means.
Oh, I misunderstand your answer.
> It means that you take a divisor of the number of loops to perform and
> "unroll" the body of the loop that many times and decrease the loop index by
> that amount.
But this can still cooperate with both my advises.
ABX
Post a reply to this message
|
|
| |
| |
|
|
From: Jonathan Wooldridge
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 25 May 2002 16:29:51
Message: <3ceff43f@news.povray.org>
|
|
|
| |
| |
|
|
> >
> > One of the oldest tricks known, loop unrolling, should speed up as
well.
>
> Nobody likes unrolling 1000000 iterations ;-)
>
Loop unrolling isn't about coding every iteration, for that very reason.
Doing an unroll of a loop reduces the number of passes for the loop.
If you have a million iterations, then there is some overhead for each of a
million passes through the loop.
You can reduce this by a factor of ten, by unrolling the loop ten times
within the loop.
Try timing this:
// Unrolled Script
#local C=1000000;
#while(C)
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#local C=C-1;
// Do stuff with C
#end
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 25 May 2002 16:49:41
Message: <3ceff8e4@news.povray.org>
|
|
|
| |
| |
|
|
Jonathan Wooldridge <jwo### [at] attbicom> wrote:
> #local C=C-1;
> // Do stuff with C
> #local C=C-1;
> // Do stuff with C
If you can get rid of those #locals and do only one #local C=C-10 at the
end of the loop, better.
--
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
From: Jonathan Wooldridge
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 25 May 2002 21:37:37
Message: <3cf03c61$1@news.povray.org>
|
|
|
| |
| |
|
|
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3ceff8e4@news.povray.org...
> Jonathan Wooldridge <jwo### [at] attbicom> wrote:
> > #local C=C-1;
> > // Do stuff with C
>
> > #local C=C-1;
> > // Do stuff with C
>
> If you can get rid of those #locals and do only one #local C=C-10 at the
> end of the loop, better.
>
No sooner said than done!
// Script without so many locals ("Spam, spam, spam and eggs spam hasn't got
too much spam in it"...)
#local C=1000000;
#while(C)
do_stuff( C );
do_stuff( C - 1 );
do_stuff( C - 2 );
...
do_stuff( C - 8 );
do_stuff( C - 9 );
do_stuff( C - 10 );
#local C = C - 10;
#end
Post a reply to this message
|
|
| |
| |
|
|
From: Warp
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 25 May 2002 23:02:45
Message: <3cf05055@news.povray.org>
|
|
|
| |
| |
|
|
Jonathan Wooldridge <jwo### [at] attbicom> wrote:
> do_stuff( C );
> do_stuff( C - 1 );
> do_stuff( C - 2 );
> ...
> do_stuff( C - 8 );
> do_stuff( C - 9 );
> do_stuff( C - 10 );
You are doing 11 things there, not 10.
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Sat, 25 May 2002 18:38:58 -0700, "Jonathan Wooldridge"
<jwo### [at] attbicom> wrote:
> No sooner said than done!
> // Script without so many locals ("Spam, spam, spam and eggs spam hasn't got
> too much spam in it"...)
> #local C=1000000;
> #while(C)
> do_stuff( C );
> do_stuff( C - 1 );
> do_stuff( C - 2 );
> ...
> do_stuff( C - 8 );
> do_stuff( C - 9 );
> do_stuff( C - 10 );
> #local C = C - 10;
> #end
Are you aware that calling macro usually isn't faster than perform float
#local in current pov parser ?
ABX
Post a reply to this message
|
|
| |
| |
|
|
From: Jonathan Wooldridge
Subject: Re: Tips & tricks: How speed-up calculations in loops - part II
Date: 28 May 2002 20:52:00
Message: <3cf42630$1@news.povray.org>
|
|
|
| |
| |
|
|
<jwo### [at] attbicom> wrote:
> > No sooner said than done!
> > // Script without so many locals ("Spam, spam, spam and eggs spam hasn't
got
> > too much spam in it"...)
> > #local C=1000000;
> > #while(C)
> > do_stuff( C );
> > do_stuff( C - 1 );
> > do_stuff( C - 2 );
> > ...
> > do_stuff( C - 8 );
> > do_stuff( C - 9 );
> > do_stuff( C - 10 );
> > #local C = C - 10;
> > #end
>
> Are you aware that calling macro usually isn't faster than perform float
> #local in current pov parser ?
>
> ABX
The do_stuff( x - y) statements are place holders, they are not meant to
represent an additional macro call. Think of them as pseudo-code, in order
to discuss the topic. If you had planned to execute a sphere{} instruction a
million times, then replace the do_stuff statements with sphere{} statements
TEN times (for the last guy who pointed out an off-by-one error).
As far as performance between declaring a variable, and calling a macro, I
haven't written anything to test that out.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |