From: Dave Airlie Date: Tue, 10 Nov 2020 05:08:46 +0000 (+1000) Subject: clover: add support for opencl C features X-Git-Tag: upstream/21.0.0~2725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a512c34d2fb933a51cd22613833b456c402755b;p=platform%2Fupstream%2Fmesa.git clover: add support for opencl C features This adds support to the compiler and api for this CL 3.0 feature. fixes CTS compiler features_macro Reviewed-by: Karol Herbst Part-of: --- diff --git a/src/gallium/frontends/clover/api/device.cpp b/src/gallium/frontends/clover/api/device.cpp index d5204d3..9ed873d 100644 --- a/src/gallium/frontends/clover/api/device.cpp +++ b/src/gallium/frontends/clover/api/device.cpp @@ -421,6 +421,10 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param, buf.as_vector() = dev.supported_extensions(); break; + case CL_DEVICE_OPENCL_C_FEATURES: + buf.as_vector() = dev.opencl_c_features(); + break; + default: throw error(CL_INVALID_VALUE); } diff --git a/src/gallium/frontends/clover/core/device.cpp b/src/gallium/frontends/clover/core/device.cpp index 4db593c..76b61a1 100644 --- a/src/gallium/frontends/clover/core/device.cpp +++ b/src/gallium/frontends/clover/core/device.cpp @@ -409,3 +409,14 @@ device::opencl_c_all_versions() const { } return vec; } + +std::vector +device::opencl_c_features() const { + std::vector vec; + + vec.push_back( (cl_name_version) {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_int64" }); + if (has_doubles()) + vec.push_back( (cl_name_version) {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_fp64" }); + + return vec; +} diff --git a/src/gallium/frontends/clover/core/device.hpp b/src/gallium/frontends/clover/core/device.hpp index 81687b5..bc57c8d 100644 --- a/src/gallium/frontends/clover/core/device.hpp +++ b/src/gallium/frontends/clover/core/device.hpp @@ -96,6 +96,8 @@ namespace clover { std::vector opencl_c_all_versions() const; std::vector supported_extensions() const; + std::vector opencl_c_features() const; + friend class command_queue; friend class root_resource; friend class hard_event; diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp index 413db85..ef0c31c 100644 --- a/src/gallium/frontends/clover/llvm/invocation.cpp +++ b/src/gallium/frontends/clover/llvm/invocation.cpp @@ -291,6 +291,12 @@ namespace { std::to_string(CL_VERSION_MAJOR_KHR(dev_version)) + std::to_string(CL_VERSION_MINOR_KHR(dev_version)) + "0"); + if (CL_VERSION_MAJOR(dev.version) >= 3) { + const auto features = dev.opencl_c_features(); + for (const auto &feature : features) + c.getPreprocessorOpts().addMacroDef(feature.name); + } + // clc.h requires that this macro be defined: c.getPreprocessorOpts().addMacroDef("cl_clang_storage_class_specifiers"); c.getPreprocessorOpts().addRemappedFile(