[v1.00] Fix freq measurement for AVX512

This commit is contained in:
Dr-Noob
2021-11-20 10:11:22 +01:00
parent 617fd2a520
commit 2fce2c9f52

View File

@@ -10,19 +10,37 @@
#include <stdint.h>
#include "freq.h"
/*
* For AVX512, it seems that multiple independent
* instructions are needed to force the CPU to
* use AVX512 frequency, since with only one instruction
* (as the AVX implementaion) it still uses AVX frequency
*/
void* compute_avx512() {
bool end = false;
struct timeval begin, now;
__m512 a = _mm512_set1_ps(1.5);
__m512 b = _mm512_set1_ps(1.2);
__m512 c = _mm512_set1_ps(0.0);
__m512 a[8];
__m512 b[8];
__m512 mult;
for(int i=0; i < 8; i++) {
a[i] = _mm512_set1_ps(1.5);
b[i] = _mm512_set1_ps(1.2);
}
gettimeofday(&begin, NULL);
while(!end) {
for(uint64_t i=0; i < LOOP_ITERS; i++) {
c = _mm512_fmadd_ps(a, b, c);
a[0] = _mm512_fmadd_ps(mult, a[0], b[0]);
a[1] = _mm512_fmadd_ps(mult, a[1], b[1]);
a[2] = _mm512_fmadd_ps(mult, a[2], b[2]);
a[3] = _mm512_fmadd_ps(mult, a[3], b[3]);
a[4] = _mm512_fmadd_ps(mult, a[4], b[4]);
a[5] = _mm512_fmadd_ps(mult, a[5], b[5]);
a[6] = _mm512_fmadd_ps(mult, a[6], b[6]);
a[7] = _mm512_fmadd_ps(mult, a[7], b[7]);
}
gettimeofday(&now, NULL);
@@ -35,7 +53,8 @@ void* compute_avx512() {
printf("fopen: %s", strerror(errno));
}
else {
fprintf(fp, "%f", c[0]);
for(int i=0; i < 8; i++)
fprintf(fp, "%f", a[i][0]);
fclose(fp);
}