From c9eb85e205e11e85729869891a6a8efa577b8b13 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Wed, 10 Nov 2021 21:23:42 -0600 Subject: [PATCH] Correct size of SVM node array. Was size of the map. Needs to be size of the node id range. Change-Id: I92501ea7adca5c30dbb0fdabd2c421dea58f8d6f --- runtime/hsa-runtime/core/inc/runtime.h | 3 +++ runtime/hsa-runtime/core/runtime/runtime.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/inc/runtime.h b/runtime/hsa-runtime/core/inc/runtime.h index b481f2da65..c31b2f7ba5 100644 --- a/runtime/hsa-runtime/core/inc/runtime.h +++ b/runtime/hsa-runtime/core/inc/runtime.h @@ -487,6 +487,9 @@ class Runtime { /// @brief Get most recently issued SVM prefetch agent for the range in question. Agent* GetSVMPrefetchAgent(void* ptr, size_t size); + /// @brief Get the highest used node id. + uint32_t max_node_id() const { return agents_by_node_.rbegin()->first; } + // Mutex object to protect multithreaded access to ::allocation_map_, // KFD map/unmap, register/unregister, and access to hsaKmtQueryPointerInfo // registered & mapped arrays. diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 59980fa928..70cf00a86b 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -1646,7 +1646,7 @@ hsa_status_t Runtime::SetSvmAttrib(void* ptr, size_t size, hsa_amd_svm_attribute_pair_t* attribute_list, size_t attribute_count) { uint32_t set_attribs = 0; - std::vector agent_seen(agents_by_node_.size(), false); + std::vector agent_seen(max_node_id() + 1, false); std::vector attribs; attribs.reserve(attribute_count);