diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp index a27e90eada..d97d0e5856 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp @@ -536,10 +536,13 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, info.size = sizeof(info); ScopedAcquire lock(&access_lock_); + if (core::Runtime::runtime_singleton_->PtrInfo(const_cast(ptr), &info, malloc, &agent_count, &accessible, &blockInfo) == HSA_STATUS_SUCCESS) { - if (blockInfo.length != size || info.sizeInBytes != size) { + /* Thunk may return type = HSA_EXT_POINTER_TYPE_UNKNOWN for userptrs */ + if (info.type != HSA_EXT_POINTER_TYPE_UNKNOWN && + (blockInfo.length != size || info.sizeInBytes != size)) { for (int i = 0; i < num_agents; i++) union_agents.push_back(agents[i].handle); for (int i = 0; i < agent_count; i++) union_agents.push_back(accessible[i].handle); std::sort(union_agents.begin(), union_agents.end()); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index e85a224883..a4cb90280f 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -777,8 +777,11 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi // We don't care if this returns an error code. // The type will be HSA_EXT_POINTER_TYPE_UNKNOWN if so. auto err = hsaKmtQueryPointerInfo(ptr, &thunkInfo); - assert(((err == HSAKMT_STATUS_SUCCESS) || (thunkInfo.Type == HSA_POINTER_UNKNOWN)) && - "Thunk ptr info error and not type HSA_POINTER_UNKNOWN."); + if (err != HSAKMT_STATUS_SUCCESS || thunkInfo.Type == HSA_POINTER_UNKNOWN) { + memset(info, 0, sizeof(*info)); + info->type = HSA_EXT_POINTER_TYPE_UNKNOWN; + return HSA_STATUS_SUCCESS; + } if (returnListData) { assert(thunkInfo.NMappedNodes <= agents_by_node_.size() &&