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

Portability when the host and device have different endianness #282

Open
chatcannon opened this issue Mar 16, 2019 · 2 comments
Open

Portability when the host and device have different endianness #282

chatcannon opened this issue Mar 16, 2019 · 2 comments

Comments

@chatcannon
Copy link

I was looking in the PyOpenCL source to see if I could find some example code of how to handle this correctly. However, as far as I can tell PyOpenCL allows querying the device endianness with Device.endian_little but does not use this information anywhere else. Is this correct or have I missed something?

If I am right and PyOpenCL doesn't do anything about endianness differences, is this because:

  • OpenCL says that handling endianness is the responsibility of the user, and PyOpenCL is deliberately keeping the same semantics?
  • In practice, devices always have the same endianness as the host, so there is no need for endianness correction?
  • Lack of time / interested people to implement this? (I could potentially contribute here)
  • Some other reason?

NumPy seems to be pretty good at handling arrays with non-native endianness, so hopefully this should be less effort to implement for PyOpenCL then it would be at the C level.

@inducer
Copy link
Owner

inducer commented Mar 16, 2019

Thanks for your report. You're right--PyOpenCL doesn't currently try to do anything about different endian-ness between host and device. I'm not sure I even understand all the concerns.

  • Matching endianness of pyopencl.array.Array when converting to numpy seems like a correctness thing that would likely be pretty easy to accomplish.
  • How is kernel parameter passing affected? If you pass a 32-bit integer, with which endianness is it supposed to go into clSetKernelArg?

In each case, I'd be happy to receive patch, though I'll admit I only have same-endian devices to test with.

@chatcannon
Copy link
Author

I also noticed the possibility of setting __attribute__((endian(host))) in the kernel, so maybe this is less important than I thought. However, I also noticed that cltypes doesn't include types for the pyopencl cfloat_t so I will try adding that.

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