Loop not vectorized: mixed data types

The loop in the following code, when compiled on linux with:

pgCC -c -fast -O3 -Mipa=fast,inline,libopt,libinline -Mvect -Munroll -Mconcur=allcores --restrict -Mneginfo=loop,vect

is not vectorized due to “mixed data types”. Following a suggestion from this forum, I changed size_t to long long (see the typedef) to have all variables 64 bits in the loop but no change. The code is part of a big class, here is reduced to have something compilable, but unfortunately neither Minfo nor Mneginfo show anything.

pgCC 11.10-0 64-bit target on x86-64 Linux -tp istanbul

Thenks a lot!

#include <cmath>
#include <cstring>
extern size_t getNumSites(void);
extern const double* getSiteMultiplicity(void);
double compute(void)
     double mMaxLnL = -10000;
     double mLikelihoods[10000];
     double mProportions[4];

     //typedef long long SIZE_T;
     typedef size_t SIZE_T;

    const SIZE_T num_sites = getNumSites();
    const double* mult = getSiteMultiplicity();
    double lnl = 0;
    for(SIZE_T site=0; site < num_sites; ++site)
        double p = mLikelihoods[0*num_sites+site];
        if(p <0> 0) p += (mProportions[1]+mProportions[3])*x;
        x = mLikelihoods[2*num_sites+site];
        if(x > 0) p += mProportions[2]*x;

        x = (p > 0) ? log(p) : mMaxLnL-100000;
        lnl += x*mult[site];
        return lnl;

Hi Mario,

It’s the if statments since vectorization is difficult across multiple-blocks. Also, it doesn’t look like there is much computation so vectorization may not be worthwhile.

  • Mat