From 9d997430ee18ac91c89ab7efd7cfe4510f016ee2 Mon Sep 17 00:00:00 2001 From: Hicham Agueny <95568317+HichamAgueny@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:04:58 +0100 Subject: [PATCH] add hip_check() --- GPUSimulators/MPISimulator.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/GPUSimulators/MPISimulator.py b/GPUSimulators/MPISimulator.py index ebb5787..29706d0 100644 --- a/GPUSimulators/MPISimulator.py +++ b/GPUSimulators/MPISimulator.py @@ -206,6 +206,20 @@ class MPISimulator(Simulator.BaseSimulator): """ Class which handles communication between simulators on different MPI nodes """ + def hip_check(call_result): + err = call_result[0] + result = call_result[1:] + if len(result) == 1: + result = result[0] + if isinstance(err, hip.hipError_t) and err != hip.hipError_t.hipSuccess: + raise RuntimeError(str(err)) + elif ( + isinstance(err, hiprtc.hiprtcResult) + and err != hiprtc.hiprtcResult.HIPRTC_SUCCESS + ): + raise RuntimeError(str(err)) + return result + def __init__(self, sim, grid): self.profiling_data_mpi = { 'start': {}, 'end': {} } self.profiling_data_mpi["start"]["t_mpi_halo_exchange"] = 0