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

Improve CudaInternalVar #16

Open
EmilyBourne opened this issue Apr 20, 2023 · 1 comment
Open

Improve CudaInternalVar #16

EmilyBourne opened this issue Apr 20, 2023 · 1 comment
Labels
internals Pyccel's internal behavior, does not affect user experience invalid This doesn't seem right

Comments

@EmilyBourne
Copy link
Member

The CudaInternalVar object is a class which describes a function which takes a literal integer as an argument and returns a cuda property in the requested dimension. E.g. the subclass CudaThreadIdx returns the 1st, 2nd or 3rd thread index. I think that this is a sub-optimal solution as the resulting code is quite different from the syntax that users may be familiar with. Furthermore the use of an argument will encourage users to pass variables instead of literals so we will need robust error messages to explain why this is not possible.

I therefore recommend replacing CudaInternalVar by a class type similar to:

CudaInternalVar = ClassDef('CudaInternalVar',
                           variables = [Variable('int', 'x'),
                                        Variable('int', 'y'),
                                        Variable('int', 'z')])

and replacing the subclasses by simple variables. E.g:

CudaThreadIdx = Variable(CudaInternalVar, 'CudaThreadIdx')

This would allow the user to write the code as:

from pyccel.cuda import CudaThreadIdx

print(CudaThreadIdx.x)
@EmilyBourne EmilyBourne added the internals Pyccel's internal behavior, does not affect user experience label Apr 20, 2023
@EmilyBourne EmilyBourne added the invalid This doesn't seem right label Jun 12, 2024
@EmilyBourne
Copy link
Member Author

Related to an old branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals Pyccel's internal behavior, does not affect user experience invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant