Skip to content

Commit 343413f

Browse files
fix issue #332
1 parent 5a48c0b commit 343413f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

kernel_tuner/observers/hip.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
hiprtc = None
1010

1111

12+
def hip_check(call_result):
13+
"""helper function to check return values of hip calls"""
14+
err = call_result[0]
15+
result = call_result[1:]
16+
if len(result) == 1:
17+
result = result[0]
18+
if isinstance(err, hip.hipError_t) and err != hip.hipError_t.hipSuccess:
19+
_, error_name = hip.hipGetErrorName(err)
20+
_, error_str = hip.hipGetErrorString(err)
21+
raise RuntimeError(f"{error_name}: {error_str}")
22+
return result
23+
24+
1225
class HipRuntimeObserver(BenchmarkObserver):
1326
"""Observer that measures time using CUDA events during benchmarking."""
1427

@@ -24,7 +37,7 @@ def __init__(self, dev):
2437

2538
def after_finish(self):
2639
# Time is measured in milliseconds
27-
EventElapsedTime = hip.hipEventElapsedTime(self.start, self.end)
40+
EventElapsedTime = hip_check(hip.hipEventElapsedTime(self.start, self.end))
2841
self.times.append(EventElapsedTime)
2942

3043
def get_results(self):

0 commit comments

Comments
 (0)