From d6fcfcdccfc9be13caed5a45af56224afc1bcb58 Mon Sep 17 00:00:00 2001 From: Eric Huang Date: Thu, 27 Aug 2020 17:17:43 -0400 Subject: [PATCH] kfdtest: add function to determine XGMI link to cpu Signed-off-by: Eric Huang Change-Id: I7650f7857f0eecd2ad587634ae11c1cf5116bd97 [ROCm/ROCR-Runtime commit: 198b5bd450328477ea43d5692180aafd4d66ebb9] --- .../tests/kfdtest/src/KFDTestUtil.cpp | 23 +++++++++++++++++++ .../tests/kfdtest/src/KFDTestUtil.hpp | 5 ++++ 2 files changed, 28 insertions(+) diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp index c4ff186686..c3a528d9c5 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp @@ -663,3 +663,26 @@ int HsaNodeInfo::FindAccessiblePeers(std::vector *peers, HSAuint32 ds return peers->size(); } + +const bool HsaNodeInfo::IsNodeXGMItoCPU(int node) const { + const HsaNodeProperties *pNodeProperties; + bool ret = false; + + pNodeProperties = GetNodeProperties(node); + if (pNodeProperties && pNodeProperties->NumIOLinks) { + HsaIoLinkProperties *IolinkProperties = new HsaIoLinkProperties[pNodeProperties->NumIOLinks]; + EXPECT_SUCCESS(hsaKmtGetNodeIoLinkProperties(node, pNodeProperties->NumIOLinks, IolinkProperties)); + + for (int linkId = 0; linkId < pNodeProperties->NumIOLinks; linkId++) { + EXPECT_EQ(node, IolinkProperties[linkId].NodeFrom); + const HsaNodeProperties *pNodeProperties0 = + GetNodeProperties(IolinkProperties[linkId].NodeTo); + if (pNodeProperties0->NumFComputeCores == 0 && + IolinkProperties[linkId].IoLinkType == HSA_IOLINK_TYPE_XGMI) + ret = true; + } + delete [] IolinkProperties; + } + + return ret; +} diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp index 28847f370e..e640d588fc 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp @@ -196,6 +196,11 @@ class HsaNodeInfo { const bool AreGPUNodesXGMI(int node0, int node1) const; int FindAccessiblePeers(std::vector *peers, HSAuint32 dstNode, bool bidirectional) const; + /* @brief: to determine if the node is XGMI-linked to CPU + * @param: node index of the node we are looking at + * @return: bool true or false + */ + const bool IsNodeXGMItoCPU(int node) const; }; #endif // __KFD__TEST__UTIL__H__