[v0.01] Retrieve more info; frequency, topology and peak performance

This commit is contained in:
Dr-Noob
2021-08-13 16:36:10 +02:00
parent 59f723ff12
commit 981daef728
6 changed files with 71 additions and 20 deletions

View File

@@ -1,12 +1,37 @@
#include "gpu.hpp"
#include <cstddef>
#include <cstring>
#include <cstdio>
#include <cassert>
#include "../common/global.hpp"
#include "gpu.hpp"
#define STRING_YES "Yes"
#define STRING_NO "No"
#define STRING_NONE "None"
#define STRING_MEGAHERZ "MHz"
#define STRING_GIGAHERZ "GHz"
#define STRING_KILOBYTES "KB"
#define STRING_MEGABYTES "MB"
char* get_str_gpu_name(struct gpu_info* gpu) {
return gpu->name;
}
char* get_str_freq(struct gpu_info* gpu) {
return NULL;
// Max 5 digits and 3 for '(M/G)Hz'
uint32_t size = (5+1+3+1);
assert(strlen(STRING_UNKNOWN)+1 <= size);
char* string = (char *) ecalloc(size, sizeof(char));
if(gpu->freq == UNKNOWN_FREQ || gpu->freq < 0)
snprintf(string,strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
else if(gpu->freq >= 1000)
snprintf(string,size,"%.3f "STRING_GIGAHERZ, (float)(gpu->freq)/1000);
else
snprintf(string,size,"%.3f "STRING_MEGAHERZ, (float)gpu->freq);
return string;
}
char* get_str_memory_size(struct gpu_info* gpu) {
@@ -26,5 +51,25 @@ char* get_str_l2(struct gpu_info* gpu) {
}
char* get_str_peak_performance(struct gpu_info* gpu) {
return NULL;
char* str;
if(gpu->peak_performance == -1) {
str = (char *) emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
strncpy(str, STRING_UNKNOWN, strlen(STRING_UNKNOWN) + 1);
return str;
}
// 7 for digits (e.g, XXXX.XX), 7 for XFLOP/s
double flopsd = (double) gpu->peak_performance;
uint32_t max_size = 7+1+7+1;
str = (char *) ecalloc(max_size, sizeof(char));
if(flopsd >= (double)1000000000000.0)
snprintf(str, max_size, "%.2f TFLOP/s", flopsd/1000000000000);
else if(flopsd >= 1000000000.0)
snprintf(str, max_size, "%.2f GFLOP/s", flopsd/1000000000);
else
snprintf(str, max_size, "%.2f MFLOP/s", flopsd/1000000);
return str;
}

View File

@@ -7,6 +7,8 @@
#include "../cuda/nvmlb.hpp"
#include "../cuda/pci.hpp"
#define UNKNOWN_FREQ -1
enum {
GPU_VENDOR_NVIDIA
};

View File

@@ -59,9 +59,9 @@ int main(int argc, char* argv[]) {
printf("Compute Capability: %s\n", get_str_cc(gpu->arch));
printf("Technology: %s\n", get_str_process(gpu->arch));
printf("Max Frequency: %s\n", get_str_freq(gpu));
printf("SM: %s\n", get_str_sm(gpu));
printf("Cores/MP: %s\n", get_str_cores_sm(gpu));
printf("CUDA cores: %s\n", get_str_cuda_cores(gpu));
printf("SM: %d\n", get_str_sm(gpu));
printf("Cores/MP: %d\n", get_str_cores_sm(gpu));
printf("CUDA cores: %d\n", get_str_cuda_cores(gpu));
printf("Memory size: %s\n", get_str_memory_size(gpu));
printf("Memory type: %s\n", get_str_memory_type(gpu));
printf("L1 size: %s\n", get_str_l1(gpu));