From 8b54459e12c025c7ae3d84b3d099e1305097df12 Mon Sep 17 00:00:00 2001 From: Kent Russell Date: Mon, 28 Mar 2022 15:46:51 -0400 Subject: [PATCH] kfdtest: Add function to check for PCI Atomic Ops support While this is currently only used in one subtest, it's useful to have this separated into the test utilities. This will also allow us to check for PCI Atomics support before trying to run them. Signed-off-by: Kent Russell Change-Id: I9704d151bfaa627eceae8399cc46c15babde6ff1 --- tests/kfdtest/src/KFDTestUtil.cpp | 37 +++++++++++++++++++++++++++++++ tests/kfdtest/src/KFDTestUtil.hpp | 1 + 2 files changed, 38 insertions(+) diff --git a/tests/kfdtest/src/KFDTestUtil.cpp b/tests/kfdtest/src/KFDTestUtil.cpp index 7473db456a..476e0bb1ce 100644 --- a/tests/kfdtest/src/KFDTestUtil.cpp +++ b/tests/kfdtest/src/KFDTestUtil.cpp @@ -128,6 +128,43 @@ bool is_dgpu() { return is_dgpu_dev; } +bool hasPciAtomicsSupport(int node) { + /* If we can't get Node Properties, assume a lack of Atomics support */ + HsaNodeProperties *pNodeProperties = new HsaNodeProperties(); + if (hsaKmtGetNodeProperties(node, pNodeProperties)) { + LOG() << "Unable to get Node Properties for node " << node << std::endl; + return false; + } + + /* APUs don't have IO Links, but support Atomic Ops by default */ + if (pNodeProperties->NumCPUCores && pNodeProperties->NumFComputeCores) + return true; + + HsaIoLinkProperties *IolinkProperties = new HsaIoLinkProperties[pNodeProperties->NumIOLinks]; + if (hsaKmtGetNodeIoLinkProperties(node, pNodeProperties->NumIOLinks, IolinkProperties)) { + LOG() << "Unable to get Node IO Link Information for node " << node << std::endl; + return false; + } + + /* Make sure we're checking GPU-to-CPU connection here */ + for (int linkId = 0; linkId < pNodeProperties->NumIOLinks; linkId++) { + /* Make sure it's a CPU */ + HsaNodeProperties *linkProps = new HsaNodeProperties(); + if (hsaKmtGetNodeProperties(IolinkProperties[linkId].NodeTo, linkProps)) { + LOG() << "Unable to get connected device's IO Link information" << std::endl; + return false; + } + if (linkProps->NumCPUCores) { + /* IOLink flags are only valid if Override flag is set */ + return (IolinkProperties[linkId].Flags.ui32.Override && + !IolinkProperties[linkId].Flags.ui32.NoAtomics32bit && + !IolinkProperties[linkId].Flags.ui32.NoAtomics64bit); + } + } + + return false; +} + unsigned int FamilyIdFromNode(const HsaNodeProperties *props) { unsigned int familyId = FAMILY_UNKNOWN; diff --git a/tests/kfdtest/src/KFDTestUtil.hpp b/tests/kfdtest/src/KFDTestUtil.hpp index ee88ed3909..7c2f9c61ce 100644 --- a/tests/kfdtest/src/KFDTestUtil.hpp +++ b/tests/kfdtest/src/KFDTestUtil.hpp @@ -50,6 +50,7 @@ HSAKMT_STATUS CreateQueueTypeEvent(bool ManualReset, bool IsSignaled, unsigned i bool is_dgpu(); bool isTonga(const HsaNodeProperties *props); +bool hasPciAtomicsSupport(int node); unsigned int FamilyIdFromNode(const HsaNodeProperties *props); void GetHwQueueInfo(const HsaNodeProperties *props,