-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Hello, and thanks for this amazing project.
We are seeing Halide errors on some devices. They seem to originate from Halide's OpenCL call to clCreateSubBuffer:
Line 1156 in 33d5ba9
| mem = clCreateSubBuffer(mem, CL_MEM_READ_WRITE, CL_BUFFER_CREATE_TYPE_REGION, ®ion, &err); |
With CL_MISALIGNED_SUB_BUFFER_OFFSET being returned from here. This error code is described as follows from clCreateSubBuffer:
CL_MISALIGNED_SUB_BUFFER_OFFSET if there are no devices in context associated with buffer for which the origin field of the cl_buffer_region structure passed in buffer_create_info is aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value.
With the mentioned origin field being set from the Halide buffer's own offset.
In particular, we have seen this error on the Intel OpenCL CPU runtime and on AMD GPUs. On the other hand, NVidia and Intel GPUs in particular do not seem to report the misalignment error, as far as we have seen.
We have observed that the call to clCreateSubBuffer from Halide does seem to violate this condition occasionally on all devices, even though only some of them report OpenCL errors as a result. As an example, we can see an offset of 321984 bytes (aligned to 64 bytes), with a required device alignment of 128 bytes. So it seems that the driver implementations diverge in how lenient they are on this condition, but Halide often violates it regardless.
Are there some steps that can be taken to prevent violating this alignment condition from the Halide side?