DynamoRIO mixes Intel AVX and Intel SSE code
Created by: andrea-brunato-ARM
As mentioned on Intel optimization manual in "Mixing AVX code with SSE code" section:
If software inter-mixes AVX and SSE instructions without using VZEROUPPER properly, it can experience an AVX/SSE transition penalty
I have noticed that this causes a significant performance regression when running DynamoRIO on Intel Skylake (model 85)
For instance, taking into account an application which performs a simple for loop, compiled with -ftree-vectorize -O3
:
int N=10000;
__attribute__((noinline)) void vector_triad(const double* __restrict a, const double* __restrict b, double* __restrict c, double scale){
//__asm__("vzeroupper");
for(int i=0; i<N; i++){
c[i] = a[i] + scale * b[i];
}
return;
}
int main(int argc, char* argv[]){
double* a = new T[N];
double* b = new T[N];
double* c = new T[N];
for(int j=0; j<1000000; j++){
vector_triad(a,b,c,2.0);
}
return 0;
}
I can notice the following execution times:
time app --> 0m2.844s
time drrun -- app --> 0m14.376s
When instead running the same application adding the "vzeroupper" command (reported in the code as comment):
time drrun -- app --> 0m3.225s
Is there a fix that could be implemented inside DynamoRIO in order to prevent such slowdown?