[PD] Findings regarding performance

Mathieu Bouchard matju at artengine.ca
Thu Dec 1 17:44:12 CET 2011


Le 2011-12-01 à 08:21:00, Jonathan Wilkes a écrit :
> ----- Original Message -----
>> From: Mathieu Bouchard <matju at artengine.ca>
>> 
>> One is made for blocksizes at least 8, and the other for blocksizes 1,2,4.
>
> Ok, so perf8 corresponds to "at least 8".  Thanks.

Well, actually it corresponds to "multiples of 8". You can see that those 
loops don't check whether there is anything left to do after they process 
chunks of 8.

But as long as blocksizes remain powers of two, there's no difference 
between «at least 8» and «positive multiple of 8».

>> Perf8 is a kind of explicit loop-unrolling, coded to greatly reduce the number 
>> of conditional jumps when looping a lot on tight loops. Conditional jumps are 
>> extremely slow on modern CPUs, and this affects if/else/for/do/while/switch as 
>> well as function pointers and virtual function calls.
>
> But there aren't any conditionals inside the loop-- it's just multiplication operators.

In «for(i=0;i<n;i++) foo[i]=42;» the conditional is «i<n» and the jump is 
performed if that conditional gives false (0). The compiler rewrites the 
code in this manner :

i=0;
while(i<n) {
   foo[i]=42;
   i++;
}

and then in this manner :

i=0;
here: if (i<n) goto there;
foo[i]=42;
i++;
goto here;
there:

But depending on which optimisations are turned on, it may transform it 
further. What I wrote is just the most basic compilation process.

  ______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC


More information about the Pd-list mailing list