File tree Expand file tree Collapse file tree 4 files changed +22
-15
lines changed Expand file tree Collapse file tree 4 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 1+ from .hip import *
Original file line number Diff line number Diff line change 88
99from kernel_tuner .backends .backend import GPUBackend
1010from kernel_tuner .observers .hip import HipRuntimeObserver
11+ from kernel_tuner .backends .hip .util import hip_check
1112
1213try :
1314 from hip import hip , hiprtc
3132
3233hipSuccess = 0
3334
34-
35- def hip_check (call_result ):
36- """helper function to check return values of hip calls"""
37- err = call_result [0 ]
38- result = call_result [1 :]
39- if len (result ) == 1 :
40- result = result [0 ]
41- if isinstance (err , hip .hipError_t ) and err != hip .hipError_t .hipSuccess :
42- _ , error_name = hip .hipGetErrorName (err )
43- _ , error_str = hip .hipGetErrorString (err )
44- raise RuntimeError (f"{ error_name } : { error_str } " )
45- return result
46-
47-
4835class HipFunctions (GPUBackend ):
4936 """Class that groups the HIP functions on maintains state about the device."""
5037
Original file line number Diff line number Diff line change 1+ try :
2+ from hip import hip , hiprtc
3+ except (ImportError , RuntimeError ):
4+ hip = None
5+
6+
7+ def hip_check (call_result ):
8+ """helper function to check return values of hip calls"""
9+ err = call_result [0 ]
10+ result = call_result [1 :]
11+ if len (result ) == 1 :
12+ result = result [0 ]
13+ if isinstance (err , hip .hipError_t ) and err != hip .hipError_t .hipSuccess :
14+ _ , error_name = hip .hipGetErrorName (err )
15+ _ , error_str = hip .hipGetErrorString (err )
16+ raise RuntimeError (f"{ error_name } : { error_str } " )
17+ return result
18+
Original file line number Diff line number Diff line change 11import numpy as np
22
33from kernel_tuner .observers .observer import BenchmarkObserver
4+ from kernel_tuner .backends .hip .util import hip_check
45
56try :
67 from hip import hip , hiprtc
@@ -24,7 +25,7 @@ def __init__(self, dev):
2425
2526 def after_finish (self ):
2627 # Time is measured in milliseconds
27- EventElapsedTime = hip .hipEventElapsedTime (self .start , self .end )
28+ EventElapsedTime = hip_check ( hip .hipEventElapsedTime (self .start , self .end ) )
2829 self .times .append (EventElapsedTime )
2930
3031 def get_results (self ):
You can’t perform that action at this time.
0 commit comments