Skip to content

Commit 0565082

Browse files
committed
handling error return code to get rid of nodiscard warning
1 parent 9957996 commit 0565082

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

include/umpire/op/hip.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ inline void prefetch(T* ptr, int device, std::size_t count)
214214
{
215215
// Use current device for properties if device is CPU
216216
int current_device;
217-
hipGetDevice(&current_device);
217+
hipError_t error = hipGetDevice(&current_device);
218+
219+
if (error != hipSuccess) {
220+
UMPIRE_ERROR(runtime_error,
221+
fmt::format("hipGetDevice failed with error: {}", hipGetErrorString(error)));
222+
}
223+
218224
int gpu = (device != hipCpuDeviceId) ? device : current_device;
219225

220226
if (supports_managed_memory(gpu)) {
@@ -246,7 +252,13 @@ inline camp::resources::EventProxy<camp::resources::Resource> prefetch_async(T*
246252

247253
// Use current device for properties if device is CPU
248254
int current_device;
249-
hipGetDevice(&current_device);
255+
hipError_t error = hipGetDevice(&current_device);
256+
257+
if (error != hipSuccess) {
258+
UMPIRE_ERROR(runtime_error,
259+
fmt::format("hipGetDevice failed with error: {}", hipGetErrorString(error)));
260+
}
261+
250262
int gpu = (device != hipCpuDeviceId) ? device : current_device;
251263

252264
if (supports_managed_memory(gpu)) {

0 commit comments

Comments
 (0)