Changeset 293 for trunk

Show
Ignore:
Timestamp:
06/09/11 23:15:34 (1 year ago)
Author:
dsimcha
Message:

Better loop unrolling: Speed up ILP optimized functions ~10%.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/base.d

    r290 r293  
    3838 
    3939import std.math, std.traits, std.typecons, std.algorithm, std.range, 
    40     std.exception, std.conv, std.functional
     40    std.exception, std.conv, std.functional, std.typetuple
    4141 
    4242import dstats.alloc, dstats.sort; 
     
    15781578} 
    15791579 
     1580// Used for ILP optimizations. 
     1581package template StaticIota(size_t upTo) { 
     1582    static if(upTo == 0) { 
     1583        alias TypeTuple!() StaticIota; 
     1584    } else { 
     1585        alias TypeTuple!(StaticIota!(upTo - 1), upTo - 1) StaticIota; 
     1586    } 
     1587} 
     1588 
    15801589// Verify that there are no TempAlloc memory leaks anywhere in the code covered 
    15811590// by the unittest.  This should always be the last unittest of the module. 
  • trunk/cor.d

    r258 r293  
    8686                immutable kNeg1 = 1 / ++_k; 
    8787 
    88                 foreach(j; 0..nILP) { 
     88                foreach(j; StaticIota!nILP) { 
    8989                    immutable double delta1 = input1[i + j] - _mean1[j]; 
    9090                    immutable double delta2 = input2[i + j] - _mean2[j]; 
  • trunk/summary.d

    r289 r293  
    394394                immutable kNeg1 = 1 / ++k; 
    395395 
    396                 foreach(j; 0..nILP) { 
     396                foreach(j; StaticIota!nILP) { 
    397397                    means[j] += (data[i + j] - means[j]) * kNeg1; 
    398398                } 
     
    514514 
    515515            for(; i + nILP < data.length; i += nILP) { 
    516                 foreach(j; 0..nILP) { 
     516                foreach(j; StaticIota!nILP) { 
    517517                    sum[j] += data[i + j]; 
    518518                } 
     
    712712                immutable kNeg1 = 1 / ++k; 
    713713 
    714                 foreach(j; 0..nILP) { 
     714                foreach(j; StaticIota!nILP) { 
    715715                    immutable double delta = data[i + j] - means[j]; 
    716716                    immutable deltaN = delta * kNeg1;