Mesa (main): clover: only return CLC version as 1.2 (even for 3.0)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 10 21:57:27 UTC 2021


Module: Mesa
Branch: main
Commit: 7fb9e78d09af1ae3bb6fa3c805ca99e1108cd80f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fb9e78d09af1ae3bb6fa3c805ca99e1108cd80f

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Aug  9 13:24:34 2021 +1000

clover: only return CLC version as 1.2 (even for 3.0)

Fixes CTS compiler opencl_c_versions

Reviewed-by: Karol Herbst <kherbst at redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12286>

---

 src/gallium/frontends/clover/api/device.cpp  |  2 +-
 src/gallium/frontends/clover/core/device.cpp | 26 +++++++++++++++++++++++---
 src/gallium/frontends/clover/core/device.hpp |  2 +-
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/gallium/frontends/clover/api/device.cpp b/src/gallium/frontends/clover/api/device.cpp
index a80367d7404..2d1066f629b 100644
--- a/src/gallium/frontends/clover/api/device.cpp
+++ b/src/gallium/frontends/clover/api/device.cpp
@@ -429,7 +429,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
       break;
 
    case CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR:
-      buf.as_scalar<cl_version>() = dev.device_clc_version();
+      buf.as_scalar<cl_version>() = dev.device_clc_version(true);
       break;
 
    case CL_DEVICE_OPENCL_C_ALL_VERSIONS:
diff --git a/src/gallium/frontends/clover/core/device.cpp b/src/gallium/frontends/clover/core/device.cpp
index d9bd2d00f04..7ef66d50492 100644
--- a/src/gallium/frontends/clover/core/device.cpp
+++ b/src/gallium/frontends/clover/core/device.cpp
@@ -440,9 +440,17 @@ device::device_version_as_string() const {
 
 std::string
 device::device_clc_version_as_string() const {
+   int major = CL_VERSION_MAJOR(clc_version);
+   int minor = CL_VERSION_MINOR(clc_version);
+
+   /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
+   if (major == 3) {
+      major = 1;
+      minor = 2;
+   }
    static const std::string version_string =
-      std::to_string(CL_VERSION_MAJOR(clc_version)) + "." +
-      std::to_string(CL_VERSION_MINOR(clc_version));
+      std::to_string(major) + "." +
+      std::to_string(minor);
    return version_string;
 }
 
@@ -510,7 +518,19 @@ device::device_version() const {
 }
 
 cl_version
-device::device_clc_version() const {
+device::device_clc_version(bool api) const {
+   /*
+    * For the API we have to limit this to 1.2,
+    * but internally we want 3.0 if it works.
+    */
+   if (!api)
+      return clc_version;
+
+   int major = CL_VERSION_MAJOR(clc_version);
+   /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
+   if (major == 3) {
+      return CL_MAKE_VERSION(1, 2, 0);
+   }
    return clc_version;
 }
 
diff --git a/src/gallium/frontends/clover/core/device.hpp b/src/gallium/frontends/clover/core/device.hpp
index 970538c0467..311d0c97e94 100644
--- a/src/gallium/frontends/clover/core/device.hpp
+++ b/src/gallium/frontends/clover/core/device.hpp
@@ -95,7 +95,7 @@ namespace clover {
       bool supports_ir(enum pipe_shader_ir ir) const;
       std::string supported_extensions_as_string() const;
       cl_version device_version() const;
-      cl_version device_clc_version() const;
+      cl_version device_clc_version(bool api = false) const;
       std::vector<cl_name_version> opencl_c_all_versions() const;
       std::vector<cl_name_version> supported_extensions() const;
       std::vector<cl_name_version> supported_il_versions() const;



More information about the mesa-commit mailing list