Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where HIP backend fails due to invalid arguments type #216

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading