diff --git a/runtime/hsa-runtime/core/inc/runtime.h b/runtime/hsa-runtime/core/inc/runtime.h index c0c1344f2a..dd38f615a3 100644 --- a/runtime/hsa-runtime/core/inc/runtime.h +++ b/runtime/hsa-runtime/core/inc/runtime.h @@ -177,13 +177,11 @@ class Runtime { /// @param [in] size Allocation size in bytes. /// @param [in] alloc_flags Modifiers to pass to MemoryRegion allocator. /// @param [out] address Pointer to store the allocation result. - /// @param [in] user_request Set to true if this is an external allocation, i.e this address - /// is directly visible to the user of this library /// /// @retval ::HSA_STATUS_SUCCESS If allocation is successful. hsa_status_t AllocateMemory(const MemoryRegion* region, size_t size, - MemoryRegion::AllocateFlags alloc_flags, void** address, - bool user_request = false); + MemoryRegion::AllocateFlags alloc_flags, + void** address); /// @brief Free memory previously allocated with AllocateMemory. /// @@ -320,7 +318,7 @@ class Runtime { hsa_status_t PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, void* (*alloc)(size_t), uint32_t* num_agents_accessible, hsa_agent_t** accessible, - PtrInfoBlockData* block_info = nullptr, bool user_request = false); + PtrInfoBlockData* block_info = nullptr); hsa_status_t SetPtrInfoData(const void* ptr, void* userptr); @@ -406,13 +404,8 @@ class Runtime { struct AllocationRegion { AllocationRegion() : region(NULL), size(0), size_requested(0), user_ptr(nullptr) {} - AllocationRegion(const MemoryRegion* region_arg, size_t size_arg, size_t size_requested, - bool user_request = false) - : region(region_arg), - size(size_arg), - size_requested(size_requested), - user_ptr(nullptr), - user_request(user_request) {} + AllocationRegion(const MemoryRegion* region_arg, size_t size_arg, size_t size_requested) + : region(region_arg), size(size_arg), size_requested(size_requested), user_ptr(nullptr) {} struct notifier_t { void* ptr; @@ -425,7 +418,6 @@ class Runtime { size_t size_requested; /* size requested by user */ void* user_ptr; std::unique_ptr> notifiers; - bool user_request; }; struct AsyncEventsControl { diff --git a/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp b/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp index 1859731002..b6f91efa7d 100644 --- a/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp @@ -546,8 +546,8 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, ScopedAcquire lock(&access_lock_); if (core::Runtime::runtime_singleton_->PtrInfo(const_cast(ptr), &info, malloc, - &agent_count, &accessible, &blockInfo, - true) == HSA_STATUS_SUCCESS) { + &agent_count, &accessible, + &blockInfo) == HSA_STATUS_SUCCESS) { /* 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)) { diff --git a/runtime/hsa-runtime/core/runtime/hsa.cpp b/runtime/hsa-runtime/core/runtime/hsa.cpp index 8756bf720f..3dc854bbd4 100644 --- a/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -1092,7 +1092,7 @@ hsa_status_t IS_VALID(mem_region); return core::Runtime::runtime_singleton_->AllocateMemory( - mem_region, size, core::MemoryRegion::AllocateNoFlags, ptr, true); + mem_region, size, core::MemoryRegion::AllocateNoFlags, ptr); CATCH; } diff --git a/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp b/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp index dbd5827945..43fd38939c 100644 --- a/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp +++ b/runtime/hsa-runtime/core/runtime/hsa_ext_amd.cpp @@ -756,7 +756,7 @@ hsa_status_t hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, siz if (flags == HSA_AMD_MEMORY_POOL_PCIE_FLAG) alloc_flag |= core::MemoryRegion::AllocatePCIeRW; - return core::Runtime::runtime_singleton_->AllocateMemory(mem_region, size, alloc_flag, ptr, true); + return core::Runtime::runtime_singleton_->AllocateMemory(mem_region, size, alloc_flag, ptr); CATCH; } @@ -907,8 +907,7 @@ hsa_status_t hsa_amd_pointer_info(const void* ptr, hsa_amd_pointer_info_t* info, IS_OPEN(); IS_BAD_PTR(ptr); IS_BAD_PTR(info); - return core::Runtime::runtime_singleton_->PtrInfo(ptr, info, alloc, num_accessible, accessible, - NULL, true); + return core::Runtime::runtime_singleton_->PtrInfo(ptr, info, alloc, num_accessible, accessible); CATCH; } diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index e9f44868a1..2ebe62bdea 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -284,14 +284,14 @@ hsa_status_t Runtime::IterateAgent(hsa_status_t (*callback)(hsa_agent_t agent, } hsa_status_t Runtime::AllocateMemory(const MemoryRegion* region, size_t size, - MemoryRegion::AllocateFlags alloc_flags, void** address, - bool user_request) { + MemoryRegion::AllocateFlags alloc_flags, + void** address) { size_t size_requested = size; // region->Allocate(...) may align-up size to granularity hsa_status_t status = region->Allocate(size, alloc_flags, address); // Track the allocation result so that it could be freed properly. if (status == HSA_STATUS_SUCCESS) { ScopedAcquire lock(&memory_lock_); - allocation_map_[*address] = AllocationRegion(region, size, size_requested, user_request); + allocation_map_[*address] = AllocationRegion(region, size, size_requested); } return status; @@ -788,7 +788,7 @@ hsa_status_t Runtime::InteropUnmap(void* ptr) { hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, void* (*alloc)(size_t), uint32_t* num_agents_accessible, hsa_agent_t** accessible, - PtrInfoBlockData* block_info, bool user_request) { + PtrInfoBlockData* block_info) { static_assert(static_cast(HSA_POINTER_UNKNOWN) == static_cast(HSA_EXT_POINTER_TYPE_UNKNOWN), "Thunk pointer info mismatch"); static_assert(static_cast(HSA_POINTER_ALLOCATED) == static_cast(HSA_EXT_POINTER_TYPE_HSA), @@ -859,13 +859,11 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi auto fragment = allocation_map_.upper_bound(ptr); if (fragment != allocation_map_.begin()) { fragment--; - if ((fragment->first <= ptr) && (user_request && fragment->second.user_request) && - (ptr < - reinterpret_cast(fragment->first) + fragment->second.size_requested)) { + if ((fragment->first <= ptr) && + (ptr < reinterpret_cast(fragment->first) + fragment->second.size_requested)) { // agent and host address must match here. Only lock memory is allowed to have differing // addresses but lock memory has type HSA_EXT_POINTER_TYPE_LOCKED and cannot be // suballocated. - retInfo.agentBaseAddress = const_cast(fragment->first); retInfo.hostBaseAddress = retInfo.agentBaseAddress; retInfo.sizeInBytes = fragment->second.size_requested; @@ -960,7 +958,7 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han PtrInfoBlockData block; hsa_amd_pointer_info_t info; info.size = sizeof(info); - if (PtrInfo(ptr, &info, nullptr, nullptr, nullptr, &block, true) != HSA_STATUS_SUCCESS) + if (PtrInfo(ptr, &info, nullptr, nullptr, nullptr, &block) != HSA_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT; // Temporary: Previous versions of HIP will call hsa_amd_ipc_memory_create with the len aligned to