Mark and friends, Please forgive me for potentially silly question that may not help Mark speedup his program. If I understand the "const" keyword, it tells the computer that after a const variable gets its first value, that variable's value will be unchangeable. So I wonder why our friend has declared some const variables inside a for-loop and why those variables appear on the left sides of the assignment operator inside that loop. Silly question: Could Mark's computer be wasting time by trying to change the value of a variable that already has an unchangeable value? Bill > > > I accidentally forgot to save the reduced file before attaching it. Here is the > proper attchment. > > -Mark > > On Saturday 15 May 2010 3:59:30 pm Mark Rose wrote: > > Hi All, > > > > 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. > > > > Here are some notes about the code: > > * tsMemAlloc and tsMemFree are basically wrappers to malloc/free. > > * dsfmt_genrand_close_open() generates a number in the range [0,1) > > > > And notes about the data: > > * n_topics is 35 (loaded from a configuration file; changeable) > > * n_tokens is about 7M (and increases as the data set grows) > > * params->iter is 500 > > * topics->wcount size is about 190k items > > * topics->dcount size is about 275k items > > * topics->tcount size is 35 items > > > > I'm compling on an Opteron, with options: -03 -std=gnu99 -march=native > > -ffast- math -ftree-loop-distribution -ftree-loop-linear > > -ftree-interchange -floop- block -ftree-vectorizer-verbose=8 > > > > I'm using GCC 4.4.3. > > > > The tree vectorizer spits out this note about the loop I'm particularly > > interested in: > > > > for (int k = 1; k < n_topics; k++) > > cdf[k] = cdf[k-1] + (dcount[k+d_offset] + alpha)*(wcount[k+w_offset + > > beta)/(tcount[k] + wbeta); > > note: not vectorized: data ref analysis failed D.8597_92 = *D.8596_91; > > > > I've done hours of googling, playing with restrict keywords, splitting the > > cdf[k-1] addition into another loop, and nothing will help. The error > > message itself is very poor, as I can't find a decent explanation anywhere > > online as to what it means nor how to fix it. > > > > Thanks for whatever insight you can give! > > > > -Mark > > > > ________________________________________________________________ Please visit a saintly hero: http://www.jakemoore.org