[v0.02] Add warning message. Hide the waiting message when CUDA initialization is done. Fix compiler warnings

This commit is contained in:
Dr-Noob
2021-08-15 21:56:51 +02:00
parent 2687fa5016
commit 8386052b10
4 changed files with 23 additions and 12 deletions

View File

@@ -33,11 +33,11 @@ int32_t get_value_as_smallest_unit(char ** str, uint64_t value) {
*str = (char *) emalloc(sizeof(char)* (max_len + 1)); *str = (char *) emalloc(sizeof(char)* (max_len + 1));
if(value/1024 >= (1 << 20)) if(value/1024 >= (1 << 20))
ret = snprintf(*str, max_len, "%.4g"STRING_GIGABYTES, (double)value/(1<<30)); ret = snprintf(*str, max_len, "%.4g" STRING_GIGABYTES, (double)value/(1<<30));
else if(value/1024 >= (1 << 10)) else if(value/1024 >= (1 << 10))
ret = snprintf(*str, max_len, "%.4g"STRING_MEGABYTES, (double)value/(1<<20)); ret = snprintf(*str, max_len, "%.4g" STRING_MEGABYTES, (double)value/(1<<20));
else else
ret = snprintf(*str, max_len, "%.4g"STRING_KILOBYTES, (double)value/(1<<10)); ret = snprintf(*str, max_len, "%.4g" STRING_KILOBYTES, (double)value/(1<<10));
return ret; return ret;
} }
@@ -55,9 +55,9 @@ char* get_str_freq(struct gpu_info* gpu) {
if(gpu->freq == UNKNOWN_FREQ || gpu->freq < 0) if(gpu->freq == UNKNOWN_FREQ || gpu->freq < 0)
snprintf(string,strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN); snprintf(string,strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
else if(gpu->freq >= 1000) else if(gpu->freq >= 1000)
snprintf(string,size,"%.3f "STRING_GIGAHERZ, (float)(gpu->freq)/1000); snprintf(string,size,"%.3f " STRING_GIGAHERZ, (float)(gpu->freq)/1000);
else else
snprintf(string,size,"%.3f "STRING_MEGAHERZ, (float)gpu->freq); snprintf(string,size,"%.3f " STRING_MEGAHERZ, (float)gpu->freq);
return string; return string;
} }
@@ -100,7 +100,7 @@ char* get_str_memory_clock(struct gpu_info* gpu) {
if(gpu->mem->freq == UNKNOWN_FREQ || gpu->mem->freq < 0) if(gpu->mem->freq == UNKNOWN_FREQ || gpu->mem->freq < 0)
snprintf(string,strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN); snprintf(string,strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
else else
snprintf(string,size,"%d "STRING_MEGAHERZ, gpu->mem->freq); snprintf(string,size,"%d " STRING_MEGAHERZ, gpu->mem->freq);
return string; return string;
} }

View File

@@ -49,6 +49,13 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
set_log_level(true);
printWarn("gpufetch is in beta. The provided information may be incomplete or wrong.\n\
If you want to help to improve gpufetch, please compare the output of the program\n\
with a reliable source which you know is right (e.g, techpowerup.com) and report\n\
any inconsistencies to https://github.com/Dr-Noob/gpufetch/issues");
struct gpu_info* gpu = get_gpu_info(); struct gpu_info* gpu = get_gpu_info();
if(gpu == NULL) if(gpu == NULL)
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@@ -6,7 +6,7 @@
#include "uarch.hpp" #include "uarch.hpp"
#include "../common/global.hpp" #include "../common/global.hpp"
struct cache* get_cache_info(struct gpu_info* gpu, cudaDeviceProp prop) { struct cache* get_cache_info(cudaDeviceProp prop) {
struct cache* cach = (struct cache*) emalloc(sizeof(struct cache)); struct cache* cach = (struct cache*) emalloc(sizeof(struct cache));
cach->L2 = (struct cach*) emalloc(sizeof(struct cach)); cach->L2 = (struct cach*) emalloc(sizeof(struct cach));
@@ -17,7 +17,7 @@ struct cache* get_cache_info(struct gpu_info* gpu, cudaDeviceProp prop) {
return cach; return cach;
} }
struct topology* get_topology_info(struct gpu_info* gpu, cudaDeviceProp prop) { struct topology* get_topology_info(cudaDeviceProp prop) {
struct topology* topo = (struct topology*) emalloc(sizeof(struct topology)); struct topology* topo = (struct topology*) emalloc(sizeof(struct topology));
topo->streaming_mp = prop.multiProcessorCount; topo->streaming_mp = prop.multiProcessorCount;
@@ -63,11 +63,13 @@ struct gpu_info* get_gpu_info() {
struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info)); struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info));
gpu->pci = NULL; gpu->pci = NULL;
printf("Waiting for CUDA driver to start...\n"); printf("Waiting for CUDA driver to start...");
fflush(stdout);
int dev = 0; int dev = 0;
cudaSetDevice(dev); cudaSetDevice(dev);
cudaDeviceProp deviceProp; cudaDeviceProp deviceProp;
cudaGetDeviceProperties(&deviceProp, dev); cudaGetDeviceProperties(&deviceProp, dev);
printf("\r");
gpu->freq = deviceProp.clockRate * 1e-3f; gpu->freq = deviceProp.clockRate * 1e-3f;
gpu->vendor = GPU_VENDOR_NVIDIA; gpu->vendor = GPU_VENDOR_NVIDIA;
@@ -80,9 +82,9 @@ struct gpu_info* get_gpu_info() {
} }
gpu->arch = get_uarch_from_cuda(gpu); gpu->arch = get_uarch_from_cuda(gpu);
gpu->cach = get_cache_info(gpu, deviceProp); gpu->cach = get_cache_info(deviceProp);
gpu->mem = get_memory_info(gpu, deviceProp); gpu->mem = get_memory_info(gpu, deviceProp);
gpu->topo = get_topology_info(gpu, deviceProp); gpu->topo = get_topology_info(deviceProp);
gpu->peak_performance = get_peak_performance(gpu); gpu->peak_performance = get_peak_performance(gpu);
return gpu; return gpu;

View File

@@ -355,5 +355,7 @@ char* get_str_chip(struct uarch* arch) {
} }
void free_uarch_struct(struct uarch* arch) { void free_uarch_struct(struct uarch* arch) {
free(arch->uarch_str);
free(arch->chip_str);
free(arch);
} }