summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-11-10 15:08:46 +1000
committerDave Airlie <airlied@redhat.com>2020-11-11 06:30:26 +1000
commit3a512c34d2fb933a51cd22613833b456c402755b (patch)
treef3c5c276c1f71a99dcc8f2cb1ff95451a11f85f4
parentf1b91177fbdc97289e9ddefa8db4b18fdc88f8f0 (diff)
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 <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>
-rw-r--r--src/gallium/frontends/clover/api/device.cpp4
-rw-r--r--src/gallium/frontends/clover/core/device.cpp11
-rw-r--r--src/gallium/frontends/clover/core/device.hpp2
-rw-r--r--src/gallium/frontends/clover/llvm/invocation.cpp6
4 files changed, 23 insertions, 0 deletions
diff --git a/src/gallium/frontends/clover/api/device.cpp b/src/gallium/frontends/clover/api/device.cpp
index d5204d35c69..9ed873d6186 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<cl_name_version>() = dev.supported_extensions();
break;
+ case CL_DEVICE_OPENCL_C_FEATURES:
+ buf.as_vector<cl_name_version>() = 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 4db593cd60e..76b61a1b8f5 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<cl_name_version>
+device::opencl_c_features() const {
+ std::vector<cl_name_version> 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 81687b5781e..bc57c8d8197 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<cl_name_version> opencl_c_all_versions() const;
std::vector<cl_name_version> supported_extensions() const;
+ std::vector<cl_name_version> 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 413db852ab5..ef0c31cdac5 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(