From e506d14d183174fc96be041d8d530ba2f93ffacb Mon Sep 17 00:00:00 2001
From: gilbertlee-amd <44450918+gilbertlee-amd@users.noreply.github.com>
Date: Thu, 7 Oct 2021 15:57:21 -0600
Subject: [PATCH] [TransferBench] Fixing advanced config, adding new all-1-hop
sample test (#433)
* [TransferBench] Fixing advanced config, adding new all-1-hop sample test
---
tools/TransferBench/TransferBench.cpp | 38 +++++++++++++++++++++++----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/tools/TransferBench/TransferBench.cpp b/tools/TransferBench/TransferBench.cpp
index 6fac7df90a..6bc5093a28 100644
--- a/tools/TransferBench/TransferBench.cpp
+++ b/tools/TransferBench/TransferBench.cpp
@@ -532,6 +532,33 @@ void GenerateConfigFile(char const* cfgFile, int numBlocks)
}
fprintf(fp, "\n\n");
+ // All single-hop XGMI links
+ int numSingleHopXgmiLinks = 0;
+ for (int i = 0; i < numGpuDevices; i++)
+ for (int j = 0; j < numGpuDevices; j++)
+ {
+ if (i == j) continue;
+ uint32_t linkType, hopCount;
+ HIP_CALL(hipExtGetLinkTypeAndHopCount(i, j, &linkType, &hopCount));
+ if (linkType == HSA_AMD_LINK_INFO_TYPE_XGMI && hopCount == 1) numSingleHopXgmiLinks++;
+ }
+ if (numSingleHopXgmiLinks > 0)
+ {
+ fprintf(fp, "# All single-hop links\n");
+ fprintf(fp, "%d %d", numSingleHopXgmiLinks, numBlocks);
+ for (int i = 0; i < numGpuDevices; i++)
+ for (int j = 0; j < numGpuDevices; j++)
+ {
+ if (i == j) continue;
+ uint32_t linkType, hopCount;
+ HIP_CALL(hipExtGetLinkTypeAndHopCount(i, j, &linkType, &hopCount));
+ if (linkType == HSA_AMD_LINK_INFO_TYPE_XGMI && hopCount == 1)
+ {
+ fprintf(fp, " (G%d G%d F%d)", i, i, j);
+ }
+ }
+ fprintf(fp, "\n\n");
+ }
fclose(fp);
}
@@ -653,7 +680,7 @@ void ParseMemType(std::string const& token, int const numCpus, int const numGpus
void ParseLinks(char* line, int numCpus, int numGpus, std::vector& links)
{
// Replace any round brackets or '->' with spaces,
- for (int i = 0; line[i]; i++)
+ for (int i = 1; line[i]; i++)
if (line[i] == '(' || line[i] == ')' || line[i] == '-' || line[i] == '>' ) line[i] = ' ';
links.clear();
@@ -693,7 +720,8 @@ void ParseLinks(char* line, int numCpus, int numGpus, std::vector& links)
links[i].numBlocksToUse = numBlocksToUse;
if (links[i].exeMemType != MEM_CPU && links[i].exeMemType != MEM_GPU)
{
- printf("[ERROR] Executor must either be CPU ('C') or GPU ('G')\n");
+ printf("[ERROR] Executor must either be CPU ('C') or GPU ('G'), (from (%s->%s->%s %d))\n",
+ srcMem.c_str(), exeMem.c_str(), dstMem.c_str(), links[i].numBlocksToUse);
exit(1);
}
}
@@ -715,12 +743,12 @@ void ParseLinks(char* line, int numCpus, int numGpus, std::vector& links)
ParseMemType(srcMem, numCpus, numGpus, &links[i].srcMemType, &links[i].srcIndex);
ParseMemType(exeMem, numCpus, numGpus, &links[i].exeMemType, &links[i].exeIndex);
ParseMemType(dstMem, numCpus, numGpus, &links[i].dstMemType, &links[i].dstIndex);
- if (links[i].exeMemType != MEM_CPU || links[i].exeMemType != MEM_GPU)
+ if (links[i].exeMemType != MEM_CPU && links[i].exeMemType != MEM_GPU)
{
- printf("[ERROR] Executor must either be CPU ('C') or GPU ('G')\n");
+ printf("[ERROR] Executor must either be CPU ('C') or GPU ('G'), (from (%s->%s->%s %d))\n"
+, srcMem.c_str(), exeMem.c_str(), dstMem.c_str(), links[i].numBlocksToUse);
exit(1);
}
-
}
}
}