diff --git a/projects/rocr-runtime/libhsakmt/src/fmm.c b/projects/rocr-runtime/libhsakmt/src/fmm.c index 84e18cd42a..97b7864ab3 100644 --- a/projects/rocr-runtime/libhsakmt/src/fmm.c +++ b/projects/rocr-runtime/libhsakmt/src/fmm.c @@ -1675,7 +1675,7 @@ static void* udmabuf_allocation(uint32_t gpu_id, uint32_t node_id, uint64_t size if (bind_mem_to_numa(numa_node_id, mem, size, mflags)) goto error_release_aperture; - node_size = numa_node_size(numa_node_id, &free_size); + node_size = numa_node_size64(numa_node_id, &free_size); pr_debug("udmabuf_allocation: numa_node_id %d, node_size %lld, free_size %lld\n", numa_node_id, node_size, free_size); /* compare free size at numa_node_id with size */ diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp index 935007b6a3..ba4700340d 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/driver/kfd/amd_kfd_driver.cpp @@ -692,5 +692,102 @@ hsa_status_t KfdDriver::GetWallclockFrequency(uint32_t node_id, uint64_t* freque return HSA_STATUS_SUCCESS; } +hsa_status_t KfdDriver::ShareMemory(void* mem, size_t size, + HsaSharedMemoryHandle* share_mem) const { + assert(share_mem); + + if (HSAKMT_CALL(hsaKmtShareMemory(mem, size, share_mem)) != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::RegisterSharedHandle(const HsaSharedMemoryHandle* share_mem, void** mem, + uint64_t* size) const { + assert(share_mem); + assert(mem); + assert(size); + + if (HSAKMT_CALL(hsaKmtRegisterSharedHandle(share_mem, mem, size)) != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::ReplaceAsanHeaderPage(void* mem) const { + if (HSAKMT_CALL(hsaKmtReplaceAsanHeaderPage(mem)) != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::ReturnAsanHeaderPage(void* mem) const { + if (HSAKMT_CALL(hsaKmtReturnAsanHeaderPage(mem)) != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::PcSamplingQueryCapabilities(uint32_t node_id, void* sample_info, + uint32_t sample_info_sz, + uint32_t* sz_needed) const { + HSAKMT_STATUS status = HSAKMT_CALL( + hsaKmtPcSamplingQueryCapabilities(node_id, sample_info, sample_info_sz, sz_needed)); + if (status == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) { + return static_cast(HSA_STATUS_ERROR_RESOURCE_BUSY); + } + if (status != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::PcSamplingCreate(uint32_t node_id, HsaPcSamplingInfo* sample_info, + uint32_t* trace_id) const { + HSAKMT_STATUS status = HSAKMT_CALL(hsaKmtPcSamplingCreate(node_id, sample_info, trace_id)); + if (status == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) { + return static_cast(HSA_STATUS_ERROR_RESOURCE_BUSY); + } + if (status != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::PcSamplingDestroy(uint32_t node_id, uint32_t trace_id) const { + HSAKMT_STATUS status = HSAKMT_CALL(hsaKmtPcSamplingDestroy(node_id, trace_id)); + if (status == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) { + return static_cast(HSA_STATUS_ERROR_RESOURCE_BUSY); + } + if (status != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::PcSamplingStart(uint32_t node_id, uint32_t trace_id) const { + HSAKMT_STATUS status = HSAKMT_CALL(hsaKmtPcSamplingStart(node_id, trace_id)); + if (status == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) { + return static_cast(HSA_STATUS_ERROR_RESOURCE_BUSY); + } + if (status != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + +hsa_status_t KfdDriver::PcSamplingStop(uint32_t node_id, uint32_t trace_id) const { + HSAKMT_STATUS status = HSAKMT_CALL(hsaKmtPcSamplingStop(node_id, trace_id)); + if (status == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) { + return static_cast(HSA_STATUS_ERROR_RESOURCE_BUSY); + } + if (status != HSAKMT_STATUS_SUCCESS) { + return HSA_STATUS_ERROR; + } + return HSA_STATUS_SUCCESS; +} + } // namespace AMD } // namespace rocr diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h index ca8ee8a593..6a78aac6de 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/amd_kfd_driver.h @@ -136,6 +136,19 @@ public: const HsaMemMapFlags* mem_flags, uint32_t num_nodes, const uint32_t* nodes) const override; hsa_status_t MakeMemoryUnresident(const void* mem) const override; + hsa_status_t ShareMemory(void* mem, size_t size, HsaSharedMemoryHandle* share_mem) const override; + hsa_status_t RegisterSharedHandle(const HsaSharedMemoryHandle* share_mem, void** mem, + uint64_t* size) const override; + hsa_status_t ReplaceAsanHeaderPage(void* mem) const override; + hsa_status_t ReturnAsanHeaderPage(void* mem) const override; + hsa_status_t PcSamplingQueryCapabilities(uint32_t node_id, void* sample_info, + uint32_t sample_info_sz, + uint32_t* sz_needed) const override; + hsa_status_t PcSamplingCreate(uint32_t node_id, HsaPcSamplingInfo* sample_info, + uint32_t* trace_id) const override; + hsa_status_t PcSamplingDestroy(uint32_t node_id, uint32_t trace_id) const override; + hsa_status_t PcSamplingStart(uint32_t node_id, uint32_t trace_id) const override; + hsa_status_t PcSamplingStop(uint32_t node_id, uint32_t trace_id) const override; hsa_status_t OpenSMI(uint32_t node_id, int* fd) const override; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/driver.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/driver.h index 3a4082e24f..e2265126bc 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/driver.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/driver.h @@ -351,6 +351,92 @@ public: /// @return HSA_STATUS_SUCCESS if the driver successfully makes the memory virtual hsa_status_t MakeMemoryUnresident(const void* mem) const = 0; + /// @brief Shares memory with another process. + /// @param[in] mem Pointer to the memory to be shared. + /// @param[in] size Size of the memory to be shared. + /// @param[out] share_mem Pointer to the shared memory handle. + /// @return HSA_STATUS_SUCCESS if the memory was successfully shared, or an error code. + virtual hsa_status_t ShareMemory(void* mem, size_t size, HsaSharedMemoryHandle* share_mem) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Registers a shared memory handle. + /// @param[in] share_mem Pointer to the shared memory handle. + /// @param[out] mem Pointer to the memory. + /// @param[out] size Size of the memory. + /// @return HSA_STATUS_SUCCESS if the memory was successfully registered, or an error code. + virtual hsa_status_t RegisterSharedHandle(const HsaSharedMemoryHandle* share_mem, void** mem, + uint64_t* size) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Replaces the ASAN header page with a valid one. + /// @param[in] mem Pointer to the memory to be replaced. + /// @return HSA_STATUS_SUCCESS if the ASAN header page was successfully replaced, or an error + /// code. + virtual hsa_status_t ReplaceAsanHeaderPage(void* mem) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Returns the ASAN header page to its original state. + /// @param[in] mem Pointer to the memory to be returned. + /// @return HSA_STATUS_SUCCESS if the ASAN header page was successfully returned, or an error + /// code. + virtual hsa_status_t ReturnAsanHeaderPage(void* mem) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Queries the PC sampling capabilities. + /// @param[in] node_id Node ID of the agent + /// @param[in] sample_info Pointer to the sample information + /// @param[in] sample_info_sz Size of the sample information + /// @param[out] sz_needed Size of the sample information needed + /// @return HSA_STATUS_SUCCESS if the PC sampling capabilities were successfully queried, or an + /// error code. + virtual hsa_status_t PcSamplingQueryCapabilities(uint32_t node_id, void* sample_info, + uint32_t sample_info_sz, + uint32_t* sz_needed) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Creates a PC sampling session. + /// @param[in] node_id Node ID of the agent + /// @param[in] sample_info Pointer to the sample information + /// @param[out] trace_id Pointer to the trace ID + /// @return HSA_STATUS_SUCCESS if the PC sampling session was successfully created, or an error + /// code. + virtual hsa_status_t PcSamplingCreate(uint32_t node_id, HsaPcSamplingInfo* sample_info, + uint32_t* trace_id) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Destroys a PC sampling session. + /// @param[in] node_id Node ID of the agent + /// @param[in] trace_id Trace ID of the PC sampling session + /// @return HSA_STATUS_SUCCESS if the PC sampling session was successfully destroyed, or an error + /// code. + virtual hsa_status_t PcSamplingDestroy(uint32_t node_id, uint32_t trace_id) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Starts a PC sampling session. + /// @param[in] node_id Node ID of the agent + /// @param[in] trace_id Trace ID of the PC sampling session + /// @return HSA_STATUS_SUCCESS if the PC sampling session was successfully started, or an error + /// code. + virtual hsa_status_t PcSamplingStart(uint32_t node_id, uint32_t trace_id) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + + /// @brief Stops a PC sampling session. + /// @param[in] node_id Node ID of the agent + /// @param[in] trace_id Trace ID of the PC sampling session + /// @return HSA_STATUS_SUCCESS if the PC sampling session was successfully stopped, or an error + /// code. + virtual hsa_status_t PcSamplingStop(uint32_t node_id, uint32_t trace_id) const { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + /// Unique identifier for supported kernel-mode drivers. const DriverType kernel_driver_type_; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h index 4b7e489d94..b9e45a8350 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h @@ -508,6 +508,22 @@ class Runtime { return **driver; } + /// @brief Check if the drivers of the agents are different. + /// @param [in] agents Array of agents to check. + /// @param [in] num_agents Number of agents in the array. + /// @return True if the drivers of the agents are different, false otherwise. + static bool IsDifferentDriver(Agent* agents, uint32_t num_agents) { + if (num_agents == 0 || agents == nullptr) return true; + + auto first_driver_type = agents[0].driver().kernel_driver_type_; + for (uint32_t i = 1; i < num_agents; ++i) { + if (agents[i].driver().kernel_driver_type_ != first_driver_type) { + return true; + } + } + return false; + } + std::vector>& AgentDrivers() { return agent_drivers_; } static bool IsGPUDriver(DriverType driver_type) { diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 6f9fe60e70..31b2f11c81 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -2553,20 +2553,16 @@ hsa_status_t GpuAgent::PcSamplingIterateConfig(hsa_ven_amd_pcs_iterate_configura return HSA_STATUS_ERROR; // First query to get size of list needed - HSAKMT_STATUS ret = HSAKMT_CALL(hsaKmtPcSamplingQueryCapabilities(node_id(), NULL, 0, &size)); - if (ret != HSAKMT_STATUS_SUCCESS || size == 0) return HSA_STATUS_ERROR; + hsa_status_t ret = driver().PcSamplingQueryCapabilities(node_id(), NULL, 0, &size); + if (ret != HSA_STATUS_SUCCESS || size == 0) return ret; std::vector sampleInfoList(size); - ret = HSAKMT_CALL(hsaKmtPcSamplingQueryCapabilities(node_id(), sampleInfoList.data(), sampleInfoList.size(), - &size)); + ret = driver().PcSamplingQueryCapabilities(node_id(), sampleInfoList.data(), + sampleInfoList.size(), &size); - if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR; + if (ret != HSA_STATUS_SUCCESS) return ret; for (uint32_t i = 0; i < size; i++) { - if ((isa_->GetMajorVersion() == 12 && (isa_->GetMinorVersion() == 0)) && - sampleInfoList[i].method == HSA_PC_SAMPLING_METHOD_KIND_STOCHASTIC_V1) { - continue; - } hsa_ven_amd_pcs_configuration_t hsaPcSampling; if (ConvertHsaKmtPcSamplingInfoToHsa(&sampleInfoList[i], &hsaPcSampling) == HSA_STATUS_SUCCESS && cb(&hsaPcSampling, cb_data) == HSA_STATUS_INFO_BREAK) @@ -2590,10 +2586,9 @@ hsa_status_t GpuAgent::PcSamplingCreate(pcs::PcsRuntime::PcSamplingSession& sess // Pass the sampling information to the kernel driver to create PC // sampling session. - HSAKMT_STATUS retkmt = HSAKMT_CALL(hsaKmtPcSamplingCreate(node_id(), &sampleInfo, &thunkId)); - if (retkmt != HSAKMT_STATUS_SUCCESS) { - return (retkmt == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) ? (hsa_status_t)HSA_STATUS_ERROR_RESOURCE_BUSY - : HSA_STATUS_ERROR; + ret = driver().PcSamplingCreate(node_id(), &sampleInfo, &thunkId); + if (ret != HSA_STATUS_SUCCESS) { + return ret; } debug_print("Created PC sampling session with thunkId:%d\n", thunkId); @@ -2613,10 +2608,6 @@ hsa_status_t GpuAgent::PcSamplingCreateFromId(HsaPcSamplingTraceId ioctlId, if (sampling_method == HSA_VEN_AMD_PCS_METHOD_HOSTTRAP_V1) { pcs_data = &pcs_hosttrap_data_; } else if (sampling_method == HSA_VEN_AMD_PCS_METHOD_STOCHASTIC_V1) { - if (isa_->GetMajorVersion() == 12 && (isa_->GetMinorVersion() == 0)) { - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - pcs_data = &pcs_stochastic_data_; } else { // Unsupported sampling method @@ -2803,7 +2794,7 @@ hsa_status_t GpuAgent::PcSamplingCreateFromId(HsaPcSamplingTraceId ioctlId, hsa_status_t GpuAgent::PcSamplingDestroy(pcs::PcsRuntime::PcSamplingSession& session) { if (PcSamplingStop(session) != HSA_STATUS_SUCCESS) return HSA_STATUS_ERROR; - HSAKMT_STATUS retKmt = HSAKMT_CALL(hsaKmtPcSamplingDestroy(node_id(), session.ThunkId())); + hsa_status_t ret = driver().PcSamplingDestroy(node_id(), session.ThunkId()); hsa_ven_amd_pcs_method_kind_t sampling_method = session.method(); pcs_data_t* pcs_data = nullptr; @@ -2835,7 +2826,7 @@ hsa_status_t GpuAgent::PcSamplingDestroy(pcs::PcsRuntime::PcSamplingSession& ses // Update the trap handler to clear any associated device data UpdateTrapHandlerWithPCS(nullptr, nullptr); - return (retKmt == HSAKMT_STATUS_SUCCESS) ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR; + return ret; } hsa_status_t GpuAgent::PcSamplingStart(pcs::PcsRuntime::PcSamplingSession& session) { @@ -2902,8 +2893,9 @@ hsa_status_t GpuAgent::PcSamplingStart(pcs::PcsRuntime::PcSamplingSession& sessi } // Start the sampling session in the kernel driver - if (HSAKMT_CALL(hsaKmtPcSamplingStart(node_id(), session.ThunkId())) == HSAKMT_STATUS_SUCCESS) + if (driver().PcSamplingStart(node_id(), session.ThunkId()) == HSA_STATUS_SUCCESS) { return HSA_STATUS_SUCCESS; + } debug_print("Failed to start PC sampling session with thunkId:%d\n", session.ThunkId()); // Clean up if starting the session failed @@ -2923,8 +2915,8 @@ hsa_status_t GpuAgent::PcSamplingStop(pcs::PcsRuntime::PcSamplingSession& sessio session.stop(); // Stop PC sampling in the kernel driver - HSAKMT_STATUS retKmt = HSAKMT_CALL(hsaKmtPcSamplingStop(node_id(), session.ThunkId())); - if (retKmt != HSAKMT_STATUS_SUCCESS) + hsa_status_t ret = driver().PcSamplingStop(node_id(), session.ThunkId()); + if (ret != HSA_STATUS_SUCCESS) throw AMD::hsa_exception(HSA_STATUS_ERROR, "Failed to stop PC Sampling session."); // Determine the sampling method and corresponding data 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 14b57254bb..e756ec7902 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -368,7 +368,7 @@ hsa_status_t Runtime::FreeMemory(void* ptr) { } if (alloc_flags & core::MemoryRegion::AllocateAsan) - assert(HSAKMT_CALL(hsaKmtReturnAsanHeaderPage(ptr)) == HSAKMT_STATUS_SUCCESS); + assert(region->owner()->driver().ReturnAsanHeaderPage(ptr) == HSA_STATUS_SUCCESS); const hsa_status_t err = region->Free(ptr, size); if (err != HSA_STATUS_SUCCESS) { @@ -1216,6 +1216,7 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han if (info.agentBaseAddress != ptr || info.sizeInBytes != len) return HSA_STATUS_ERROR_INVALID_ARGUMENT; + Agent* agent = Agent::Convert(info.agentOwner); bool useFrag = (block.base != ptr || block.length != len); // Assume all pointers and blocks are 4Kb aligned. uint32_t fragOffset = (reinterpret_cast(ptr) - @@ -1229,7 +1230,7 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han if (!ipc_dmabuf_supported_) { HsaSharedMemoryHandle *sHandle = reinterpret_cast(handle); - if (HSAKMT_CALL(hsaKmtShareMemory(block.base, block.length, sHandle)) != HSAKMT_STATUS_SUCCESS) + if (agent->driver().ShareMemory(block.base, block.length, sHandle) != HSA_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT; hsa_status_t err = HSA_STATUS_SUCCESS; @@ -1250,7 +1251,6 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han handle->handle[1] = dmaBufFdHandleHi; handle->handle[2] = getpid(); // socket server name handle - Agent *agent = Agent::Convert(info.agentOwner); handle->handle[3] = agent->device_type() == Agent::kAmdCpuDevice; // System sub allocations are not supported for now. if (handle->handle[3] && useFrag) return HSA_STATUS_ERROR_INVALID_ARGUMENT; @@ -1391,6 +1391,9 @@ hsa_status_t Runtime::IPCAttach(const hsa_amd_ipc_memory_t* handle, size_t len, bool isFragment = false; uint32_t fragOffset = 0; + if (Runtime::IsDifferentDriver(*agents, num_agents)) return HSA_STATUS_ERROR_INVALID_ARGUMENT; + core::Driver* driver = &agents[0]->driver(); + auto fixFragment = [&](amdgpu_bo_handle ldrm_bo) { if (isFragment) { importAddress = reinterpret_cast(importAddress) + fragOffset; @@ -1402,14 +1405,17 @@ hsa_status_t Runtime::IPCAttach(const hsa_amd_ipc_memory_t* handle, size_t len, allocation_map_[importAddress].ldrm_bo = ldrm_bo; }; - auto importMemory = [&](unsigned int numNodes, HSAuint32 *nodes, - amdgpu_bo_import_result *res) { - int ret = ipc_dmabuf_supported_ ? - IPCClientImport(importHandle.handle[2], dmaBufFDHandle, res, - numNodes, nodes, &importAddress, &importSize) : - HSAKMT_CALL(hsaKmtRegisterSharedHandle(reinterpret_cast(&importHandle), - &importAddress, &importSize)); - if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT; + auto importMemory = [&](unsigned int numNodes, HSAuint32* nodes, amdgpu_bo_import_result* res) { + if (ipc_dmabuf_supported_) { + int ret = IPCClientImport(importHandle.handle[2], dmaBufFDHandle, res, numNodes, nodes, + &importAddress, &importSize); + if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT; + } else { + hsa_status_t ret = driver->RegisterSharedHandle( + reinterpret_cast(&importHandle), &importAddress, + &importSize); + if (ret != HSA_STATUS_SUCCESS) return ret; + } return HSA_STATUS_SUCCESS; };