Community
cancel
Showing results for 
Search instead for 
Did you mean: 
snirgaz
Beginner
58 Views

ippmSub_vav_64f is slower than regular loop

Hi All,

I am comparing ippmSub_vav_64f with a regular loop implementation. The ipp result is significantly slower.

Compile line:

icpc -O3 -ipp=common test.cpp

results:

Ipp Time (uSec):1228
Regular Loop Time (uSec):881

Runs on:

Hi All,

I am comparing ippmSub_vav_64f with regular loop. The ipp result is significantly slower.

Compile line:

icpc -O3 -ipp=common test.cpp

results:

Ipp Time (uSec):1228
Regular Loop Time (uSec):881

Runs on:

Intel Xeon CPU X5550 @ 2.67GHz

Code:

#include
#include
#include
#include

#define VEC_SIZE 20000
#define DIM 3
#define REPEAT_SIZE 10

int main(){
// Output Array
double *aIpp=new double[VEC_SIZE*DIM];
double *aLoop=new double[VEC_SIZE*DIM];
// Rand Arrays
double *temp_a=new double[VEC_SIZE*DIM];
double *temp_b=new double[DIM];
unsigned int seed=5;
int j,d,i;
int stride0=sizeof(double),stride2=VEC_SIZE*sizeof(double);
// Timing Vars
timeval startTime;
timeval endTime;
double tS,tE;
// Draw Arrays
ippsRandUniform_Direct_64f(temp_a, VEC_SIZE*DIM,0,1000,&seed);
ippsRandUniform_Direct_64f(temp_b, DIM,0,1000,&seed);
// IPP Sub
gettimeofday(&startTime, NULL);
for (j=0; j ippmSub_vav_64f(temp_a, stride0, stride2, temp_b, stride0, aIpp,stride0, stride2, DIM, VEC_SIZE);
}
gettimeofday(&endTime, NULL);
tS = startTime.tv_sec*1000000 + (startTime.tv_usec);
tE = endTime.tv_sec*1000000 + (endTime.tv_usec);
std::cout<< "Ipp Time (uSec):" << (tE-tS) << "\\n";
// Regular Sub
gettimeofday(&startTime, NULL);
for (j=0; j for (d=0;d for (i=0;i aLoop[i+VEC_SIZE*d]=temp_a[i+VEC_SIZE*d]-temp_b;
}
}
gettimeofday(&endTime, NULL);
tS = startTime.tv_sec*1000000 + (startTime.tv_usec);
tE = endTime.tv_sec*1000000 + (endTime.tv_usec);
std::cout<< "Regular Loop Time (uSec):" << (tE-tS) << "\\n";
for (i=0;i if (fabs(aLoop-aIpp)>0.0001) std::cout <<"Error";
}


Any thoughts?

Thanks !

Snir







0 Kudos
4 Replies
Chao_Y_Intel
Employee
58 Views

Hello,

It looks that you are computing the vector with size 20000. Actually, IPP MX functions are optimized for operations on small matrices and small vectors, particularly for matrices of size 3x3, 4x4, 5x5, 6x6, and for vectors of length 3, 4, 5, 6.

For the simple C code you test, the Compiler can easily vectorize the code, and get good performance.

Thanks,
Chao

snirgaz
Beginner
58 Views

Hi,

Thanks for the reply.
The vector size is DIM=3 the variable SIZE sets the number of vectors in the vector array.
So that this setting should be adequate for IPP MX
Snir
snirgaz
Beginner
58 Views

Any Thoughts?

I think that the setting fits the IPP MX target

Thanks

Snir
Chao_Y_Intel
Employee
58 Views

Snir,

In your code, the following inner loops take most the time. It just sub a constant temp_b from temp_a vector. For such simple code, the compiler could generated well optimized code, and achieve good performance.

for (i=0;i

aLoop[i+VEC_SIZE*d]=temp_a[i+VEC_SIZE*d]-temp_b;

}

Actually good replacement for such code is use the following IPP function call:

ippsSubC_64f(...).

Thanks,
Chao

Reply