restrict in practice

#ponce nospam at nospam.com
Mon Jan 4 01:45:34 PST 2010


VisualDSP++ has a great deal of pragmas to deal with aliasing and optimization at the loop-level. They are quite handy and require less work than restrict imho. Aliasing is especially annoying with loops.

// tell the optimizer there is no pointer aliasing in the whole loop
#pragma no_alias  

// minimum and maximum loop count
#pragma loop_count(24, 48, 8)  

// tell the optimizer this loop can be run in parallel
// implies no_alias 
// (similar to #pragma omp parallel for)
#pragma vector_for 
for (i=0;i<taps;i++)
    acc += x[i]*y[i];

Of course array slices operations are a convenient way to prevent aliasing problems but carrying the length information is an overhead and could prevent loop-unrolling.




More information about the Digitalmars-d mailing list