Skip to content

Commit

Permalink
Don't setup wg_info_cache in Kernel constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Oct 6, 2024
1 parent 5085bb3 commit 4c3dd3c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyopencl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ def kernel__setup(self, prg):
warn_about_arg_count_bug=None,
work_around_arg_count_bug=None, devs=self.context.devices)

self._wg_info_cache = {}
return self

def kernel_set_arg_types(self, arg_types):
Expand Down Expand Up @@ -856,14 +855,19 @@ def kernel_set_arg_types(self, arg_types):
devs=self.context.devices)

def kernel_get_work_group_info(self, param, device):
try:
wg_info_cache = self._wg_info_cache
except AttributeError:
wg_info_cache = self._wg_info_cache = {}

cache_key = (param, device.int_ptr)
try:
return self._wg_info_cache[cache_key]
return wg_info_cache[cache_key]
except KeyError:
pass

result = kernel_old_get_work_group_info(self, param, device)
self._wg_info_cache[cache_key] = result
wg_info_cache[cache_key] = result
return result

def kernel_set_args(self, *args, **kwargs):
Expand Down

0 comments on commit 4c3dd3c

Please sign in to comment.