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

Including CUDA header files in generated code #30

Closed
isazi opened this issue Nov 13, 2017 · 2 comments
Closed

Including CUDA header files in generated code #30

isazi opened this issue Nov 13, 2017 · 2 comments

Comments

@isazi
Copy link
Collaborator

isazi commented Nov 13, 2017

I was trying the generator system with some vector operations. In OpenCL the operators on vector types are part of the language, so no issue there, but to use them in CUDA I need to include "helper_math.h".
However, in cuda.py the whole generated code is wrapped in "extern C", and this generates a plethora of naming errors with this specific header file.
To make everything work I set no_extern_c to True in cuda.py, and added an "extern C" statement only around the kernel. This solution would require the user, to my understanding, to use "extern C" for every kernel, breaking compatibility with current code and making everything more cumbersome.

@isazi
Copy link
Collaborator Author

isazi commented Nov 13, 2017

Forcing the user to pay attention to this is, actually, the best idea, as it is already the case for the manually written code.
No change necessary for the source code, thus I close this issue.

@isazi isazi closed this as completed Nov 13, 2017
@benvanwerkhoven
Copy link
Collaborator

Yeah if you explicitly give your kernel extern "C" linkage, then cuda.py will detect that and set no_extern_c to True for you. But indeed, apart from looking for whether there is a substring containing 'extern "C"' I believe there isn't too much we can do. Well, it may be better to not play the guessing game and (unlike pycuda) not wrap it all in extern "C", it's just a little bit more user-friendly for small kernels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants