[v0.98][Refactoring] Unify the use of get_str_peak_performance

This commit is contained in:
Dr-Noob
2021-08-06 10:26:07 +02:00
parent 7e1dde3c71
commit 6953d8dda5
9 changed files with 73 additions and 83 deletions

View File

@@ -151,6 +151,28 @@ char* get_str_freq(struct frequency* freq) {
return string;
}
char* get_str_peak_performance(double flops, bool valid_flops) {
char* str;
if(!valid_flops) {
str = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
strncpy(str, STRING_UNKNOWN, strlen(STRING_UNKNOWN) + 1);
}
// 7 for digits (e.g, XXXX.XX), 7 for XFLOP/s
uint32_t max_size = 7+1+7+1;
str = ecalloc(max_size, sizeof(char));
if(flops >= (double)1000000000000.0)
snprintf(str, max_size, "%.2f TFLOP/s", flops/1000000000000);
else if(flops >= 1000000000.0)
snprintf(str, max_size, "%.2f GFLOP/s", flops/1000000000);
else
snprintf(str, max_size, "%.2f MFLOP/s", flops/1000000);
return str;
}
void init_topology_struct(struct topology* topo, struct cache* cach) {
topo->total_cores = 0;
topo->cach = cach;