SiliconValley
Joined: 24 May 2011 Posts: 6
|
Posted: Tue Feb 21, 2012 9:03 pm Post subject: Loop not vectorized: mixed data types |
|
|
The loop in the following code, when compiled on linux with:
| Code: | | 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
Ideas?
Thenks a lot!
mario
| Code: | #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;
} |
|
|
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Feb 22, 2012 9:25 am Post subject: |
|
|
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 |
|