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

Add cuda arg to _build_combine #1194

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions datashader/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def compile_components(agg, schema, glyph, *, antialias=False, cuda=False):
create = make_create(bases, dshapes, cuda)
info = make_info(cols)
append = make_append(bases, cols, calls, glyph, isinstance(agg, by), antialias)
combine = make_combine(bases, dshapes, temps, combine_temps, antialias)
combine = make_combine(bases, dshapes, temps, combine_temps, antialias, cuda)
finalize = make_finalize(bases, agg, schema, cuda)

return create, info, append, combine, finalize, antialias_stage_2
Expand Down Expand Up @@ -203,14 +203,14 @@ def make_append(bases, cols, calls, glyph, categorical, antialias):
return ngjit(namespace['append'])


def make_combine(bases, dshapes, temps, combine_temps, antialias):
def make_combine(bases, dshapes, temps, combine_temps, antialias, cuda):
arg_lk = dict((k, v) for (v, k) in enumerate(bases))

# where._combine() deals with combine of preceding reduction so exclude
# it from explicit combine calls.
base_is_where = [isinstance(b, where) for b in bases]
next_base_is_where = base_is_where[1:] + [False]
calls = [(None if n else b._build_combine(d, antialias), [arg_lk[i] for i in (b,) + t + ct])
calls = [(None if n else b._build_combine(d, antialias, cuda), [arg_lk[i] for i in (b,) + t + ct])
for (b, d, t, ct, n) in zip(bases, dshapes, temps, combine_temps, next_base_is_where)]

def combine(base_tuples):
Expand Down
14 changes: 7 additions & 7 deletions datashader/reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _build_append(self, dshape, schema, cuda, antialias, self_intersect):
else:
return self._append

def _build_combine(self, dshape, antialias):
def _build_combine(self, dshape, antialias, cuda):
return self._combine

def _build_finalize(self, dshape):
Expand Down Expand Up @@ -519,7 +519,7 @@ def _append_no_field_cuda(x, y, agg):
nb_cuda.atomic.add(agg, (y, x), 1)
return 0

def _build_combine(self, dshape, antialias):
def _build_combine(self, dshape, antialias, cuda):
if antialias:
return self._combine_antialias
else:
Expand Down Expand Up @@ -617,8 +617,8 @@ def _build_bases(self, cuda=False):
def _build_append(self, dshape, schema, cuda, antialias, self_intersect):
return self.reduction._build_append(dshape, schema, cuda, antialias, self_intersect)

def _build_combine(self, dshape, antialias):
return self.reduction._build_combine(dshape, antialias)
def _build_combine(self, dshape, antialias, cuda):
return self.reduction._build_combine(dshape, antialias, cuda)

def _build_finalize(self, dshape):
cats = list(self.categorizer.categories(dshape))
Expand Down Expand Up @@ -680,7 +680,7 @@ def _append_no_field_antialias(x, y, agg, aa_factor):
_append_cuda =_append
_append_no_field_cuda = _append_no_field

def _build_combine(self, dshape, antialias):
def _build_combine(self, dshape, antialias, cuda):
if antialias:
return self._combine_antialias
else:
Expand Down Expand Up @@ -1542,7 +1542,7 @@ def _build_append(self, dshape, schema, cuda, antialias, self_intersect):
def _build_bases(self, cuda=False):
return self.selector._build_bases(cuda=cuda) + super()._build_bases(cuda=cuda)

def _build_combine(self, dshape, antialias):
def _build_combine(self, dshape, antialias, cuda):
# Does not support categorical reductions.
selector = self.selector
append = selector._append
Expand Down Expand Up @@ -1593,7 +1593,7 @@ def wrapped_combine(aggs, selector_aggs):

if len(aggs) == 1:
pass
elif cp is not None and isinstance(aggs[0], cp.ndarray):
elif cuda:
combine_cuda_2d[cuda_args(aggs[0].shape)](aggs, selector_aggs)
else:
if aggs[0].ndim == 3:
Expand Down