Skip to content

Commit

Permalink
Fix issue where HIP backend fails due to invalid arguments type (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnh authored Oct 3, 2023
1 parent 2d5bff2 commit 15036be
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions kernel_tuner/backends/hip.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,7 @@ def ready_argument_list(self, arguments):
data_ctypes = dtype_map[dtype_str](arg)
ctype_args.append(data_ctypes)

# Determine the types of the fields in the structure
field_types = [type(x) for x in ctype_args]
# Define a new ctypes structure with the inferred layout
class ArgListStructure(ctypes.Structure):
_fields_ = [(f'field{i}', t) for i, t in enumerate(field_types)]
def __getitem__(self, key):
return getattr(self, self._fields_[key][0])

return ArgListStructure(*ctype_args)
return ctype_args


def compile(self, kernel_instance):
Expand Down Expand Up @@ -219,12 +211,23 @@ def run_kernel(self, func, gpu_args, threads, grid, stream=None):
if stream is None:
stream = self.stream

# Determine the types of the fields in the structure
field_types = [type(x) for x in gpu_args]

# Define a new ctypes structure with the inferred layout
class ArgListStructure(ctypes.Structure):
_fields_ = [(f'field{i}', t) for i, t in enumerate(field_types)]
def __getitem__(self, key):
return getattr(self, self._fields_[key][0])

ctype_args = ArgListStructure(*gpu_args)

hip.hipModuleLaunchKernel(func,
grid[0], grid[1], grid[2],
threads[0], threads[1], threads[2],
self.smem_size,
stream,
gpu_args)
ctype_args)

def memset(self, allocation, value, size):
"""set the memory in allocation to the value in value
Expand Down

0 comments on commit 15036be

Please sign in to comment.