Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/client/EnvVars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class EnvVars
pingpongStride = GetEnvVar("PNP_STRIDE" , 1);
outputToCsv = GetEnvVar("OUTPUT_TO_CSV" , 0);
samplingFactor = GetEnvVar("SAMPLING_FACTOR" , 1);
if (samplingFactor < 1) {
printf("[ERROR] SAMPLING_FACTOR must be at least 1 (got %d)\n", samplingFactor);
exit(1);
}
showBorders = GetEnvVar("SHOW_BORDERS" , 1);
showIterations = GetEnvVar("SHOW_ITERATIONS" , 0);
showPercentiles = GetEnvVarArray("SHOW_PERCENTILES", {});
Expand Down Expand Up @@ -314,6 +318,13 @@ class EnvVars
}
cuMask.resize(2 * numXccs, 0);

for (auto range : ranges) {
// Mask holds 64 bits (2 dwords) per XCC, so per-XCC CU indices must be in 0..63
if (range.first < 0 || range.second > 63) {
printf("[ERROR] CU_MASK index out of range (allowed 0..63): %d-%d\n", range.first, range.second);
exit(1);
}
}
for (auto range : ranges) {
for (int i = range.first; i <= range.second; i++) {
for (int x = 0; x < numXccs; x++) {
Expand Down Expand Up @@ -547,7 +558,7 @@ class EnvVars
Print("IB_PORT_NUMBER", ibPort,
"IB port number is set to %d", ibPort);
Print("NIC_CHUNK_BYTES", nicChunkBytes,
"Sending %lu bytes at a time for NIC RDMA", nicChunkBytes);
"Sending %d bytes at a time for NIC RDMA", nicChunkBytes);
Print("NIC_CQ_POLL_BATCH", nicCqPollBatch,
"Polling %d CQ entries per ibv_poll_cq call", nicCqPollBatch);
Print("NIC_RELAX_ORDER", nicRelaxedOrder,
Expand Down Expand Up @@ -625,14 +636,20 @@ class EnvVars
if (varStr[0] == '\0') {
return defaultValue;
}
int val = atoi(varStr);
long long val = strtoll(varStr, NULL, 10);
long long mult = 1;
char units = varStr[strlen(varStr)-1];
switch (units) {
case 'G': case 'g': val *= 1024;
case 'M': case 'm': val *= 1024;
case 'K': case 'k': val *= 1024;
case 'G': case 'g': mult *= 1024;
case 'M': case 'm': mult *= 1024;
case 'K': case 'k': mult *= 1024;
}
// Reject values that do not fit in an int instead of silently overflowing
if (val > INT_MAX / mult || val < INT_MIN / mult) {
printf("[ERROR] %s value [%s] is out of range (must fit in a 32-bit signed int)\n", varname.c_str(), varStr);
exit(1);
}
return val;
return (int)(val * mult);
}
return defaultValue;
}
Expand Down
14 changes: 9 additions & 5 deletions src/header/TransferBench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,21 +1295,25 @@ const auto& AmdSmiFabricInfoV1(const T& info)
//========================================================================================
static ErrResult CharToMemType(char const c, MemType& memType)
{
char const* val = strchr(MemTypeStr, toupper(c));
// strchr also matches the terminating NUL, so reject a missing type character explicitly
char const* val = c ? strchr(MemTypeStr, toupper(c)) : NULL;
if (val) {
memType = (MemType)(val - MemTypeStr);
return ERR_NONE;
}
if (!c) return {ERR_FATAL, "Missing memory type"};
return {ERR_FATAL, "Unexpected memory type (%c)", c};
}

static ErrResult CharToExeType(char const c, ExeType& exeType)
{
char const* val = strchr(ExeTypeStr, toupper(c));
// strchr also matches the terminating NUL, so reject a missing type character explicitly
char const* val = c ? strchr(ExeTypeStr, toupper(c)) : NULL;
if (val) {
exeType = (ExeType)(val - ExeTypeStr);
return ERR_NONE;
}
if (!c) return {ERR_FATAL, "Missing executor type"};
return {ERR_FATAL, "Unexpected executor type (%c)", c};
}

Expand Down Expand Up @@ -1501,7 +1505,7 @@ const auto& AmdSmiFabricInfoV1(const T& info)
// This is optional for EXE_NIC_NEAREST as long as nothing further is specified
char const* endPtr = ParseRange(ptr, -1, exeDevice.exeIndices);
if (!endPtr) {
if (exeDevice.exeType == EXE_NIC_NEAREST && *endPtr == 0) {
if (exeDevice.exeType == EXE_NIC_NEAREST && *ptr == 0) {
if (exeDevice.exeRanks.size() != 0) {
return {ERR_FATAL, "Wildcard NIC executor may not be specified with rank in executor token %s", token.c_str()};
}
Expand Down Expand Up @@ -2274,7 +2278,7 @@ const auto& AmdSmiFabricInfoV1(const T& info)
CheckMultiNodeConfigConsistency(cfg, errors);

// Check data options
if (cfg.data.blockBytes == 0 || cfg.data.blockBytes % 4)
if (cfg.data.blockBytes <= 0 || cfg.data.blockBytes % 4)
errors.push_back({ERR_FATAL, "[data.blockBytes] must be positive multiple of %lu", sizeof(float)});
if (cfg.data.byteOffset < 0 || cfg.data.byteOffset % sizeof(float))
errors.push_back({ERR_FATAL, "[data.byteOffset] must be positive multiple of %lu", sizeof(float)});
Expand All @@ -2300,7 +2304,7 @@ const auto& AmdSmiFabricInfoV1(const T& info)
if (cfg.general.useMultiStream && cfg.gfx.blockOrder > 0)
errors.push_back({ERR_WARN, "[gfx.blockOrder] will be ignored when running in multi-stream mode"});

if (cfg.gfx.blockSize < 0 || cfg.gfx.blockSize % 64 || cfg.gfx.blockSize > MAX_BLOCKSIZE)
if (cfg.gfx.blockSize <= 0 || cfg.gfx.blockSize % 64 || cfg.gfx.blockSize > MAX_BLOCKSIZE)
errors.push_back({ERR_FATAL,
"[gfx.blockSize] must be positive multiple of 64 less than or equal to %d",
MAX_BLOCKSIZE});
Expand Down