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

shared memory update #117

Merged
merged 4 commits into from
Nov 10, 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
22 changes: 10 additions & 12 deletions xobjects/context_cupy.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ def to_pointer_arg(self, offset, nbytes):


class KernelCupy(object):
def __init__(
self, function, description, block_size, context, shared_mem_size_bytes
):
def __init__(self, function, description, block_size, context,
shared_mem_size_bytes):

self.function = function
self.description = description
self.block_size = block_size
self.context = context
self.shared_mem_size_bytes = shared_mem_size_bytes
self.context = context

def to_function_arg(self, arg, value):
if arg.pointer:
Expand Down Expand Up @@ -671,7 +671,7 @@ def to_function_arg(self, arg, value):
def num_args(self):
return len(self.description.args)

def __call__(self, **kwargs):
def __call__(self, shared_mem_size_bytes=None, **kwargs):
assert len(kwargs.keys()) == self.num_args
arg_list = []
for arg in self.description.args:
Expand All @@ -683,14 +683,12 @@ def __call__(self, **kwargs):
else:
n_threads = self.description.n_threads

grid_size = int(np.ceil(n_threads / self.block_size))
self.function(
(grid_size,),
(self.block_size,),
arg_list,
shared_mem=self.shared_mem_size_bytes,
)
if shared_mem_size_bytes is None:
shared_mem_size_bytes = self.shared_mem_size_bytes

grid_size = int(np.ceil(n_threads / self.block_size))
self.function((grid_size,), (self.block_size,), arg_list,
shared_mem=shared_mem_size_bytes)

class FFTCupy(object):
def __init__(self, context, data, axes):
Expand Down
Loading