forked from pyccel/pyccel
-
Couldn't load subscription status.
- Fork 0
Feature: Improve Kernel Decorator #69
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
39 commits
Select commit
Hold shift + click to select a range
b9e5c94
Trigger tests on push to devel or main branch
EmilyBourne df24e81
Add cuda workflow to test cuda developments on CI
EmilyBourne 31d7247
Trigger tests on push to devel or main branch
EmilyBourne 17aa0e6
[init] Adding CUDA language/compiler and CodePrinter (#32)
bauom 2c58573
Fix import handling (#49)
smazouz42 0d154f8
Add support for kernels (#42)
smazouz42 2ffa7fc
Updated CUDA Name Clash Checker By Added CUDA-specific keywords (#60)
smazouz42 8eef19d
add handle for custom device (#61)
smazouz42 e5feffb
improve kernel decorator
smazouz42 2547f6e
addinf doc string to all CudaThreadIndexing fucntions
smazouz42 f80eed5
update CHANGELOG
smazouz42 6df004d
Add missing docstring for internal_loop in KernelAccessor class
smazouz42 048bd16
Add missing docstring for internal_loop in KernelAccessor class
smazouz42 738371a
update CHANGELOG
smazouz42 ec738b3
refactoring the code
smazouz42 aa76f91
refactoring the code
smazouz42 528099f
move CudaThreadIndexing to pyccel/cuda
smazouz42 f1f63ef
cleaning upmy PR
smazouz42 1aa26b1
add final new line
smazouz42 ea1beb7
add final new line
smazouz42 0f076a0
Make sure tests are passing
smazouz42 57f977e
refactoring the code
smazouz42 26fcdc0
adding missing import to device test
smazouz42 9f58f02
adding missing import to kernel
smazouz42 c45c615
refactoring the code
smazouz42 572cdd8
refactoring the code
smazouz42 d969ebb
update doc
smazouz42 2b3085f
update doc
smazouz42 34d801f
update doc
smazouz42 e9436a9
update doc
smazouz42 1aeb5a5
work in progress
smazouz42 654afa3
update docs
smazouz42 c5e1986
Merge branch 'devel' of https://github.com/pyccel/pyccel-cuda into is…
smazouz42 ded14a7
Add tests for both thread_ndx and block_ndx
smazouz42 ab33bd0
fix doc string
smazouz42 5c8fa2d
fix linting
smazouz42 f6a5792
fix linting
smazouz42 cd9ce2b
fix linting
smazouz42 ef09298
.
smazouz42 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #------------------------------------------------------------------------------------------# | ||
| # This file is part of Pyccel which is released under MIT License. See the LICENSE file or # | ||
| # go to https://github.com/pyccel/pyccel/blob/master/LICENSE for full license details. # | ||
| #------------------------------------------------------------------------------------------# | ||
| """ | ||
| This module contains all the CUDA thread indexing methods | ||
| """ | ||
| class CudaThreadIndexing: | ||
| """ | ||
| Class representing the CUDA thread indexing. | ||
|
|
||
| Class representing the CUDA thread indexing. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| block_idx : int | ||
| The index of the block in the x-dimension. | ||
|
|
||
| thread_idx : int | ||
| The index of the thread in the x-dimension. | ||
| """ | ||
| def __init__(self, block_idx, thread_idx): | ||
| self._block_idx = block_idx | ||
| self._thread_idx = thread_idx | ||
|
|
||
| def threadIdx(self, dim): | ||
| """ | ||
| Get the thread index. | ||
|
|
||
| Get the thread index. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| dim : int | ||
| The dimension of the indexing. It can be: | ||
| - 0 for the x-dimension | ||
| - 1 for the y-dimension | ||
| - 2 for the z-dimension | ||
|
|
||
| Returns | ||
| ------- | ||
| int | ||
| The index of the thread in the specified dimension of its block. | ||
| """ | ||
| return self._thread_idx | ||
|
|
||
| def blockIdx(self, dim): | ||
| """ | ||
| Get the block index. | ||
|
|
||
| Get the block index. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| dim : int | ||
| The dimension of the indexing. It can be: | ||
| - 0 for the x-dimension | ||
| - 1 for the y-dimension | ||
| - 2 for the z-dimension | ||
|
|
||
| Returns | ||
| ------- | ||
| int | ||
| The index of the block in the specified dimension. | ||
| """ | ||
| return self._block_idx | ||
|
|
||
EmilyBourne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def blockDim(self, dim): | ||
| """ | ||
| Get the block dimension. | ||
|
|
||
| Get the block dimension. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| dim : int | ||
| The dimension of the indexing. It can be: | ||
| - 0 for the x-dimension | ||
| - 1 for the y-dimension | ||
| - 2 for the z-dimension | ||
|
|
||
| Returns | ||
| ------- | ||
| int | ||
| The size of the block in the specified dimension. | ||
| """ | ||
| return 0 | ||
EmilyBourne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
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,15 @@ | ||
| # pylint: disable=missing-function-docstring, missing-module-docstring | ||
| from pyccel.decorators import kernel | ||
| from pyccel import cuda | ||
|
|
||
| @kernel | ||
| def print_block(): | ||
| print(cuda.blockIdx(0)) # pylint: disable=no-member | ||
|
|
||
| def f(): | ||
| print_block[5,5]() | ||
| cuda.synchronize() | ||
|
|
||
| if __name__ == '__main__': | ||
| f() | ||
|
|
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,15 @@ | ||
| # pylint: disable=missing-function-docstring, missing-module-docstring | ||
| from pyccel.decorators import kernel | ||
| from pyccel import cuda | ||
|
|
||
| @kernel | ||
| def print_block(): | ||
| print(cuda.threadIdx(0)) # pylint: disable=no-member | ||
|
|
||
| def f(): | ||
| print_block[5,5]() | ||
| cuda.synchronize() | ||
|
|
||
| if __name__ == '__main__': | ||
| f() | ||
|
|
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
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.