[1/2] clover: Allow overriding platform/device version numbers

Submitted by Aaron Watry on March 1, 2018, 7:44 p.m.

Details

Message ID 20180301194434.15419-1-awatry@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

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

Signed-off-by: Aaron Watry <awatry@gmail.com>
Cc: Pierre Moreau <pierre.morrow@free.fr>
Cc: Jan Vesely <jan.vesely@rutgers.edu>
Cc: Francisco Jerez <currojerez@riseup.net>
---
 src/gallium/state_trackers/clover/api/platform.cpp | 7 ++++++-
 src/gallium/state_trackers/clover/core/device.cpp  | 5 +++--
 2 files changed, 9 insertions(+), 3 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..8cb2718973 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;
 
@@ -51,6 +52,7 @@  clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
    property_buffer buf { r_buf, size, r_size };
 
    obj(d_platform);
+   std::string version_string;
 
    switch (param) {
    case CL_PLATFORM_PROFILE:
@@ -58,7 +60,10 @@  clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
       break;
 
    case CL_PLATFORM_VERSION:
-      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
+      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
diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
index 71cf4bf60a..245d728886 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,10 @@  device::endianness() const {
 
 std::string
 device::device_version() const {
-    return "1.1";
+   return std::string(debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
 }
 
 std::string
 device::device_clc_version() const {
-    return "1.1";
+   return std::string(debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
 }

Comments

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

On 2018-03-01 — 13:44, 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>
> Cc: Pierre Moreau <pierre.morrow@free.fr>
> Cc: Jan Vesely <jan.vesely@rutgers.edu>
> Cc: Francisco Jerez <currojerez@riseup.net>
> ---
>  src/gallium/state_trackers/clover/api/platform.cpp | 7 ++++++-
>  src/gallium/state_trackers/clover/core/device.cpp  | 5 +++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
> index ed86163311..8cb2718973 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;
>  
> @@ -51,6 +52,7 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>     property_buffer buf { r_buf, size, r_size };
>  
>     obj(d_platform);
> +   std::string version_string;
>  
>     switch (param) {
>     case CL_PLATFORM_PROFILE:
> @@ -58,7 +60,10 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>        break;
>  
>     case CL_PLATFORM_VERSION:
> -      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
> +      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
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index 71cf4bf60a..245d728886 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,10 @@ device::endianness() const {
>  
>  std::string
>  device::device_version() const {
> -    return "1.1";
> +   return std::string(debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
>  }
>  
>  std::string
>  device::device_clc_version() const {
> -    return "1.1";
> +   return std::string(debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
>  }
> -- 
> 2.14.1
>
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>
> Cc: Pierre Moreau <pierre.morrow@free.fr>
> Cc: Jan Vesely <jan.vesely@rutgers.edu>
> Cc: Francisco Jerez <currojerez@riseup.net>
> ---
>  src/gallium/state_trackers/clover/api/platform.cpp | 7 ++++++-
>  src/gallium/state_trackers/clover/core/device.cpp  | 5 +++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
> index ed86163311..8cb2718973 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;
>  
> @@ -51,6 +52,7 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>     property_buffer buf { r_buf, size, r_size };
>  
>     obj(d_platform);
> +   std::string version_string;
>  
>     switch (param) {
>     case CL_PLATFORM_PROFILE:
> @@ -58,7 +60,10 @@ clover::GetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
>        break;
>  
>     case CL_PLATFORM_VERSION:
> -      buf.as_string() = "OpenCL 1.1 Mesa " PACKAGE_VERSION
> +      version_string = std::string(
> +            debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1"));

Can you make the version_string declaration local to this case block and
mark as const?  With that fixed:

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

> +
> +      buf.as_string() = "OpenCL " + version_string + " Mesa " PACKAGE_VERSION
>  #ifdef MESA_GIT_SHA1
>                          " (" MESA_GIT_SHA1 ")"
>  #endif
> diff --git a/src/gallium/state_trackers/clover/core/device.cpp b/src/gallium/state_trackers/clover/core/device.cpp
> index 71cf4bf60a..245d728886 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,10 @@ device::endianness() const {
>  
>  std::string
>  device::device_version() const {
> -    return "1.1";
> +   return std::string(debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"));
>  }
>  
>  std::string
>  device::device_clc_version() const {
> -    return "1.1";
> +   return std::string(debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"));
>  }
> -- 
> 2.14.1
Hi Aaron,

On 1 March 2018 at 19:44, Aaron Watry <awatry@gmail.com> wrote:
> Useful for testing API, builtin library, and device completeness of
> not-yet-supported versions.
>
Small fly-by comment:

As-is it seems like getenv(foo) will be called multiple times.
Perhaps it isn't that 'slow' since it's not a hot path.

Yet again, one could get different version across calls which does sound icky.

Perhaps it's not worth bothering about?
Emil
Emil Velikov <emil.l.velikov@gmail.com> writes:

> Hi Aaron,
>
> On 1 March 2018 at 19:44, Aaron Watry <awatry@gmail.com> wrote:
>> Useful for testing API, builtin library, and device completeness of
>> not-yet-supported versions.
>>
> Small fly-by comment:
>
> As-is it seems like getenv(foo) will be called multiple times.
> Perhaps it isn't that 'slow' since it's not a hot path.
>
> Yet again, one could get different version across calls which does sound icky.
>
> Perhaps it's not worth bothering about?

These are far from hot paths...  But if you care a trivial solution
would be to mark version_string and friends as static const, so the
initializer is only evaluated once.

> Emil
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev