OpenCL.jl icon indicating copy to clipboard operation
OpenCL.jl copied to clipboard

Allow 64-bit buffer lengths

Open herzfeldd opened this issue 5 years ago • 5 comments

Fixes #183

herzfeldd avatar Mar 04 '20 22:03 herzfeldd

Seems like we need a size_t for this?

The unsigned integer type of the result of the sizeof operator. This is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS defined in clGetDeviceInfo is 32-bits and is a 64-bit unsigned integer if CL_DEVICE_ADDRESS_BITS is 64-bits.

https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clCreateBuffer.html

DO we already have this in OpenCL.jl?

SimonDanisch avatar Mar 04 '20 22:03 SimonDanisch

The underlying call to the C functions already use a Csize_t at src/api/opencl_1.0.0.jl#43.

The cast to either the original cl_uint or cl_long is not strictly necessary as Julia's ccall should do the cast to a Csize_t (I have verified that this is true).

However, unlike the spec that you quoted, Csize_t in the ccall does not depend on the value of :address_bits, but I am not sure this is necessary.

I am happy to replace this pull request with one that merely removes the reference to the original cl_uint or cl_ulong.

herzfeldd avatar Mar 04 '20 22:03 herzfeldd

Whatever you think is safe ;) Just trying to make sure we're not overlooking anything!

SimonDanisch avatar Mar 04 '20 22:03 SimonDanisch

To be consistent with the rest of the code in buffer.jl, I removed the explicit cast in its entirety.

The remainder of the functions (e.g., enqueue_copy_buffer, enqueue_map_mem) use the result sizeof(buffer) and then allow the underlying api to cast the result as a Csize_t.

herzfeldd avatar Mar 05 '20 13:03 herzfeldd

I'm not sure where everyone has landed on this, but loading an array into buffer memory with a size that exceeds typemax(UInt32) bytes does not appear to work.

Technically it can be done with the suggested modification: cl_ulong(nbytes), however reading the data back onto the host will show that much of the data has been erroneously zeroed out.

ericproffitt avatar Dec 15 '21 18:12 ericproffitt

Closing as too old

juliohm avatar Oct 05 '22 22:10 juliohm