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

Add support for CL_HPP_OPENCL_API_WRAPPER macro #314

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

steffen-kiess
Copy link
Contributor

Add support for a macro CL_HPP_OPENCL_API_WRAPPER which will be used to wrap all OpenCL API calls.This can be used e.g. to load the OpenCL library dynamically with dlopen()/dlsym().

This is similar to #170, but uses a macro which is called with the API function name instead of a namespace. This macro can e.g. call a function which will open the OpenCL library if needed, look up the function name and return a pointer to API function.

Comment on lines 404 to 405
#define _CL(name) ::name
#define _CL_PTR(name) &::name
Copy link
Contributor

@bashbaug bashbaug Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both _CL and _CL_PTR? I can't figure out why _CL_PTR is needed, and it seems like we could use _CL in all cases.

If we do need _CL_PTR for some reason, should there be a separate wrapper macro for it as well? I'd prefer not to do this, and would much rather eliminate _CL_PTR, but we should stay symmetric regardless.

One final nit: identifiers beginning with an underscore and a capital letter are considered reserved IIRC, so although I appreciate the brevity we should use a different spelling than _CL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I was thinking that a & is needed when taking a function pointer, but I think that's only the case for pointer-to-members, not for normal function pointers, so using _CL everywhere should work fine, yes.

Also, I'll rename _CL to CL_ which is not reserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've updated the PR.

Add support for a macro CL_HPP_OPENCL_API_WRAPPER which will be used to
wrap all OpenCL API calls.This can be used e.g. to load the OpenCL
library dynamically with dlopen()/dlsym().
Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

Merging as discussed in the October 29th teleconference.

@bashbaug bashbaug merged commit a232f10 into KhronosGroup:main Oct 29, 2024
52 checks passed
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

Successfully merging this pull request may close these issues.

2 participants