Le vendredi 02 mars 2007 à 12:01 +0100, Vanuxem Grégory a écrit :
> Le vendredi 02 mars 2007 à 09:01 +0000, Xavier Calbet a écrit :
> > Hello,
> >
> > I am getting confused now with inplace. The detailed code and times
> > are shown below.
> > I am running three tests trying to implement inplace operations
> > to make the code faster. The summary is:
> >
> > Test # command time
> > 1: $Re=$Re+1000.; 58 sec
> > 2: $Re.=$Re+1000.; 109 sec
> > 3: $Re->inplace;$Re+1000.; 55 sec
>
> #1: a new piddle of ~30Mb is created, threading is used (threading along
> dimension 0 and 1 of $Re). Affectation of the new result of each
> addition to the elements of this new piddle.
>
> #2: same thing _+_ affectation of the _new_ 2000x2000 piddle (after
> calculation) to $Re, each element at a time.
> (I find your timing surprising)
>
> #3: threading as in #1 and #2 but no new piddle, results of additions
> affected to elements of $Re "inplace".
> (in C : Re[x,y] = Re[x,y]*1000, approximatively, since piddle are
> represented by a one dimensional array in a more complex structure).
>
>
> with 2000x2000 piddle of double (from your code below)
> ----------------------------------
> ---- #1
> time perl pdl.pl
>
> real 0m48.948s
> user 0m25.947s
> sys 0m22.981s
>
> ---- #3
> time perl pdl_i.pl
>
> real 0m23.460s
> user 0m23.032s
> sys 0m0.350s
> ----------------------------------
Forgot to say : look at the system time (kernel, in part due to memory
allocation/deallocation).
Greg
>
> 23 secondes against 48.
>
> Apparently you made a mistake, your timings above do not reflect the
> ones below.
>
> Greg
>
>
> >
> > I believe test 3 is doing things really inplace, but its time is almost
> > the
> > same as test 1, which is the "easy" way. Does this mean
> > that test 1 is really done inplace? Or maybe test 3 is not done inplace?
> >
> > I thought the .= operator performed operations inplace, and I would have
> > thought test 2 was also doing things inplace like test 3. Obviously it is
> > not. In fact it is taking twice the time to run probably meaning it is
> > doing the calculations twice. What am I missing here?
> >
> > Many thanks again,
> >
> > Xavier
> >
> >
> > *******************************************
> > Test 1
> > -----------------------------------------
> > $npts=2000;
> > $niter=1000;
> > $Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
> >
> > for($j=0;$j<$niter;$j++){
> > $Re=$Re+1000.;
> > }
> > ------------------------------------------------
> > time output:
> >
> > real 1m0.727s
> > user 0m22.794s
> > sys 0m36.667s
> >
> > ******************************************************
> > Test 2:
> > ---------------------------------------------------
> > $npts=2000;
> > $niter=1000;
> > $Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
> >
> > for($j=0;$j<$niter;$j++){
> > $Re.=$Re+1000.;
> > }
> > ------------------------------------------------------
> > time output:
> >
> > real 1m53.829s
> > user 1m11.915s
> > sys 0m37.040s
> >
> > *******************************************************
> > Test 3
> > -------------------------------------------------------
> > $npts=2000;
> > $niter=1000;
> > $Re=zeroes(double,$npts,$npts)->xlinvals(-1.5,0.5);
> >
> > for($j=0;$j<$niter;$j++){
> > $Re->inplace;
> > $Re+1000.;
> > }
> > --------------------------------------------------------
> > time output:
> >
> > real 0m33.181s
> > user 0m32.446s
> > sys 0m0.190s
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl