[Mesa-dev] [PATCH 8/8] clover/llvm: Make __OPENCL_VERSION__ dynamic

Aaron Watry awatry at gmail.com
Thu Aug 10 03:36:44 UTC 2017


On Fri, Aug 4, 2017 at 1:43 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> On Sun, 2017-07-30 at 20:26 -0500, Aaron Watry wrote:
>> Signed-off-by: Aaron Watry <awatry at gmail.com>
>> CC: Jan Vesely <jan.vesely at rutgers.edu>
>>
>> v2: base it on the device version
>> ---
>>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> index 63b2961752..443cd31e66 100644
>> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
>> @@ -224,7 +224,8 @@ namespace {
>>        c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
>>
>>        // Add definition for the OpenCL version
>> -      c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=110");
>> +      c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=" +
>> +              std::to_string(get_language_from_version_str(dev.device_version())));
>
> I don't think you can use the same parsing function here.
> __OPENCL_VERSION__ can go up to 2.2, while __OPENCL_C_VERSION__ is max
> 2.0

Is that an issue here? I thought that the device's highest supported
OpenCL version was what was required here?

__OPENCL_VERSION__ is defined as "substitutes an integer reflecting
the version number of the OpenCL
supported by the OpenCL device", which in this case should map
directly to dev.device_version().

__OPENCL_C_VERSION__ is already added by clang when the pre-processor
is initialized using the selected language version
(clang/FrontEnd/InitPreprocessor.cpp).

--Aaron

>
> Jan
>
>>
>>        // clc.h requires that this macro be defined:
>>        c.getPreprocessorOpts().addMacroDef("cl_clang_storage_class_specifiers");


More information about the mesa-dev mailing list