clover/device: store version in device at constructor.
authorDave Airlie <airlied@redhat.com>
Tue, 10 Nov 2020 00:03:47 +0000 (10:03 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 10 Nov 2020 20:08:19 +0000 (06:08 +1000)
This reads the env vars once and stores the value, and converts
to strings when needed

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7520>

src/gallium/frontends/clover/core/device.cpp
src/gallium/frontends/clover/core/device.hpp

index c055e5b..0179980 100644 (file)
@@ -49,6 +49,14 @@ namespace {
 
 device::device(clover::platform &platform, pipe_loader_device *ldev) :
    platform(platform), clc_cache(NULL), ldev(ldev) {
+   unsigned major = 1, minor = 1;
+   debug_get_version_option("CLOVER_DEVICE_VERSION_OVERRIDE", &major, &minor);
+   version = CL_MAKE_VERSION(major, minor, 0);
+
+   major = 1, minor = 1;
+   debug_get_version_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", &major, &minor);
+   clc_version = CL_MAKE_VERSION(major, minor, 0);
+
    pipe = pipe_loader_create_screen(ldev);
    if (pipe && pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
       if (supports_ir(PIPE_SHADER_IR_NATIVE))
@@ -313,16 +321,18 @@ device::endianness() const {
 
 std::string
 device::device_version_as_string() const {
-   static const std::string device_version =
-         debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1");
-   return device_version;
+   static const std::string version_string =
+      std::to_string(CL_VERSION_MAJOR(version)) + "." +
+      std::to_string(CL_VERSION_MINOR(version));
+   return version_string;
 }
 
 std::string
 device::device_clc_version_as_string() const {
-   static const std::string device_clc_version =
-         debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1");
-   return device_clc_version;
+   static const std::string version_string =
+      std::to_string(CL_VERSION_MAJOR(clc_version)) + "." +
+      std::to_string(CL_VERSION_MINOR(clc_version));
+   return version_string;
 }
 
 bool
index 6815e7a..85e01bf 100644 (file)
@@ -108,6 +108,8 @@ namespace clover {
 
       lazy<std::shared_ptr<nir_shader>> clc_nir;
       disk_cache *clc_cache;
+      cl_version version;
+      cl_version clc_version;
    private:
       pipe_screen *pipe;
       pipe_loader_device *ldev;