mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 07:50:40 +01:00
[v1.01] Remove useless frequency measurement (SSE and novector should report the same frequency!). Increase iterations to improve precision
This commit is contained in:
5
Makefile
5
Makefile
@@ -19,7 +19,7 @@ ifneq ($(OS),Windows_NT)
|
|||||||
|
|
||||||
os := $(shell uname -s)
|
os := $(shell uname -s)
|
||||||
ifeq ($(os), Linux)
|
ifeq ($(os), Linux)
|
||||||
SOURCE += $(SRC_DIR)freq/freq.c freq_nov.o freq_sse.o freq_avx.o freq_avx512.o
|
SOURCE += $(SRC_DIR)freq/freq.c freq_nov.o freq_avx.o freq_avx512.o
|
||||||
HEADERS += $(SRC_DIR)freq/freq.h
|
HEADERS += $(SRC_DIR)freq/freq.h
|
||||||
CFLAGS += -pthread
|
CFLAGS += -pthread
|
||||||
endif
|
endif
|
||||||
@@ -73,9 +73,6 @@ strict: $(OUTPUT)
|
|||||||
freq_nov.o: Makefile $(SRC_DIR)freq/freq_nov.c $(SRC_DIR)freq/freq_nov.h
|
freq_nov.o: Makefile $(SRC_DIR)freq/freq_nov.c $(SRC_DIR)freq/freq_nov.h
|
||||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -pthread $(SRC_DIR)freq/freq_nov.c -o $@
|
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -pthread $(SRC_DIR)freq/freq_nov.c -o $@
|
||||||
|
|
||||||
freq_sse.o: Makefile $(SRC_DIR)freq/freq_sse.c $(SRC_DIR)freq/freq_sse.h
|
|
||||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -msse -pthread $(SRC_DIR)freq/freq_sse.c -o $@
|
|
||||||
|
|
||||||
freq_avx.o: Makefile $(SRC_DIR)freq/freq_avx.c $(SRC_DIR)freq/freq_avx.h
|
freq_avx.o: Makefile $(SRC_DIR)freq/freq_avx.c $(SRC_DIR)freq/freq_avx.h
|
||||||
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -mavx -mfma -pthread $(SRC_DIR)freq/freq_avx.c -o $@
|
$(CC) $(CFLAGS) $(SANITY_FLAGS) -c -mavx -mfma -pthread $(SRC_DIR)freq/freq_avx.c -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
static const char* OS_STR = "Unknown OS";
|
static const char* OS_STR = "Unknown OS";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* VERSION = "1.00";
|
static const char* VERSION = "1.01";
|
||||||
|
|
||||||
void print_help(char *argv[]) {
|
void print_help(char *argv[]) {
|
||||||
const char **t = args_str;
|
const char **t = args_str;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "../uarch.h"
|
#include "../uarch.h"
|
||||||
#include "freq.h"
|
#include "freq.h"
|
||||||
#include "freq_nov.h"
|
#include "freq_nov.h"
|
||||||
#include "freq_sse.h"
|
|
||||||
#include "freq_avx.h"
|
#include "freq_avx.h"
|
||||||
#include "freq_avx512.h"
|
#include "freq_avx512.h"
|
||||||
|
|
||||||
@@ -102,11 +101,6 @@ int64_t measure_frequency(struct cpuInfo* cpu) {
|
|||||||
compute_function = compute_avx;
|
compute_function = compute_avx;
|
||||||
num_spaces = 42;
|
num_spaces = 42;
|
||||||
}
|
}
|
||||||
else if(cpu->feat->SSE) {
|
|
||||||
printf("cpufetch is measuring the SSE frequency...");
|
|
||||||
compute_function = compute_sse;
|
|
||||||
num_spaces = 42;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
printf("cpufetch is measuring the frequency (no vector instructions)...");
|
printf("cpufetch is measuring the frequency (no vector instructions)...");
|
||||||
compute_function = compute_nov;
|
compute_function = compute_nov;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "../../common/cpu.h"
|
#include "../../common/cpu.h"
|
||||||
|
|
||||||
#define MEASURE_TIME_SECONDS 5
|
#define MEASURE_TIME_SECONDS 5
|
||||||
#define LOOP_ITERS 100000000
|
#define LOOP_ITERS 1000000000
|
||||||
|
|
||||||
int64_t measure_frequency(struct cpuInfo* cpu);
|
int64_t measure_frequency(struct cpuInfo* cpu);
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#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() {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef __FREQ_SSE__
|
|
||||||
#define __FREQ_SSE__
|
|
||||||
|
|
||||||
void* compute_sse();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user