Hide or fix all build warnings (#1331)

* Changing C-strings to be const.

* Changed variable-length arrays to std::vector to avoid warnings. VLA is a compiler extension.

* Changed `#define` inside functions into `constexpr int` to preserve scoping and avoid macro redefinition warnings.

* Disabled warnings for modifying `CMAKE_CXX_FLAGS` caused by `check_symbol_exists`, which temporarily modifies the flag to do a compile check.

* Fixed VLA in rccl UT.
Этот коммит содержится в:
corey-derochie-amd
2024-11-04 09:46:42 -07:00
коммит произвёл GitHub
родитель 6178556853
Коммит 1c45962273
6 изменённых файлов: 78 добавлений и 35 удалений
+29 -26
Просмотреть файл
@@ -26,6 +26,7 @@ THE SOFTWARE.
#include <math.h>
#include <sys/time.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include "rome_models.h"
@@ -1746,17 +1747,17 @@ int checkAlltoallWidth(struct rcclRomeModel *romeTopo) {
}
ncclResult_t parseA2a8P(struct ncclTopoSystem* system, struct ncclTopoGraph* graph, const char *ringBase) {
#define NUMA_CPUS 2
#define NUMA_GPUS 4
#define NUMA_PERMUTE_COUNT 24
#define TOTAL_PERMUTE_COUNT (NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT)
constexpr int NUMA_CPUS = 2;
constexpr int NUMA_GPUS = 4;
constexpr int NUMA_PERMUTE_COUNT = 24;
constexpr int TOTAL_PERMUTE_COUNT = (NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT);
static char ringRemap[256];
int i;
int ngpus = system->nodes[GPU].count;
int ncpus = system->nodes[CPU].count;
int nnets = system->nodes[NET].count;
const int ngpus = system->nodes[GPU].count;
const int ncpus = system->nodes[CPU].count;
const int nnets = system->nodes[NET].count;
// number of GPUs and NICs on each numa node is used as first screening pattern
struct rcclRomeModel romeTopo;
@@ -1775,11 +1776,12 @@ ncclResult_t parseA2a8P(struct ncclTopoSystem* system, struct ncclTopoGraph* gra
int *all_gpu_permutations = (int *)malloc(TOTAL_PERMUTE_COUNT*NUMA_CPUS*NUMA_GPUS*sizeof(int));
struct timeval tvs, tve;
gettimeofday(&tvs, NULL);
std::vector<int> r(ngpus), g(ngpus);
for (i = 0; i < sizeof(romeTopoModels)/sizeof(romeTopoModels[0]); i++) {
if (romeTopo.nCpus != romeTopoModels[i].nCpus || romeTopo.nGpus != romeTopoModels[i].nGpus ||
romeTopo.nNics != romeTopoModels[i].nNics || romeTopo.nLinks != romeTopoModels[i].nLinks) continue;
if (strcmp(romeTopoModels[i].pattern, pattern)) continue;
int j, r[ngpus], g[ngpus];
int j;
int numa_gpu_permutations[NUMA_CPUS][NUMA_PERMUTE_COUNT][NUMA_GPUS];
if (isAlltoall != checkAlltoallWidth(romeTopoModels+i))
continue;
@@ -1798,12 +1800,12 @@ ncclResult_t parseA2a8P(struct ncclTopoSystem* system, struct ncclTopoGraph* gra
if (romeTopo.gpuNuma[k] != j) continue;
g[(2+cnt++)%ngpusPerNuma] = k;
}
std::sort(g, g+ngpusPerNuma);
std::sort(g.begin(), g.begin()+ngpusPerNuma);
do {
for (int n = 0; n < ngpusPerNuma; n++)
numa_gpu_permutations[j][npermute][n] = g[n];
npermute++;
} while (std::next_permutation(g, g+ngpusPerNuma));
} while (std::next_permutation(g.begin(), g.begin()+ngpusPerNuma));
if (npermute != NUMA_PERMUTE_COUNT) break;
}
if (j < ncpus) continue;
@@ -2108,17 +2110,17 @@ ncclResult_t parseRome4P2H(struct ncclTopoSystem* system, struct ncclTopoGraph*
}
ncclResult_t parse1H16P(struct ncclTopoSystem* system, struct ncclTopoGraph* graph) {
#define NUMA_CPUS 4
#define NUMA_GPUS 4
#define NUMA_PERMUTE_COUNT 24
#define TOTAL_PERMUTE_COUNT (NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT)
constexpr int NUMA_CPUS = 4;
constexpr int NUMA_GPUS = 4;
constexpr int NUMA_PERMUTE_COUNT = 24;
constexpr int TOTAL_PERMUTE_COUNT = (NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT*NUMA_PERMUTE_COUNT);
static char ringRemap[256];
int i;
int ngpus = system->nodes[GPU].count;
int ncpus = system->nodes[CPU].count;
int nnets = system->nodes[NET].count;
const int ngpus = system->nodes[GPU].count;
const int ncpus = system->nodes[CPU].count;
const int nnets = system->nodes[NET].count;
// only valid on Rome
int arch, vendor, model;
@@ -2139,11 +2141,12 @@ ncclResult_t parse1H16P(struct ncclTopoSystem* system, struct ncclTopoGraph* gra
int *all_gpu_permutations = (int *)malloc(TOTAL_PERMUTE_COUNT*NUMA_CPUS*NUMA_GPUS*sizeof(int));
struct timeval tvs, tve;
gettimeofday(&tvs, NULL);
std::vector<int> r(ngpus), g(ngpus);
for (i = 0; i < sizeof(romeTopoModels)/sizeof(romeTopoModels[0]); i++) {
if (romeTopo.nCpus != romeTopoModels[i].nCpus || romeTopo.nGpus != romeTopoModels[i].nGpus ||
romeTopo.nNics != romeTopoModels[i].nNics || romeTopo.nLinks != romeTopoModels[i].nLinks) continue;
if (strcmp(romeTopoModels[i].pattern, pattern)) continue;
int j, r[ngpus], g[ngpus];
int j;
int numa_gpu_permutations[NUMA_CPUS][NUMA_PERMUTE_COUNT][NUMA_GPUS];
// permute GPUs for each CPU NUMA nodes
for (j = 0; j < ncpus; j++) {
@@ -2160,12 +2163,12 @@ ncclResult_t parse1H16P(struct ncclTopoSystem* system, struct ncclTopoGraph* gra
if (romeTopo.gpuNuma[k] != j) continue;
g[(2+cnt++)%ngpusPerNuma] = k;
}
std::sort(g, g+ngpusPerNuma);
std::sort(g.begin(), g.begin()+ngpusPerNuma);
do {
for (int n = 0; n < ngpusPerNuma; n++)
numa_gpu_permutations[j][npermute][n] = g[n];
npermute++;
} while (std::next_permutation(g, g+ngpusPerNuma));
} while (std::next_permutation(g.begin(), g.begin()+ngpusPerNuma));
if (npermute != NUMA_PERMUTE_COUNT) break;
}
if (j < ncpus) continue;
@@ -2245,13 +2248,13 @@ ncclResult_t parse1H16P(struct ncclTopoSystem* system, struct ncclTopoGraph* gra
}
ncclResult_t parse4H4P(struct ncclTopoSystem* system, struct ncclTopoGraph* graph) {
#define NUM_HIVES 4
#define HIVE_GPUS 4
constexpr int NUM_HIVES = 4;
constexpr int HIVE_GPUS = 4;
static char ringRemap[256];
int ngpus = system->nodes[GPU].count;
int nnets = system->nodes[NET].count;
const int ngpus = system->nodes[GPU].count;
const int nnets = system->nodes[NET].count;
// only valid on Rome
int arch, vendor, model;
@@ -2267,7 +2270,7 @@ ncclResult_t parse4H4P(struct ncclTopoSystem* system, struct ncclTopoGraph* grap
// only match for system with 16 GPUs
if (ngpus != NUM_HIVES*HIVE_GPUS || nnets != NUM_HIVES*HIVE_GPUS) return ncclSuccess;
int g_hives[ngpus], n_hives[nnets];
std::vector<int> g_hives(ngpus), n_hives(nnets);
int ng_hives[NUM_HIVES];
// try to sort GPUs into hives
@@ -2338,6 +2341,6 @@ ncclResult_t parse4H4P(struct ncclTopoSystem* system, struct ncclTopoGraph* grap
system->type |= RCCL_TOPO_4P2H_ROME;
parseOptions(system, rome_model_68.options);
// create 4P4H based on reference and remapped ids
NCCLCHECK(parseGraph(rome_model_68.ringBase, system, graph, g_hives, n_hives, false));
NCCLCHECK(parseGraph(rome_model_68.ringBase, system, graph, g_hives.data(), n_hives.data(), false));
return ncclSuccess;
}