[v0.11] Fixes to recover CUDA functionality, ready for implementing Intel iGPU code

This commit is contained in:
Dr-Noob
2021-11-26 09:33:57 +01:00
parent e5a4f91b20
commit 310486a6a2
4 changed files with 20 additions and 46 deletions

View File

@@ -73,10 +73,10 @@ int main(int argc, char* argv[]) {
set_log_level(true); 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\ 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\ 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()); struct gpu_info* gpu = get_gpu_info(list, get_gpu_idx());
if(gpu == NULL) if(gpu == NULL)

View File

@@ -42,12 +42,12 @@ bool print_gpus_list(struct gpu_list* list) {
for(int i=0; i < list->num_gpus; i++) { for(int i=0; i < list->num_gpus; i++) {
printf("GPU %d: ", i); printf("GPU %d: ", i);
if(list->gpus[i]->vendor == GPU_VENDOR_NVIDIA) { if(list->gpus[i]->vendor == GPU_VENDOR_NVIDIA) {
#ifdef ENABLE_CUDA_BACKEND #ifdef BACKEND_CUDA
print_gpu_cuda(list->gpus[i]); print_gpu_cuda(list->gpus[i]);
#endif #endif
} }
else if(list->gpus[i]->vendor == GPU_VENDOR_INTEL) { else if(list->gpus[i]->vendor == GPU_VENDOR_INTEL) {
#ifdef ENABLE_INTEL_BACKEND #ifdef BACKEND_INTEL
print_gpu_intel(list->gpus[i]); print_gpu_intel(list->gpus[i]);
#endif #endif
} }

View File

@@ -6,44 +6,12 @@
#include "../common/pci.hpp" #include "../common/pci.hpp"
#include "../common/global.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) { 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) { struct cache* get_cache_info(cudaDeviceProp prop) {
@@ -127,8 +95,10 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) {
return NULL; return NULL;
} }
if(gpu_idx == 0) {
printf("Waiting for CUDA driver to start..."); printf("Waiting for CUDA driver to start...");
fflush(stdout); fflush(stdout);
}
int num_gpus = -1; int num_gpus = -1;
cudaError_t err = cudaSuccess; 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)); printErr("%s: %s", cudaGetErrorName(err), cudaGetErrorString(err));
return NULL; return NULL;
} }
printf("\r ");
if(gpu_idx == 0) {
printf("\r");
}
if(num_gpus <= 0) { if(num_gpus <= 0) {
printErr("No CUDA capable devices found!"); 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) { 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; return NULL;
} }

View File

@@ -7,6 +7,7 @@
struct gpu_info* get_gpu_info_intel() { struct gpu_info* get_gpu_info_intel() {
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->vendor = GPU_VENDOR_INTEL;
return gpu; return gpu;
} }
@@ -14,7 +15,7 @@ struct gpu_info* get_gpu_info_intel() {
bool print_gpu_intel(struct gpu_info* gpu) { bool print_gpu_intel(struct gpu_info* gpu) {
if(gpu->vendor != GPU_VENDOR_INTEL) return false; if(gpu->vendor != GPU_VENDOR_INTEL) return false;
printf("%s\n", gpu->name); printf("Intel ???\n");
return true; return true;
} }