-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental Python cooperative algorithms (#1973)
* Python exposure of cooperative algorithms * Update inpect changes to be aware of pycudax. This is a bit more complex since this is the first subproject that doesn't live in a directory with the same name as the project. * Print working directory when running CI commands. * Update CI for pycudax. * Update module name in CI This reverts commit 058bb5f2725a70fa8b4cd8ff39b84e0c4c53c2b0. * [pre-commit.ci] auto code formatting * Remove accidental directory * Fix Thrust pair docs * Fix pkg resource usage --------- Co-authored-by: Allison Piper <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
deedb00
commit 6b95f43
Showing
43 changed files
with
3,156 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ CMakeUserPresets.json | |
/ci/rapids/.conda | ||
/ci/rapids/.log | ||
/ci/rapids/.repos | ||
*.egg-info/ | ||
*.pyc | ||
__pycache__ | ||
*.pyd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "$0")/build_common.sh" | ||
|
||
print_environment_details | ||
|
||
fail_if_no_gpu | ||
|
||
readonly prefix="${BUILD_DIR}/python/" | ||
export PYTHONPATH="${prefix}:${PYTHONPATH:-}" | ||
|
||
pushd ../python/cuda >/dev/null | ||
|
||
run_command "⚙️ Pip install cuda" pip install --force-reinstall --target "${prefix}" .[test] | ||
run_command "🚀 Pytest cuda" python -m pytest -v ./tests | ||
|
||
popd >/dev/null | ||
|
||
print_time_summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.. _pycudax-module: | ||
|
||
CUDA | ||
================================================== | ||
|
||
.. warning:: | ||
Python exposure of cooperative algorithms is in public beta. | ||
The API is subject to change without notice. | ||
|
||
.. automodule:: cuda.cooperative.experimental.warp | ||
:members: | ||
:undoc-members: | ||
:imported-members: | ||
|
||
|
||
.. automodule:: cuda.cooperative.experimental.block | ||
:members: | ||
:undoc-members: | ||
:imported-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cuda/_include | ||
env | ||
*egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include cuda/_include * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```bash | ||
pip3 install -e .[test] | ||
pytest -v ./tests/device/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
import cuda.cooperative.experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
from cuda.cooperative.experimental import block, warp | ||
from cuda.cooperative.experimental._types import StatefulFunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
import os | ||
import pickle | ||
import json | ||
import hashlib | ||
|
||
_ENABLE_CACHE = 'CCCL_ENABLE_CACHE' in os.environ | ||
if _ENABLE_CACHE: | ||
_CACHE_LOCATION = os.path.join(os.path.expanduser("~"), ".cache", "cccl") | ||
if not os.path.exists(_CACHE_LOCATION): | ||
os.makedirs(_CACHE_LOCATION) | ||
|
||
# We use | ||
# json.dumps to serialize args/kwargs to a string | ||
# hashlib to compute the hash | ||
def json_hash(*args, **kwargs): | ||
hasher = hashlib.sha1() | ||
hasher.update(json.dumps([args, kwargs]).encode('utf-8')) | ||
return hasher.hexdigest() | ||
|
||
def disk_cache(func): | ||
def cacher(*args, **kwargs): | ||
if _ENABLE_CACHE: | ||
# compute hash(args, kwargs) | ||
h = json_hash(*args, **kwargs) | ||
# if file exist... | ||
if os.path.isfile(os.path.join(_CACHE_LOCATION, h)): | ||
# open it | ||
with open(os.path.join(_CACHE_LOCATION, h), 'rb') as f: | ||
out = pickle.load(f) | ||
# return cache | ||
return out | ||
else: | ||
# compute output | ||
out = func(*args, **kwargs) | ||
# store to file | ||
with open(os.path.join(_CACHE_LOCATION, h), 'wb') as f: | ||
pickle.dump(out, f) | ||
return out | ||
else: | ||
return func(*args, **kwargs) | ||
|
||
return cacher |
Oops, something went wrong.