[v1.01] Run multiple independent instructions in the pipeline for AVX freq too. Fixes incorrect frequency measures under certain CPUs

This commit is contained in:
Dr-Noob
2021-12-27 12:42:03 +01:00
parent a4e1a837a3
commit 874a856e34
4 changed files with 21 additions and 14 deletions

View File

@@ -15,13 +15,25 @@ void* compute_avx() {
struct timeval begin, now;
__m256 a = _mm256_set1_ps(1.5);
__m256 b = _mm256_set1_ps(1.2);
__m256 a[8];
__m256 b[8];
for(int i=0; i < 8; i++) {
a[i] = _mm256_set1_ps(1.5);
b[i] = _mm256_set1_ps(1.2);
}
gettimeofday(&begin, NULL);
while(!end) {
for(uint64_t i=0; i < LOOP_ITERS; i++) {
a = _mm256_add_ps(a, b);
a[0] = _mm256_add_ps(a[0], b[0]);
a[1] = _mm256_add_ps(a[1], b[1]);
a[2] = _mm256_add_ps(a[2], b[2]);
a[3] = _mm256_add_ps(a[3], b[3]);
a[4] = _mm256_add_ps(a[4], b[4]);
a[5] = _mm256_add_ps(a[5], b[5]);
a[6] = _mm256_add_ps(a[6], b[6]);
a[7] = _mm256_add_ps(a[7], b[7]);
}
gettimeofday(&now, NULL);
@@ -34,7 +46,8 @@ void* compute_avx() {
printf("fopen: %s", strerror(errno));
}
else {
fprintf(fp, "%f", a[0]);
for(int i=0; i < 8; i++)
fprintf(fp, "%f", a[i][0]);
fclose(fp);
}