From e620ea1b699aeb77123378fe199e065792c1144a Mon Sep 17 00:00:00 2001 From: Kurt McMillan Date: Fri, 31 Oct 2025 21:03:07 +0000 Subject: [PATCH] rocfile: Throw system_error if IO failed in amdgpu status will be set if IO fails in amdgpu/kfd. If status is set, throw a system_error instead of throwing HipRuntimeError. --- rocfile/src/hip.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/rocfile/src/hip.cpp b/rocfile/src/hip.cpp index 59297b61..8f1a2cab 100644 --- a/rocfile/src/hip.cpp +++ b/rocfile/src/hip.cpp @@ -121,18 +121,20 @@ uint64_t Hip::hipAmdFileRead(hipAmdFileHandle_t handle, void *devicePtr, uint64_t size, int64_t file_offset) const { static const hipAmdFileRead_t hipAmdFileReadPtr{getHipAmdFileReadPtr()}; - uint64_t bytes_read; - int status; + uint64_t bytes_read{}; + int status{}; if (!hipAmdFileReadPtr) { throw Hip::SymbolNotFound("Could not find hipAmdFileRead()"); } - (void)throwOnHipError( - (*hipAmdFileReadPtr)(handle, devicePtr, size, file_offset, &bytes_read, &status)); + auto hip_error{(*hipAmdFileReadPtr)(handle, devicePtr, size, file_offset, &bytes_read, &status)}; if (status) { - throw std::system_error(status, std::generic_category()); + throw std::system_error(abs(status), std::generic_category()); + } + else if (hip_error) { + throw Hip::RuntimeError(hip_error); } return bytes_read; @@ -142,18 +144,20 @@ uint64_t Hip::hipAmdFileWrite(hipAmdFileHandle_t handle, void *devicePtr, uint64_t size, int64_t file_offset) const { static const hipAmdFileWrite_t hipAmdFileWritePtr{getHipAmdFileWritePtr()}; - uint64_t bytes_written; - int32_t status; + uint64_t bytes_written{}; + int32_t status{}; if (!hipAmdFileWritePtr) { throw Hip::SymbolNotFound("Could not find hipAmdFileWrite()"); } - (void)throwOnHipError( - (*hipAmdFileWritePtr)(handle, devicePtr, size, file_offset, &bytes_written, &status)); + auto hip_error{(*hipAmdFileWritePtr)(handle, devicePtr, size, file_offset, &bytes_written, &status)}; if (status) { - throw std::system_error(status, std::generic_category()); + throw std::system_error(abs(status), std::generic_category()); + } + else if (hip_error) { + throw Hip::RuntimeError(hip_error); } return bytes_written;