From 6d4d8b621bc056b1300ff92594c1bc3b1e23f0bf Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Sat, 18 Dec 2021 10:01:42 +0100 Subject: [PATCH] [v0.11] Fix compilation error and ambiguity with CUDA and Intel backend when enabled at the same time due to functions with the same name --- src/common/gpu.cpp | 2 +- src/common/gpu.hpp | 2 +- src/cuda/cuda.cpp | 8 ++++---- src/cuda/pci.cpp | 2 +- src/cuda/pci.hpp | 3 +-- src/cuda/uarch.cpp | 9 ++++----- src/intel/intel.cpp | 4 ++-- src/intel/pci.cpp | 2 +- src/intel/pci.hpp | 3 +-- src/intel/uarch.cpp | 9 +++++---- 10 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/common/gpu.cpp b/src/common/gpu.cpp index 512ad85..c25e1fa 100644 --- a/src/common/gpu.cpp +++ b/src/common/gpu.cpp @@ -143,7 +143,7 @@ char* get_str_peak_performance(struct gpu_info* gpu) { } char* get_str_peak_performance_tensor(struct gpu_info* gpu) { - return get_str_peak_performance_generic(gpu->peak_performance_t); + return get_str_peak_performance_generic(gpu->peak_performance_tcu); } char* get_str_generic(int32_t data) { diff --git a/src/common/gpu.hpp b/src/common/gpu.hpp index 60fcbc8..8f308c3 100644 --- a/src/common/gpu.hpp +++ b/src/common/gpu.hpp @@ -69,7 +69,7 @@ struct gpu_info { struct memory* mem; struct cache* cach; int64_t peak_performance; - int64_t peak_performance_t; + int64_t peak_performance_tcu; int32_t idx; }; diff --git a/src/cuda/cuda.cpp b/src/cuda/cuda.cpp index 1a70c59..fa6811d 100644 --- a/src/cuda/cuda.cpp +++ b/src/cuda/cuda.cpp @@ -76,12 +76,12 @@ struct memory* get_memory_info(struct gpu_info* gpu, cudaDeviceProp prop) { } // Compute peak performance when using CUDA cores -int64_t get_peak_performance(struct gpu_info* gpu) { +int64_t get_peak_performance_cuda(struct gpu_info* gpu) { return gpu->freq * 1000000 * gpu->topo->cuda_cores * 2; } // Compute peak performance when using tensor cores -int64_t get_peak_performance_t(struct gpu_info* gpu) { +int64_t get_peak_performance_tcu(struct gpu_info* gpu) { return gpu->freq * 1000000 * 4 * 4 * 8 * gpu->topo->tensor_cores; } @@ -138,8 +138,8 @@ struct gpu_info* get_gpu_info_cuda(int gpu_idx) { gpu->cach = get_cache_info(deviceProp); gpu->mem = get_memory_info(gpu, deviceProp); gpu->topo = get_topology_info(deviceProp); - gpu->peak_performance = get_peak_performance(gpu); - gpu->peak_performance_t = get_peak_performance_t(gpu); + gpu->peak_performance = get_peak_performance_cuda(gpu); + gpu->peak_performance_tcu = get_peak_performance_tcu(gpu); return gpu; } diff --git a/src/cuda/pci.cpp b/src/cuda/pci.cpp index 6e0e8cc..146c636 100644 --- a/src/cuda/pci.cpp +++ b/src/cuda/pci.cpp @@ -19,7 +19,7 @@ * or in pci.ids itself) */ -GPUCHIP get_chip_from_pci(struct pci* pci) { +GPUCHIP get_chip_from_pci_cuda(struct pci* pci) { CHECK_PCI_START CHECK_PCI(pci, 0x25e5, CHIP_GA107BM) CHECK_PCI(pci, 0x25e2, CHIP_GA107BM) diff --git a/src/cuda/pci.hpp b/src/cuda/pci.hpp index b30edd3..4627c8f 100644 --- a/src/cuda/pci.hpp +++ b/src/cuda/pci.hpp @@ -14,7 +14,6 @@ struct pci; -struct pci* get_pci_from_pciutils(struct pci_dev *devices); -GPUCHIP get_chip_from_pci(struct pci* pci); +GPUCHIP get_chip_from_pci_cuda(struct pci* pci); #endif diff --git a/src/cuda/uarch.cpp b/src/cuda/uarch.cpp index 4d85e5d..ef2f86d 100644 --- a/src/cuda/uarch.cpp +++ b/src/cuda/uarch.cpp @@ -39,7 +39,7 @@ static const char *uarch_str[] = { #define CHECK_UARCH_START if (false) {} #define CHECK_UARCH(arch, chip_, str, uarch, process) \ else if (arch->chip == chip_) fill_uarch(arch, str, uarch, process); -#define CHECK_UARCH_END else { printBug("map_chip_to_uarch: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, 0); } +#define CHECK_UARCH_END else { printBug("map_chip_to_uarch_cuda: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, 0); } void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, uint32_t process) { arch->chip_str = (char *) emalloc(sizeof(char) * (strlen(str)+1)); @@ -54,7 +54,7 @@ void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, uint32_t proce * o CHIP_XXXGL: indicates a professional-class (Quadro/Tesla) chip * o CHIP_XXXM: indicates a mobile chip */ -void map_chip_to_uarch(struct uarch* arch) { +void map_chip_to_uarch_cuda(struct uarch* arch) { CHECK_UARCH_START // TESLA (1.0, 1.1, 1.2, 1.3) // CHECK_UARCH(arch, CHIP_G80, "G80", UARCH_TESLA, 90) @@ -243,9 +243,8 @@ struct uarch* get_uarch_from_cuda(struct gpu_info* gpu) { arch->cc_major = deviceProp.major; arch->cc_minor = deviceProp.minor; arch->compute_capability = deviceProp.major * 10 + deviceProp.minor; - arch->chip = get_chip_from_pci(gpu->pci); - - map_chip_to_uarch(arch); + arch->chip = get_chip_from_pci_cuda(gpu->pci); + map_chip_to_uarch_cuda(arch); return arch; } diff --git a/src/intel/intel.cpp b/src/intel/intel.cpp index 96a83fd..09a6a7b 100644 --- a/src/intel/intel.cpp +++ b/src/intel/intel.cpp @@ -8,7 +8,7 @@ #include "../common/pci.hpp" #include "../common/global.hpp" -int64_t get_peak_performance(struct gpu_info* gpu) { +int64_t get_peak_performance_intel(struct gpu_info* gpu) { return gpu->freq * 1000000 * gpu->topo_i->eu_subslice * gpu->topo_i->subslices * 8 * 2; } @@ -22,7 +22,7 @@ struct gpu_info* get_gpu_info_intel() { gpu->name = get_name_from_uarch(gpu->arch); gpu->topo_i = get_topology_info(gpu->arch); gpu->freq = get_max_freq_from_file(gpu->pci); - gpu->peak_performance = get_peak_performance(gpu); + gpu->peak_performance = get_peak_performance_intel(gpu); return gpu; } diff --git a/src/intel/pci.cpp b/src/intel/pci.cpp index cfb77a9..024c2ab 100644 --- a/src/intel/pci.cpp +++ b/src/intel/pci.cpp @@ -13,7 +13,7 @@ /* * https://github.com/mesa3d/mesa/blob/main/include/pci_ids/i965_pci_ids.h */ -GPUCHIP get_chip_from_pci(struct pci* pci) { +GPUCHIP get_chip_from_pci_intel(struct pci* pci) { CHECK_PCI_START // Gen6 CHECK_PCI(pci, 0x0102, CHIP_HD_2000) diff --git a/src/intel/pci.hpp b/src/intel/pci.hpp index d9401a8..9966a04 100644 --- a/src/intel/pci.hpp +++ b/src/intel/pci.hpp @@ -14,7 +14,6 @@ struct pci; -struct pci* get_pci_from_pciutils(struct pci_dev *devices); -GPUCHIP get_chip_from_pci(struct pci* pci); +GPUCHIP get_chip_from_pci_intel(struct pci* pci); #endif diff --git a/src/intel/uarch.cpp b/src/intel/uarch.cpp index 9ffe9b7..8b5f30a 100644 --- a/src/intel/uarch.cpp +++ b/src/intel/uarch.cpp @@ -7,6 +7,7 @@ #include "../common/global.hpp" #include "../common/gpu.hpp" #include "chips.hpp" +#include "pci.hpp" // Data not available #define NA -1 @@ -68,7 +69,7 @@ static const char *gt_str[] = { #define CHECK_UARCH_START if (false) {} #define CHECK_UARCH(arch, chip_, str, uarch, gt, process) \ else if (arch->chip == chip_) fill_uarch(arch, str, uarch, gt, process); -#define CHECK_UARCH_END else { printBug("map_chip_to_uarch: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, GT_UNKNOWN, 0); } +#define CHECK_UARCH_END else { printBug("map_chip_to_uarch_intel: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, GT_UNKNOWN, 0); } #define CHECK_TOPO_START if (false) {} #define CHECK_TOPO(topo, arch, uarch_, gt_, eu_sub, sub, sli) \ @@ -89,7 +90,7 @@ void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, int32_t gt, ui arch->gt = gt; } -void map_chip_to_uarch(struct uarch* arch) { +void map_chip_to_uarch_intel(struct uarch* arch) { CHECK_UARCH_START // Gen6 CHECK_UARCH(arch, CHIP_HD_2000, "HD Graphics 2000", UARCH_GEN6, GT1, 32) @@ -147,8 +148,8 @@ struct uarch* get_uarch_from_pci(struct pci* pci) { struct uarch* arch = (struct uarch*) emalloc(sizeof(struct uarch)); arch->chip_str = NULL; - arch->chip = get_chip_from_pci(pci); - map_chip_to_uarch(arch); + arch->chip = get_chip_from_pci_intel(pci); + map_chip_to_uarch_intel(arch); return arch; }