mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-24 23:40:39 +01:00
[v1.00] Implemented all backends for --accurate-pp
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../../common/cpu.h"
|
#include "../../common/cpu.h"
|
||||||
|
|
||||||
|
#define MEASURE_TIME_SECONDS 5
|
||||||
|
#define LOOP_ITERS 100000000
|
||||||
|
|
||||||
int64_t measure_frequency(struct cpuInfo* cpu);
|
int64_t measure_frequency(struct cpuInfo* cpu);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "freq.h"
|
||||||
#define MEASURE_TIME_SECONDS 5
|
|
||||||
#define LOOP_ITERS 100000000
|
|
||||||
|
|
||||||
void* compute_avx() {
|
void* compute_avx() {
|
||||||
bool end = false;
|
bool end = false;
|
||||||
|
|||||||
@@ -1,5 +1,44 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <immintrin.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "freq.h"
|
||||||
|
|
||||||
void* compute_avx512() {
|
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);
|
||||||
|
|
||||||
|
gettimeofday(&begin, NULL);
|
||||||
|
while(!end) {
|
||||||
|
for(uint64_t i=0; i < LOOP_ITERS; i++) {
|
||||||
|
c = _mm512_fmadd_ps(a, b, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
double elapsed = (now.tv_sec - begin.tv_sec) + ((now.tv_usec - begin.tv_usec)/1000000.0);
|
||||||
|
end = elapsed >= (double) MEASURE_TIME_SECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = fopen("/dev/null", "w");
|
||||||
|
if(fp == NULL) {
|
||||||
|
printf("fopen: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(fp, "%f", c[0]);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,44 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <immintrin.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "freq.h"
|
||||||
|
|
||||||
void* compute_nov() {
|
void* compute_nov() {
|
||||||
|
bool end = false;
|
||||||
|
|
||||||
|
struct timeval begin, now;
|
||||||
|
|
||||||
|
float a = 1.5;
|
||||||
|
float b = 1.2;
|
||||||
|
float c = 0.0;
|
||||||
|
|
||||||
|
gettimeofday(&begin, NULL);
|
||||||
|
while(!end) {
|
||||||
|
for(uint64_t i=0; i < LOOP_ITERS; i++) {
|
||||||
|
c = a * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
double elapsed = (now.tv_sec - begin.tv_sec) + ((now.tv_usec - begin.tv_usec)/1000000.0);
|
||||||
|
end = elapsed >= (double) MEASURE_TIME_SECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = fopen("/dev/null", "w");
|
||||||
|
if(fp == NULL) {
|
||||||
|
printf("fopen: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(fp, "%f", c);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,44 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <immintrin.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "freq.h"
|
||||||
|
|
||||||
void* compute_sse() {
|
void* compute_sse() {
|
||||||
|
bool end = false;
|
||||||
|
|
||||||
|
struct timeval begin, now;
|
||||||
|
|
||||||
|
__m128 a = _mm_set1_ps(1.5);
|
||||||
|
__m128 b = _mm_set1_ps(1.2);
|
||||||
|
__m128 c = _mm_set1_ps(0.0);
|
||||||
|
|
||||||
|
gettimeofday(&begin, NULL);
|
||||||
|
while(!end) {
|
||||||
|
for(uint64_t i=0; i < LOOP_ITERS; i++) {
|
||||||
|
c = _mm_add_ps(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
double elapsed = (now.tv_sec - begin.tv_sec) + ((now.tv_usec - begin.tv_usec)/1000000.0);
|
||||||
|
end = elapsed >= (double) MEASURE_TIME_SECONDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = fopen("/dev/null", "w");
|
||||||
|
if(fp == NULL) {
|
||||||
|
printf("fopen: %s", strerror(errno));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(fp, "%f", c[0]);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user