diff --git a/GPUSimulators/FORCE.py b/GPUSimulators/FORCE.py index 205c4d7..092711a 100644 --- a/GPUSimulators/FORCE.py +++ b/GPUSimulators/FORCE.py @@ -24,7 +24,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np - +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc diff --git a/GPUSimulators/HLL.py b/GPUSimulators/HLL.py index 885fbc3..792d3c6 100644 --- a/GPUSimulators/HLL.py +++ b/GPUSimulators/HLL.py @@ -23,6 +23,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc diff --git a/GPUSimulators/HLL2.py b/GPUSimulators/HLL2.py index e9b1313..b5c0dc0 100644 --- a/GPUSimulators/HLL2.py +++ b/GPUSimulators/HLL2.py @@ -23,6 +23,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc @@ -50,6 +51,20 @@ class HLL2 (Simulator.BaseSimulator): dt: Size of each timestep (90 s) g: Gravitational accelleration (9.81 m/s^2) """ + 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, context, h0, hu0, hv0, diff --git a/GPUSimulators/KP07.py b/GPUSimulators/KP07.py index 5ad5d8c..93ce5e9 100644 --- a/GPUSimulators/KP07.py +++ b/GPUSimulators/KP07.py @@ -28,6 +28,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc @@ -51,6 +52,20 @@ class KP07 (Simulator.BaseSimulator): dt: Size of each timestep (90 s) g: Gravitational accelleration (9.81 m/s^2) """ + 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, context, h0, hu0, hv0, diff --git a/GPUSimulators/KP07_dimsplit.py b/GPUSimulators/KP07_dimsplit.py index c9e2c80..0a5cfc7 100644 --- a/GPUSimulators/KP07_dimsplit.py +++ b/GPUSimulators/KP07_dimsplit.py @@ -28,6 +28,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc @@ -52,6 +53,21 @@ class KP07_dimsplit(Simulator.BaseSimulator): dt: Size of each timestep (90 s) g: Gravitational accelleration (9.81 m/s^2) """ + + 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, context, h0, hu0, hv0, diff --git a/GPUSimulators/LxF.py b/GPUSimulators/LxF.py index 3b989d3..98e54c6 100644 --- a/GPUSimulators/LxF.py +++ b/GPUSimulators/LxF.py @@ -24,6 +24,7 @@ along with this program. If not, see . from GPUSimulators import Simulator, Common from GPUSimulators.Simulator import BaseSimulator, BoundaryCondition import numpy as np +import ctypes #from pycuda import gpuarray from hip import hip,hiprtc @@ -49,6 +50,21 @@ class LxF (Simulator.BaseSimulator): dt: Size of each timestep (90 s) g: Gravitational accelleration (9.81 m/s^2) """ + + 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, context, h0, hu0, hv0,