-
Notifications
You must be signed in to change notification settings - Fork 57
Allow External Code to Use Coorperative Group #240
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c33fa82
Add cooperative attr to codelib
isVoid 3087f1f
Merge branch 'main' of github.com:NVIDIA/numba-cuda into fea-extern-cg
isVoid c524f77
make sure that declare_device can specify use of cooperative launch a…
isVoid 03b43f6
update declare device usage and fix type
isVoid bad3f85
add external coop k launch example
isVoid b0776d2
avoid searching the ptx to determine if cooperative launch is needed
isVoid 65de740
Merge branch 'main' into fea-extern-cg
isVoid 8d53871
Apply suggestions from code review
isVoid 2efcc47
Improve cooperative launch test link usage{
isVoid 8e9c0f7
persist `use_cooperative` for codelib
isVoid fab0cb7
create a separate cg test group to avoid vending run_in_separate_process
isVoid f9fe394
Update numba_cuda/numba/cuda/tests/cudapy/test_caching.py
isVoid 400cbda
Merge branch 'main' into fea-extern-cg
isVoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,33 @@ | ||
| from numba import cuda | ||
| from numba.cuda.testing import CUDATestCase | ||
| import sys | ||
|
|
||
| from numba.cuda.tests.cudapy.cache_usecases import CUDAUseCase | ||
|
|
||
|
|
||
| # Usecase with cooperative groups | ||
|
|
||
|
|
||
| @cuda.jit(cache=True) | ||
| def cg_usecase_kernel(r, x): | ||
| grid = cuda.cg.this_grid() | ||
| grid.sync() | ||
|
|
||
|
|
||
| cg_usecase = CUDAUseCase(cg_usecase_kernel) | ||
|
|
||
|
|
||
| class _TestModule(CUDATestCase): | ||
| """ | ||
| Tests for functionality of this module's functions. | ||
| Note this does not define any "test_*" method, instead check_module() | ||
| should be called by hand. | ||
| """ | ||
|
|
||
| def check_module(self, mod): | ||
| mod.cg_usecase(0) | ||
|
|
||
|
|
||
| def self_test(): | ||
| mod = sys.modules[__name__] | ||
| _TestModule().check_module(mod) |
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| #include <cooperative_groups.h> | ||
| #include <cuda/barrier> | ||
|
|
||
| namespace cg = cooperative_groups; | ||
|
|
||
| __device__ void _wait_on_tile(cuda::barrier<cuda::thread_scope_block> &tile) | ||
| { | ||
| auto token = tile.arrive(); | ||
| tile.wait(std::move(token)); | ||
| } | ||
|
|
||
| extern "C" | ||
| __device__ int cta_barrier(int *ret) { | ||
| auto cta = cg::this_thread_block(); | ||
| cg::thread_block_tile<32> tile = cg::tiled_partition<32>(cta); | ||
| __shared__ cuda::barrier<cuda::thread_scope_block> barrier; | ||
| if (threadIdx.x == 0) { | ||
| init(&barrier, blockDim.x); | ||
| } | ||
|
|
||
| _wait_on_tile(barrier); | ||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.