From 163eb02a0b02b27df6721928e5263ae1ccbb9b27 Mon Sep 17 00:00:00 2001 From: Hicham Agueny Date: Tue, 27 Feb 2024 16:04:03 +0100 Subject: [PATCH] add hip_check() routine --- GPUSimulators/SHMEMSimulator.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/GPUSimulators/SHMEMSimulator.py b/GPUSimulators/SHMEMSimulator.py index cfee8f3..8417d7e 100644 --- a/GPUSimulators/SHMEMSimulator.py +++ b/GPUSimulators/SHMEMSimulator.py @@ -34,6 +34,20 @@ class SHMEMSimulator(Simulator.BaseSimulator): Class which handles communication and synchronization between simulators in different contexts (presumably on different GPUs) """ + 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, sims, grid): self.logger = logging.getLogger(__name__)