[PATCH] D77923: OpenCL: Fix some missing predefined macros
Jan Vesely via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 13 16:52:56 PDT 2020
jvesely added a comment.
> In D77923#1976497 <https://reviews.llvm.org/D77923#1976497>, @jvesely wrote:
>
>> OPENCL_VERSION is something that should be really set by the opencl driver rather than the compiler.
>> coarse-grained SVM can be done without FEATURE_FLAT_ADDRESS_SPACE, so those gpus can get over 1.2, while the compiler can be used in an implementation that doesn't go above 1.2 even for gfx700+
>
>
> I don't know why this would imply we can't just have a static `__OPENCL_VERSION__` for each device in Clang? I don't see anything in the standard that says you are not allowed to have (going with your example) `__OPENCL_VERSION__=200` and `__OPENCL_C_VERSION=120` at the same time.
>
> It seems like we should be able to just have `__OPENCL_VERSION__` defined in Clang, and let the runtime control setting `__OPENCL_C_VERSION__` via `-cl-std=`. If the current patch sets `__OPENCL_VERSION__` differently than the runtime does then it seems like we should make it match, but I'm not sure how best to confirm that.
The `__OPENCL_VERSION__` macro in the kernel needs to match the version returned by `clGetDeviceInfo` (both refer to OpenCL version supported by the device),
which in turn must be <= version returned by `clGetPlatformInfo`.
This part makes it unsuitable for hardcoding in the compiler.
`__OPENCL_VERSION__` should indicate device capabilities rather than language features. specs talk about available resources.
For example, `CL_DEVICE_IMAGE2D_MAX_HEIGHT` is required to be >= 8192 for OpenCL 1.2 while it's required to be >=16384 for OpenCL 2.1.
if there's to be a default value hardcoded in the compiler it'd be nice if platform drivers had an easy way to override (lower) it.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77923/new/
https://reviews.llvm.org/D77923
More information about the cfe-commits
mailing list