Mesa (master): clover: add support for opencl C features

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 10 20:56:33 UTC 2020


Module: Mesa
Branch: master
Commit: 3a512c34d2fb933a51cd22613833b456c402755b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a512c34d2fb933a51cd22613833b456c402755b

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Nov 10 15:08:46 2020 +1000

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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>

---

 src/gallium/frontends/clover/api/device.cpp      |  4 ++++
 src/gallium/frontends/clover/core/device.cpp     | 11 +++++++++++
 src/gallium/frontends/clover/core/device.hpp     |  2 ++
 src/gallium/frontends/clover/llvm/invocation.cpp |  6 ++++++
 4 files changed, 23 insertions(+)

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(



More information about the mesa-commit mailing list