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

Cuda and cuda-with-dask support for inspection reductions #1219

Merged
merged 6 commits into from
May 24, 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
14 changes: 11 additions & 3 deletions datashader/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xarray as xr

from .reductions import by, category_codes, summary, where
from .utils import ngjit
from .utils import isnull, ngjit

try:
from datashader.transfer_functions._cuda_utils import cuda_mutex_lock, cuda_mutex_unlock
Expand Down Expand Up @@ -172,6 +172,9 @@ def make_append(bases, cols, calls, glyph, categorical, antialias):
names = ('_{0}'.format(i) for i in count())
inputs = list(bases) + list(cols)
namespace = {}
need_isnull = any(call[3] for call in calls)
if need_isnull:
namespace["isnull"] = isnull
any_uses_cuda_mutex = any(call[6] for call in calls)
if any_uses_cuda_mutex:
# This adds an argument to the append() function that is the cuda mutex
Expand Down Expand Up @@ -234,7 +237,7 @@ def make_append(bases, cols, calls, glyph, categorical, antialias):
else:
var = f"{arg_lk[nan_check_column]}[{subscript}]"
prev_body = body[-1]
body[-1] = f'if {var}<=0 or {var}>0:' # Inline CUDA-friendly 'is not nan' test
body[-1] = f'if not isnull({var}):'
body.append(f' {prev_body}')
whitespace = ' '

Expand All @@ -243,7 +246,12 @@ def make_append(bases, cols, calls, glyph, categorical, antialias):
else:
if uses_cuda_mutex and not prev_cuda_mutex:
body.append(f'cuda_mutex_lock({arg_lk["_cuda_mutex"]}, (y, x))')
body.append(f'{func_name}(x, y, {", ".join(args)})')
if nan_check_column:
var = f"{arg_lk[nan_check_column]}[{subscript}]"
body.append(f'if not isnull({var}):')
body.append(f' {func_name}(x, y, {", ".join(args)})')
else:
body.append(f'{func_name}(x, y, {", ".join(args)})')

if uses_cuda_mutex:
body.append(f'cuda_mutex_unlock({arg_lk["_cuda_mutex"]}, (y, x))')
Expand Down
Loading