* Mark Rose <markrose@xxxxxxxxxxx> wrote: Hi, > I have a line that gets called approxmiately 2 trillion times according to > valgrind, and I love any suggestions for speeding it up. I have taken over the > project from someone else and my C abilities are only intermediate. I've > attached a trimmed down version of the function. Maybe it helps putting the critical arrays like cdf as big global variables in the data segment instead of dynamic allocation. IMHO, this reduce the addressing by one indirection. For example, address computation for cdf[k] yet needs to calculate: (.DATA[cdf_offset]) + k*sizeof(double) while w/ static data segment array, the first term becomes a constand value: DATA_CDF_OFFSET + k*sizeof(double) Another idea, to optimize the the expressions: dcount[k+d_offset] wcount[k+w_offset] you could first calculate (before the k-loop): dcount[d_offset] wcount[w_offset] and then add k for each loop cycle. cu -- ---------------------------------------------------------------------- Enrico Weigelt, metux IT service -- http://www.metux.de/ phone: +49 36207 519931 email: weigelt@xxxxxxxx mobile: +49 151 27565287 icq: 210169427 skype: nekrad666 ---------------------------------------------------------------------- Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme ----------------------------------------------------------------------