[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

This commit is contained in:
Dr-Noob
2021-12-18 10:01:42 +01:00
parent 93889b2b18
commit 6d4d8b621b
10 changed files with 21 additions and 23 deletions

View File

@@ -143,7 +143,7 @@ char* get_str_peak_performance(struct gpu_info* gpu) {
} }
char* get_str_peak_performance_tensor(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) { char* get_str_generic(int32_t data) {

View File

@@ -69,7 +69,7 @@ struct gpu_info {
struct memory* mem; struct memory* mem;
struct cache* cach; struct cache* cach;
int64_t peak_performance; int64_t peak_performance;
int64_t peak_performance_t; int64_t peak_performance_tcu;
int32_t idx; int32_t idx;
}; };

View File

@@ -76,12 +76,12 @@ struct memory* get_memory_info(struct gpu_info* gpu, cudaDeviceProp prop) {
} }
// Compute peak performance when using CUDA cores // 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; return gpu->freq * 1000000 * gpu->topo->cuda_cores * 2;
} }
// Compute peak performance when using tensor cores // 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; 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->cach = get_cache_info(deviceProp);
gpu->mem = get_memory_info(gpu, deviceProp); gpu->mem = get_memory_info(gpu, deviceProp);
gpu->topo = get_topology_info(deviceProp); gpu->topo = get_topology_info(deviceProp);
gpu->peak_performance = get_peak_performance(gpu); gpu->peak_performance = get_peak_performance_cuda(gpu);
gpu->peak_performance_t = get_peak_performance_t(gpu); gpu->peak_performance_tcu = get_peak_performance_tcu(gpu);
return gpu; return gpu;
} }

View File

@@ -19,7 +19,7 @@
* or in pci.ids itself) * 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_START
CHECK_PCI(pci, 0x25e5, CHIP_GA107BM) CHECK_PCI(pci, 0x25e5, CHIP_GA107BM)
CHECK_PCI(pci, 0x25e2, CHIP_GA107BM) CHECK_PCI(pci, 0x25e2, CHIP_GA107BM)

View File

@@ -14,7 +14,6 @@
struct pci; struct pci;
struct pci* get_pci_from_pciutils(struct pci_dev *devices); GPUCHIP get_chip_from_pci_cuda(struct pci* pci);
GPUCHIP get_chip_from_pci(struct pci* pci);
#endif #endif

View File

@@ -39,7 +39,7 @@ static const char *uarch_str[] = {
#define CHECK_UARCH_START if (false) {} #define CHECK_UARCH_START if (false) {}
#define CHECK_UARCH(arch, chip_, str, uarch, process) \ #define CHECK_UARCH(arch, chip_, str, uarch, process) \
else if (arch->chip == chip_) fill_uarch(arch, 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) { void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, uint32_t process) {
arch->chip_str = (char *) emalloc(sizeof(char) * (strlen(str)+1)); 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_XXXGL: indicates a professional-class (Quadro/Tesla) chip
* o CHIP_XXXM: indicates a mobile 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 CHECK_UARCH_START
// TESLA (1.0, 1.1, 1.2, 1.3) // // TESLA (1.0, 1.1, 1.2, 1.3) //
CHECK_UARCH(arch, CHIP_G80, "G80", UARCH_TESLA, 90) 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_major = deviceProp.major;
arch->cc_minor = deviceProp.minor; arch->cc_minor = deviceProp.minor;
arch->compute_capability = deviceProp.major * 10 + deviceProp.minor; arch->compute_capability = deviceProp.major * 10 + deviceProp.minor;
arch->chip = get_chip_from_pci(gpu->pci); arch->chip = get_chip_from_pci_cuda(gpu->pci);
map_chip_to_uarch_cuda(arch);
map_chip_to_uarch(arch);
return arch; return arch;
} }

View File

@@ -8,7 +8,7 @@
#include "../common/pci.hpp" #include "../common/pci.hpp"
#include "../common/global.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; 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->name = get_name_from_uarch(gpu->arch);
gpu->topo_i = get_topology_info(gpu->arch); gpu->topo_i = get_topology_info(gpu->arch);
gpu->freq = get_max_freq_from_file(gpu->pci); 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; return gpu;
} }

View File

@@ -13,7 +13,7 @@
/* /*
* https://github.com/mesa3d/mesa/blob/main/include/pci_ids/i965_pci_ids.h * 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 CHECK_PCI_START
// Gen6 // Gen6
CHECK_PCI(pci, 0x0102, CHIP_HD_2000) CHECK_PCI(pci, 0x0102, CHIP_HD_2000)

View File

@@ -14,7 +14,6 @@
struct pci; struct pci;
struct pci* get_pci_from_pciutils(struct pci_dev *devices); GPUCHIP get_chip_from_pci_intel(struct pci* pci);
GPUCHIP get_chip_from_pci(struct pci* pci);
#endif #endif

View File

@@ -7,6 +7,7 @@
#include "../common/global.hpp" #include "../common/global.hpp"
#include "../common/gpu.hpp" #include "../common/gpu.hpp"
#include "chips.hpp" #include "chips.hpp"
#include "pci.hpp"
// Data not available // Data not available
#define NA -1 #define NA -1
@@ -68,7 +69,7 @@ static const char *gt_str[] = {
#define CHECK_UARCH_START if (false) {} #define CHECK_UARCH_START if (false) {}
#define CHECK_UARCH(arch, chip_, str, uarch, gt, process) \ #define CHECK_UARCH(arch, chip_, str, uarch, gt, process) \
else if (arch->chip == chip_) fill_uarch(arch, 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_START if (false) {}
#define CHECK_TOPO(topo, arch, uarch_, gt_, eu_sub, sub, sli) \ #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; arch->gt = gt;
} }
void map_chip_to_uarch(struct uarch* arch) { void map_chip_to_uarch_intel(struct uarch* arch) {
CHECK_UARCH_START CHECK_UARCH_START
// Gen6 // Gen6
CHECK_UARCH(arch, CHIP_HD_2000, "HD Graphics 2000", UARCH_GEN6, GT1, 32) 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)); struct uarch* arch = (struct uarch*) emalloc(sizeof(struct uarch));
arch->chip_str = NULL; arch->chip_str = NULL;
arch->chip = get_chip_from_pci(pci); arch->chip = get_chip_from_pci_intel(pci);
map_chip_to_uarch(arch); map_chip_to_uarch_intel(arch);
return arch; return arch;
} }