Skip to content

[SYCL] Isolate OpenCL types and enums #6261

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 6 commits into from
Jun 8, 2022

Conversation

jchlanda
Copy link
Contributor

@jchlanda jchlanda commented Jun 7, 2022

This PR populates PI enums and typedefs with values taken from the OpenCL equivalents; it also makes sure that all uses of the system OpenCL header cl.h are channelled through include/CL/sycl/detail/cl.h. Finally, pi.h and pi.hpp would only tap into the system cl.h for OpenCL backend (guarded by PI_OPENCL_AVAILABLE compiler definition), which allowed a removal of all OpenCL types and enums from other PI backends.

Fixes: #1265

@jchlanda jchlanda requested review from a team as code owners June 7, 2022 07:48
@jchlanda jchlanda requested a review from smaslov-intel June 7, 2022 07:48
kbobrovs
kbobrovs previously approved these changes Jun 7, 2022
Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp LGTM

bader
bader previously approved these changes Jun 7, 2022
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

Thanks a lot for doing this clean-up!
Finally! 🥳 🎉

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

@jchlanda jchlanda dismissed stale reviews from bader and kbobrovs via 0702e62 June 7, 2022 12:26
@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 7, 2022

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59
It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

@smaslov-intel
Copy link
Contributor

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59 It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

I really think we should completely untie PI enums from OpenCL, not only drop use of OpenCL names, see #6261 (comment)

@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 7, 2022

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59 It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

I really think we should completely untie PI enums from OpenCL, not only drop use of OpenCL names, see #6261 (comment)

I don't share that view, there is no hiding away from the fact that PI's interface is a direct copy of OpenCL's (albeit extended in places), coming up with a different values for effectively exactly the same enums (semantically) only to translate them back to OpenCL (even in one backend) doesn't seem like a task worth doing.

@smaslov-intel
Copy link
Contributor

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59 It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

I really think we should completely untie PI enums from OpenCL, not only drop use of OpenCL names, see #6261 (comment)

I don't share that view, there is no hiding away from the fact that PI's interface is a direct copy of OpenCL's (albeit extended in places), coming up with a different values for effectively exactly the same enums (semantically) only to translate them back to OpenCL (even in one backend) doesn't seem like a task worth doing.

This is not to "hide away" the fact that the PI is borrowing OpenCL model, but to:

  1. Continue to be able to track the semantics of specific PI values (from seeing what OpenCL codes do they map to in OpenCL plugin)
  2. Ensure that PI extensions aren't clashing with existing OpenCL codes.

bader
bader previously approved these changes Jun 7, 2022
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 8, 2022

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59 It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

I really think we should completely untie PI enums from OpenCL, not only drop use of OpenCL names, see #6261 (comment)

I don't share that view, there is no hiding away from the fact that PI's interface is a direct copy of OpenCL's (albeit extended in places), coming up with a different values for effectively exactly the same enums (semantically) only to translate them back to OpenCL (even in one backend) doesn't seem like a task worth doing.

This is not to "hide away" the fact that the PI is borrowing OpenCL model, but to:

1. Continue to be able to track the semantics of specific PI values (from seeing what OpenCL codes do they map to in OpenCL plugin)

2. Ensure that PI extensions aren't clashing with existing OpenCL codes.

I understand your point now, thank you. I'm not sure if I agree though :) seems like every time OpenCL's cl.h changes it will require a review of the code in either approach, to update the mapping or to the values; given how many enums are there and the fact that some of them are used as bitfields the untying would require non-trivial amount of effort for a marginal gain.
I feel like there is value in this PR going in, so perhaps a way forward would be to create a future task, if you think it's necessary to do?

@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 8, 2022

/verify with intel/llvm-test-suite#1048

@smaslov-intel
Copy link
Contributor

Overall I think the changes look good. I would however like if we could have some comments for the various enums specifying where the enum values come from. That should hopefully help prevent people from adding values in the future that conflict with missing and future OpenCL enum values.

I agree that it might be more dangerous to tinker with the enums now, would you be ok with a note in the file, something along the lines of this: https://github.com/jchlanda/llvm/blob/jakub/opencl_headers/sycl/include/CL/sycl/detail/pi.h#L59 It feels like putting a comment for every enum mapping to OpenCL (of which there are plenty) would just include a lot of noise.

I really think we should completely untie PI enums from OpenCL, not only drop use of OpenCL names, see #6261 (comment)

I don't share that view, there is no hiding away from the fact that PI's interface is a direct copy of OpenCL's (albeit extended in places), coming up with a different values for effectively exactly the same enums (semantically) only to translate them back to OpenCL (even in one backend) doesn't seem like a task worth doing.

This is not to "hide away" the fact that the PI is borrowing OpenCL model, but to:

1. Continue to be able to track the semantics of specific PI values (from seeing what OpenCL codes do they map to in OpenCL plugin)

2. Ensure that PI extensions aren't clashing with existing OpenCL codes.

I understand your point now, thank you. I'm not sure if I agree though :) seems like every time OpenCL's cl.h changes it will require a review of the code in either approach, to update the mapping or to the values; given how many enums are there and the fact that some of them are used as bitfields the untying would require non-trivial amount of effort for a marginal gain. I feel like there is value in this PR going in, so perhaps a way forward would be to create a future task, if you think it's necessary to do?

I agree there is value in this PR as it is, but please retain the comment

// TODO: we need a mapping of PI to OpenCL somewhere, and this can be done
rephrasing it to reflect current state.

@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 8, 2022

Done in: e948928

@jchlanda
Copy link
Contributor Author

jchlanda commented Jun 8, 2022

The failures should be addressed by intel/llvm-test-suite#1048, seems like the /verify with didn't do the trick.

Copy link
Contributor

@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@jchlanda jchlanda requested a review from bader June 8, 2022 15:10
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

The failures should be addressed by intel/llvm-test-suite#1048, seems like the /verify with didn't do the trick.

It did - I see the tests pass.

@bader bader merged commit 3fcf848 into intel:sycl Jun 8, 2022
@@ -420,6 +423,16 @@ template <class To, class From> inline To cast(From value) {
return (To)(value);
}

template <class To, class From> inline To cast(std::vector<From> value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@jchlanda, post-commit failed with:

/home/runner/work/llvm/llvm/src/sycl/include/CL/sycl/detail/pi.hpp:426:66: error: unused parameter 'value' [-Werror,-Wunused-parameter]
template <class To, class From> inline To cast(std::vector<From> value) {

Could you fix this, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad sorry, should be fixed in: #6276

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem. Thanks for contributions!

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.

[SYCL][CUDA] Remove opencl-headers dependency from pi-cuda.h
5 participants