From 9d2a07146a48d0c8bbe34e670994c169fee202d7 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Tue, 28 Dec 2021 15:56:44 +0100 Subject: [PATCH] [v0.21] Check that topology is valid in Intel backend. Print informative message if no valid topology is found --- src/common/gpu.cpp | 14 +++++++++++--- src/intel/intel.cpp | 3 +++ src/intel/uarch.cpp | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/gpu.cpp b/src/common/gpu.cpp index 47ac4f4..051f7d1 100644 --- a/src/common/gpu.cpp +++ b/src/common/gpu.cpp @@ -147,9 +147,17 @@ char* get_str_peak_performance_tensor(struct gpu_info* gpu) { } char* get_str_generic(int32_t data) { + char* str; + + if(data < 0) { + str = (char *) emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1)); + strncpy(str, STRING_UNKNOWN, strlen(STRING_UNKNOWN) + 1); + return str; + } + // Largest int is 10, +1 for possible negative, +1 for EOL uint32_t max_size = 12; - char* dummy = (char *) ecalloc(max_size, sizeof(char)); - snprintf(dummy, max_size, "%d", data); - return dummy; + str = (char *) ecalloc(max_size, sizeof(char)); + snprintf(str, max_size, "%d", data); + return str; } diff --git a/src/intel/intel.cpp b/src/intel/intel.cpp index 8a55016..08a77eb 100644 --- a/src/intel/intel.cpp +++ b/src/intel/intel.cpp @@ -9,6 +9,7 @@ #include "../common/global.hpp" int64_t get_peak_performance_intel(struct gpu_info* gpu) { + if(gpu->topo_i->eu_subslice < 0 || gpu->topo_i->subslices < 0) return -1; return gpu->freq * 1000000 * gpu->topo_i->eu_subslice * gpu->topo_i->subslices * 8 * 2; } @@ -48,5 +49,7 @@ bool print_gpu_intel(struct gpu_info* gpu) { } char* get_str_eu(struct gpu_info* gpu) { + if(gpu->topo_i->subslices < 0 || gpu->topo_i->eu_subslice < 0) + return get_str_generic(-1); return get_str_generic(gpu->topo_i->subslices * gpu->topo_i->eu_subslice); } diff --git a/src/intel/uarch.cpp b/src/intel/uarch.cpp index 96b6191..e76d3bb 100644 --- a/src/intel/uarch.cpp +++ b/src/intel/uarch.cpp @@ -75,7 +75,7 @@ static const char *gt_str[] = { #define CHECK_TOPO_START if (false) {} #define CHECK_TOPO(topo, arch, uarch_, gt_, eu_sub, sub, sli) \ else if(arch->uarch == uarch_ && arch->gt == gt_) fill_topo(topo, eu_sub, sub, sli); -#define CHECK_TOPO_END else { printBug("TODOO"); fill_topo(topo, -1, -1, -1); } +#define CHECK_TOPO_END else { printBug("get_topology_info: Invalid uarch and gt combination: '%s' and '%s'", arch->chip_str, get_str_gt(arch)); fill_topo(topo, UNK, UNK, UNK); } void fill_topo(struct topology_i* topo_i, int32_t eu_sub, int32_t sub, int32_t sli) { topo_i->slices = sli;