forked from pyccel/pyccel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request addresses issue #41 by implementing a new feature in Pyccel that allows users to define a custom device **Commit Summary** - Adding handler for custom device and its code generation. - Adding test --------- Co-authored-by: EmilyBourne <[email protected]>
- Loading branch information
1 parent
45c013e
commit f6ac853
Showing
9 changed files
with
112 additions
and
6 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
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
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,31 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring | ||
import pytest | ||
|
||
from pyccel import epyccel | ||
from pyccel.decorators import device | ||
from pyccel.errors.errors import Errors, PyccelSemanticError | ||
from pyccel.errors.messages import (INVAlID_DEVICE_CALL,) | ||
|
||
|
||
@pytest.mark.cuda | ||
def test_invalid_device_call(): | ||
def invalid_device_call(): | ||
@device | ||
def device_call(): | ||
pass | ||
def fake_kernel_call(): | ||
device_call() | ||
|
||
fake_kernel_call() | ||
|
||
errors = Errors() | ||
|
||
with pytest.raises(PyccelSemanticError): | ||
epyccel(invalid_device_call, language="cuda") | ||
|
||
assert errors.has_errors() | ||
|
||
assert errors.num_messages() == 1 | ||
|
||
error_info = [*errors.error_info_map.values()][0][0] | ||
assert INVAlID_DEVICE_CALL == error_info.message |
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,18 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring | ||
from pyccel.decorators import device, kernel | ||
from pyccel import cuda | ||
|
||
@device | ||
def device_call(): | ||
print("Hello from device") | ||
|
||
@kernel | ||
def kernel_call(): | ||
device_call() | ||
|
||
def f(): | ||
kernel_call[1,1]() | ||
cuda.synchronize() | ||
|
||
if __name__ == '__main__': | ||
f() |
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