From 310486a6a24e42d7c631855d9028a3b25a645eb8 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 26 Nov 2021 09:33:57 +0100 Subject: [PATCH] [v0.11] Fixes to recover CUDA functionality, ready for implementing Intel iGPU code --- src/common/main.cpp | 4 ++-- src/common/master.cpp | 4 ++-- src/cuda/cuda.cpp | 55 +++++++++++-------------------------------- src/intel/intel.cpp | 3 ++- 4 files changed, 20 insertions(+), 46 deletions(-) diff --git a/src/common/main.cpp b/src/common/main.cpp index 1f0478c..2e51d86 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -73,10 +73,10 @@ int main(int argc, char* argv[]) { set_log_level(true); - printWarn("gpufetch is in beta. The provided information may be incomplete or wrong.\n\ + printf("[WARNING]: 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"); +any inconsistencies to https://github.com/Dr-Noob/gpufetch/issues\n"); struct gpu_info* gpu = get_gpu_info(list, get_gpu_idx()); if(gpu == NULL) diff --git a/src/common/master.cpp b/src/common/master.cpp index ae45d45..8dbc9ba 100644 --- a/src/common/master.cpp +++ b/src/common/master.cpp @@ -42,12 +42,12 @@ bool print_gpus_list(struct gpu_list* list) { for(int i=0; i < list->num_gpus; i++) { printf("GPU %d: ", i); if(list->gpus[i]->vendor == GPU_VENDOR_NVIDIA) { - #ifdef ENABLE_CUDA_BACKEND + #ifdef BACKEND_CUDA print_gpu_cuda(list->gpus[i]); #endif } else if(list->gpus[i]->vendor == GPU_VENDOR_INTEL) { - #ifdef ENABLE_INTEL_BACKEND + #ifdef BACKEND_INTEL print_gpu_intel(list->gpus[i]); #endif } diff --git a/src/cuda/cuda.cpp b/src/cuda/cuda.cpp index 03c295b..d542936 100644 --- a/src/cuda/cuda.cpp +++ b/src/cuda/cuda.cpp @@ -6,44 +6,12 @@ #include "../common/pci.hpp" #include "../common/global.hpp" -int print_gpus_list_deprecated() { - cudaError_t err = cudaSuccess; - int num_gpus = -1; - - if ((err = cudaGetDeviceCount(&num_gpus)) != cudaSuccess) { - printErr("%s: %s", cudaGetErrorName(err), cudaGetErrorString(err)); - return EXIT_FAILURE; - } - printf("CUDA GPUs available: %d\n", num_gpus); - - if(num_gpus > 0) { - cudaDeviceProp deviceProp; - int max_len = 0; - - for(int idx=0; idx < num_gpus; idx++) { - if ((err = cudaGetDeviceProperties(&deviceProp, idx)) != cudaSuccess) { - printErr("%s: %s", cudaGetErrorName(err), cudaGetErrorString(err)); - return EXIT_FAILURE; - } - max_len = max(max_len, (int) strlen(deviceProp.name)); - } - - for(int i=0; i < max_len + 32; i++) putchar('-'); - putchar('\n'); - for(int idx=0; idx < num_gpus; idx++) { - if ((err = cudaGetDeviceProperties(&deviceProp, idx)) != cudaSuccess) { - printErr("%s: %s", cudaGetErrorName(err), cudaGetErrorString(err)); - return EXIT_FAILURE; - } - printf("GPU %d: %s (Compute Capability %d.%d)\n", idx, deviceProp.name, deviceProp.major, deviceProp.minor); - } - } - - return EXIT_SUCCESS; -} - bool print_gpu_cuda(struct gpu_info* gpu) { - return false; + char* cc = get_str_cc(gpu->arch); + printf("%s (Compute Capability %s)\n", gpu->name, cc); + free(cc); + + return true; } struct cache* get_cache_info(cudaDeviceProp prop) { @@ -127,8 +95,10 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) { return NULL; } - printf("Waiting for CUDA driver to start..."); - fflush(stdout); + if(gpu_idx == 0) { + printf("Waiting for CUDA driver to start..."); + fflush(stdout); + } int num_gpus = -1; cudaError_t err = cudaSuccess; @@ -136,7 +106,10 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) { printErr("%s: %s", cudaGetErrorName(err), cudaGetErrorString(err)); return NULL; } - printf("\r "); + + if(gpu_idx == 0) { + printf("\r"); + } if(num_gpus <= 0) { printErr("No CUDA capable devices found!"); @@ -144,7 +117,7 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) { } if(gpu->idx+1 > num_gpus) { - printErr("Requested GPU index %d in a system with %d GPUs", gpu->idx, num_gpus); + // Master is trying to query an invalid GPU return NULL; } diff --git a/src/intel/intel.cpp b/src/intel/intel.cpp index dd51c6f..44680a4 100644 --- a/src/intel/intel.cpp +++ b/src/intel/intel.cpp @@ -7,6 +7,7 @@ struct gpu_info* get_gpu_info_intel() { struct gpu_info* gpu = (struct gpu_info*) emalloc(sizeof(struct gpu_info)); + gpu->vendor = GPU_VENDOR_INTEL; return gpu; } @@ -14,7 +15,7 @@ struct gpu_info* get_gpu_info_intel() { bool print_gpu_intel(struct gpu_info* gpu) { if(gpu->vendor != GPU_VENDOR_INTEL) return false; - printf("%s\n", gpu->name); + printf("Intel ???\n"); return true; }