[v3] clover: Allow overriding platform/device version numbers

Submitted by Aaron Watry on March 4, 2018, 3:13 p.m.

Details

Message ID 20180304151342.16539-1-awatry@gmail.com
State New
Headers show
Series "clover: Allow overriding platform/device version numbers" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Aaron Watry March 4, 2018, 3:13 p.m.
Useful for testing API, builtin library, and device completeness of
not-yet-supported versions.

Signed-off-by: Aaron Watry <awatry@gmail.com>
(v1) Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
(v2) Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Cc: Jan Vesely <jan.vesely@rutgers.edu>
Cc: Emil Velikov <emil.l.velikov@gmail.com>

v3: mark CL version overrides as static and const
v2: Make version_string in platform const in case
---
Emil, hopefully this is along the lines of what you wanted.

I believe that function-scoped static const variables are only evaluated/initialized once.

--Aaron

 src/gallium/state_trackers/clover/api/platform.cpp | 10 +++++++---
 src/gallium/state_trackers/clover/core/device.cpp  |  9 +++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
index ed86163311..23e524a630 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -23,6 +23,7 @@ 
 #include "api/util.hpp"
 #include "core/platform.hpp"
 #include "git_sha1.h"
+#include "util/u_debug.h"
 
 using namespace clover;
 
@@ -57,14 +58,17 @@  clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
       buf.as_string() = "FULL_PROFILE";
       break;
 
-   case CL_PLATFORM_VERSION:
-      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
+   case CL_PLATFORM_VERSION: {
+      static const std::string version_string = std::string(
+            debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1"));
+
+      buf.as_string() = "OpenCL " + version_string + " Mesa " PACKAGE_VERSION
 #ifdef MESA_GIT_SHA1
                         " (" MESA_GIT_SHA1 ")"
 #endif
                         ;
       break;
-
+   }
    case CL_PLATFORM_NAME:
       buf.as_string() = "Clover";
       break;
diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index 71cf4bf60a..b3a3903bcd 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -25,6 +25,7 @@ 
 #include "core/platform.hpp"
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
+#include "util/u_debug.h"
 
 using namespace clover;
 
@@ -268,10 +269,14 @@  device::endianness() const {
 
 std::string
 device::device_version() const {
-    return "1.1";
+   static const std::string device_version = std::string(
+         debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
+   return device_version;
 }
 
 std::string
 device::device_clc_version() const {
-    return "1.1";
+   static const std::string device_clc_version = std::string(
+         debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
+   return device_clc_version;
 }

Comments

On 4 March 2018 at 15:13, Aaron Watry <awatry@gmail.com> wrote:
> Useful for testing API, builtin library, and device completeness of
> not-yet-supported versions.
>
> Signed-off-by: Aaron Watry <awatry@gmail.com>
> (v1) Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
> (v2) Reviewed-by: Francisco Jerez <currojerez@riseup.net>
> Cc: Jan Vesely <jan.vesely@rutgers.edu>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>
> v3: mark CL version overrides as static and const
> v2: Make version_string in platform const in case
> ---
> Emil, hopefully this is along the lines of what you wanted.
>
> I believe that function-scoped static const variables are only evaluated/initialized once.
>
I believe so as well. FWIW patch is
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>

-Emil
Aaron Watry <awatry@gmail.com> writes:

> Useful for testing API, builtin library, and device completeness of
> not-yet-supported versions.
>
> Signed-off-by: Aaron Watry <awatry@gmail.com>
> (v1) Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
> (v2) Reviewed-by: Francisco Jerez <currojerez@riseup.net>
> Cc: Jan Vesely <jan.vesely@rutgers.edu>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>
> v3: mark CL version overrides as static and const
> v2: Make version_string in platform const in case
> ---
> Emil, hopefully this is along the lines of what you wanted.
>
> I believe that function-scoped static const variables are only evaluated/initialized once.
>
> --Aaron
>
>  src/gallium/state_trackers/clover/api/platform.cpp | 10 +++++++---
>  src/gallium/state_trackers/clover/core/device.cpp  |  9 +++++++--
>  2 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
> index ed86163311..23e524a630 100644
> --- a/src/gallium/state_trackers/clover/api/platform.cpp
> +++ b/src/gallium/state_trackers/clover/api/platform.cpp
> @@ -23,6 +23,7 @@
>  #include "api/util.hpp"
>  #include "core/platform.hpp"
>  #include "git_sha1.h"
> +#include "util/u_debug.h"
>  
>  using namespace clover;
>  
> @@ -57,14 +58,17 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>        buf.as_string() = "FULL_PROFILE";
>        break;
>  
> -   case CL_PLATFORM_VERSION:
> -      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
> +   case CL_PLATFORM_VERSION: {
> +      static const std::string version_string = std::string(

The std::string() conversions here and below are redundant, with them
removed:

Reviewed-by: Francisco Jerez <currojerez@riseup.net>

> +            debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1"));
> +
> +      buf.as_string() = "OpenCL " + version_string + " Mesa " PACKAGE_VERSION
>  #ifdef MESA_GIT_SHA1
>                          " (" MESA_GIT_SHA1 ")"
>  #endif
>                          ;
>        break;
> -
> +   }
>     case CL_PLATFORM_NAME:
>        buf.as_string() = "Clover";
>        break;
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index 71cf4bf60a..b3a3903bcd 100644
> --- a/src/gallium/state_trackers/clover/core/device.cpp
> +++ b/src/gallium/state_trackers/clover/core/device.cpp
> @@ -25,6 +25,7 @@
>  #include "core/platform.hpp"
>  #include "pipe/p_screen.h"
>  #include "pipe/p_state.h"
> +#include "util/u_debug.h"
>  
>  using namespace clover;
>  
> @@ -268,10 +269,14 @@ device::endianness() const {
>  
>  std::string
>  device::device_version() const {
> -    return "1.1";
> +   static const std::string device_version = std::string(
> +         debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
> +   return device_version;
>  }
>  
>  std::string
>  device::device_clc_version() const {
> -    return "1.1";
> +   static const std::string device_clc_version = std::string(
> +         debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
> +   return device_clc_version;
>  }
> -- 
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
With Francisco’s comments addressed,

Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>

On 2018-03-04 — 09:13, Aaron Watry wrote:
> Useful for testing API, builtin library, and device completeness of
> not-yet-supported versions.
> 
> Signed-off-by: Aaron Watry <awatry@gmail.com>
> (v1) Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
> (v2) Reviewed-by: Francisco Jerez <currojerez@riseup.net>
> Cc: Jan Vesely <jan.vesely@rutgers.edu>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> 
> v3: mark CL version overrides as static and const
> v2: Make version_string in platform const in case
> ---
> Emil, hopefully this is along the lines of what you wanted.
> 
> I believe that function-scoped static const variables are only evaluated/initialized once.
> 
> --Aaron
> 
>  src/gallium/state_trackers/clover/api/platform.cpp | 10 +++++++---
>  src/gallium/state_trackers/clover/core/device.cpp  |  9 +++++++--
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
> index ed86163311..23e524a630 100644
> --- a/src/gallium/state_trackers/clover/api/platform.cpp
> +++ b/src/gallium/state_trackers/clover/api/platform.cpp
> @@ -23,6 +23,7 @@
>  #include "api/util.hpp"
>  #include "core/platform.hpp"
>  #include "git_sha1.h"
> +#include "util/u_debug.h"
>  
>  using namespace clover;
>  
> @@ -57,14 +58,17 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>        buf.as_string() = "FULL_PROFILE";
>        break;
>  
> -   case CL_PLATFORM_VERSION:
> -      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
> +   case CL_PLATFORM_VERSION: {
> +      static const std::string version_string = std::string(
> +            debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1"));
> +
> +      buf.as_string() = "OpenCL " + version_string + " Mesa " PACKAGE_VERSION
>  #ifdef MESA_GIT_SHA1
>                          " (" MESA_GIT_SHA1 ")"
>  #endif
>                          ;
>        break;
> -
> +   }
>     case CL_PLATFORM_NAME:
>        buf.as_string() = "Clover";
>        break;
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index 71cf4bf60a..b3a3903bcd 100644
> --- a/src/gallium/state_trackers/clover/core/device.cpp
> +++ b/src/gallium/state_trackers/clover/core/device.cpp
> @@ -25,6 +25,7 @@
>  #include "core/platform.hpp"
>  #include "pipe/p_screen.h"
>  #include "pipe/p_state.h"
> +#include "util/u_debug.h"
>  
>  using namespace clover;
>  
> @@ -268,10 +269,14 @@ device::endianness() const {
>  
>  std::string
>  device::device_version() const {
> -    return "1.1";
> +   static const std::string device_version = std::string(
> +         debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
> +   return device_version;
>  }
>  
>  std::string
>  device::device_clc_version() const {
> -    return "1.1";
> +   static const std::string device_clc_version = std::string(
> +         debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
> +   return device_clc_version;
>  }
> -- 
> 2.14.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev