Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-08-13 Thread Matt Arsenault
On Jun 26, 2014, at 7:15 AM, Francisco Jerez curroje...@riseup.net wrote:

 Tom Stellard thomas.stell...@amd.com writes:
 
 v2:
  - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
  - Only define cl_khr_fp64 if the extension is supported.
  - Remove trailing space from extension string.
  - Rename device query function from cl_khr_fp86() to has_doubles().
 ---
 src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 src/gallium/state_trackers/clover/core/program.cpp| 5 -
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
 5 files changed, 14 insertions(+), 5 deletions(-)
 
 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index 7006702..1176668 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
 @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
   break;
 
case CL_DEVICE_PLATFORM:
 @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index bc6b761..6bf33e0 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -193,6 +193,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
 +bool
 +device::has_doubles() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 16831ab..025c648 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -66,6 +66,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
 +  bool has_doubles() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
 diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
 b/src/gallium/state_trackers/clover/core/program.cpp
 index e09c3aa..f65f321 100644
 --- a/src/gallium/state_trackers/clover/core/program.cpp
 +++ b/src/gallium/state_trackers/clover/core/program.cpp
 @@ -95,7 +95,10 @@ program::build_status(const device dev) const {
 
 std::string
 program::build_opts(const device dev) const {
 -   return _opts.count(dev) ? _opts.find(dev)-second : ;
 +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
 +   if (dev.has_doubles())
 +  opts.append( -Dcl_khr_fp64);
 +   return opts;
 
 This define belongs in the target-specific part of libclc.  With this
 hunk removed this patch is:
 
 Reviewed-by: Francisco Jerez curroje...@riseup.net
 
 }
 
 std::string
 diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
 b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 index 5d2efc4..f2b4fd9 100644
 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
 +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 @@ -183,7 +183,6 @@ namespace {
 
   // clc.h requires that this macro be defined:
   
 c.getPreprocessorOpts().addMacroDef(cl_clang_storage_class_specifiers);
 -  c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);
 
   c.getLangOpts().NoBuiltin = true;
   c.getTargetOpts().Triple = triple;
 -- 
 1.8.1.5
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev


ping
___
mesa-dev mailing list

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-04 Thread Francisco Jerez
Tom Stellard t...@stellard.net writes:

 On Fri, Jul 04, 2014 at 12:28:20AM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
  Tom Stellard t...@stellard.net writes:
  
   On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
   Tom Stellard thomas.stell...@amd.com writes:
   
v2:
  - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 
and
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
  - Only define cl_khr_fp64 if the extension is supported.
  - Remove trailing space from extension string.
  - Rename device query function from cl_khr_fp86() to has_doubles().
---
 src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 src/gallium/state_trackers/clover/core/program.cpp| 5 -
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
 5 files changed, 14 insertions(+), 5 deletions(-)
   
diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 7006702..1176668 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
@@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
-  buf.as_string() = ;
+  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
   break;
 
case CL_DEVICE_PLATFORM:
@@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index bc6b761..6bf33e0 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -193,6 +193,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
+bool
+device::has_doubles() const {
+   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_DOUBLES);
+}
+
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, 
PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 16831ab..025c648 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -66,6 +66,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
+  bool has_doubles() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index e09c3aa..f65f321 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -95,7 +95,10 @@ program::build_status(const device dev) const {
 
 std::string
 program::build_opts(const device dev) const {
-   return _opts.count(dev) ? _opts.find(dev)-second : ;
+   std::string opts = _opts.count(dev) ? _opts.find(dev)-second 
: ;
+   if (dev.has_doubles())
+  opts.append( -Dcl_khr_fp64);
+   return opts;
   
   This define belongs in the target-specific part of libclc.  With this
   hunk removed this patch is:
   
  
   The declarations for double functions in the libclc headers are wrapped 
   in this
   macro, so we need to set it here in order to be able to use them from 
   clover.
  
  
  This abuses the ::build_opts() accessor to that end, which is only
  supposed to return the compiler options that were specified by the user
  at build time, as required by the CL_PROGRAM_BUILD_OPTIONS build param.
  
 
  You are right, I can fix that.
 
  IMO preprocessor macros defined by the 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-04 Thread Tom Stellard
On Fri, Jul 04, 2014 at 12:28:05PM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Fri, Jul 04, 2014 at 12:28:20AM +0200, Francisco Jerez wrote:
  Tom Stellard t...@stellard.net writes:
  
   On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
   Tom Stellard t...@stellard.net writes:
   
On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
Tom Stellard thomas.stell...@amd.com writes:

 v2:
   - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 
 and
 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
   - Only define cl_khr_fp64 if the extension is supported.
   - Remove trailing space from extension string.
   - Rename device query function from cl_khr_fp86() to 
 has_doubles().
 ---
  src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
  src/gallium/state_trackers/clover/core/device.cpp | 6 ++
  src/gallium/state_trackers/clover/core/device.hpp | 1 +
  src/gallium/state_trackers/clover/core/program.cpp| 5 -
  src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
  5 files changed, 14 insertions(+), 5 deletions(-)

 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index 7006702..1176668 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
 @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
break;
  
 case CL_DEVICE_PLATFORM:
 @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index bc6b761..6bf33e0 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -193,6 +193,12 @@ device::half_fp_config() const {
 return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
  }
  
 +bool
 +device::has_doubles() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
  std::vectorsize_t
  device::max_block_size() const {
 auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 16831ab..025c648 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -66,6 +66,7 @@ namespace clover {
cl_device_fp_config single_fp_config() const;
cl_device_fp_config double_fp_config() const;
cl_device_fp_config half_fp_config() const;
 +  bool has_doubles() const;
  
std::vectorsize_t max_block_size() const;
std::string device_name() const;
 diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
 b/src/gallium/state_trackers/clover/core/program.cpp
 index e09c3aa..f65f321 100644
 --- a/src/gallium/state_trackers/clover/core/program.cpp
 +++ b/src/gallium/state_trackers/clover/core/program.cpp
 @@ -95,7 +95,10 @@ program::build_status(const device dev) const {
  
  std::string
  program::build_opts(const device dev) const {
 -   return _opts.count(dev) ? _opts.find(dev)-second : ;
 +   std::string opts = _opts.count(dev) ? 
 _opts.find(dev)-second : ;
 +   if (dev.has_doubles())
 +  opts.append( -Dcl_khr_fp64);
 +   return opts;

This define belongs in the target-specific part of libclc.  With this
hunk removed this patch is:

   
The declarations for double functions in the libclc headers are 
wrapped in this
macro, so we need to set it here in order to be able to use them from 
clover.
   
   
   This abuses the ::build_opts() accessor to that end, which is only
   supposed to return the compiler 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-04 Thread Francisco Jerez
Tom Stellard t...@stellard.net writes:

 On Fri, Jul 04, 2014 at 12:28:05PM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Fri, Jul 04, 2014 at 12:28:20AM +0200, Francisco Jerez wrote:
  Tom Stellard t...@stellard.net writes:
  
   On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
   Tom Stellard t...@stellard.net writes:
   
On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
Tom Stellard thomas.stell...@amd.com writes:

 v2:
   - Report correct values for 
 CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
   - Only define cl_khr_fp64 if the extension is supported.
   - Remove trailing space from extension string.
   - Rename device query function from cl_khr_fp86() to 
 has_doubles().
 ---
  src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
  src/gallium/state_trackers/clover/core/device.cpp | 6 ++
  src/gallium/state_trackers/clover/core/device.hpp | 1 +
  src/gallium/state_trackers/clover/core/program.cpp| 5 -
  src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
  5 files changed, 14 insertions(+), 5 deletions(-)

 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index 7006702..1176668 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
 @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
break;
  
 case CL_DEVICE_PLATFORM:
 @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
 cl_device_info param,
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index bc6b761..6bf33e0 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -193,6 +193,12 @@ device::half_fp_config() const {
 return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
  }
  
 +bool
 +device::has_doubles() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
  std::vectorsize_t
  device::max_block_size() const {
 auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 16831ab..025c648 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -66,6 +66,7 @@ namespace clover {
cl_device_fp_config single_fp_config() const;
cl_device_fp_config double_fp_config() const;
cl_device_fp_config half_fp_config() const;
 +  bool has_doubles() const;
  
std::vectorsize_t max_block_size() const;
std::string device_name() const;
 diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
 b/src/gallium/state_trackers/clover/core/program.cpp
 index e09c3aa..f65f321 100644
 --- a/src/gallium/state_trackers/clover/core/program.cpp
 +++ b/src/gallium/state_trackers/clover/core/program.cpp
 @@ -95,7 +95,10 @@ program::build_status(const device dev) const 
 {
  
  std::string
  program::build_opts(const device dev) const {
 -   return _opts.count(dev) ? _opts.find(dev)-second : ;
 +   std::string opts = _opts.count(dev) ? 
 _opts.find(dev)-second : ;
 +   if (dev.has_doubles())
 +  opts.append( -Dcl_khr_fp64);
 +   return opts;

This define belongs in the target-specific part of libclc.  With 
this
hunk removed this patch is:

   
The declarations for double functions in the libclc headers are 
wrapped in this
macro, so we need to set it here in order to be able to use them 
from clover.
   
   
   This abuses the ::build_opts() accessor to that end, 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-04 Thread Tom Stellard
On Fri, Jul 04, 2014 at 05:25:42PM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Fri, Jul 04, 2014 at 12:28:05PM +0200, Francisco Jerez wrote:
  Tom Stellard t...@stellard.net writes:
  
   On Fri, Jul 04, 2014 at 12:28:20AM +0200, Francisco Jerez wrote:
   Tom Stellard t...@stellard.net writes:
   
On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
Tom Stellard t...@stellard.net writes:

 On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
 Tom Stellard thomas.stell...@amd.com writes:
 
  v2:
- Report correct values for 
  CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
  CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
- Only define cl_khr_fp64 if the extension is supported.
- Remove trailing space from extension string.
- Rename device query function from cl_khr_fp86() to 
  has_doubles().
  ---
   src/gallium/state_trackers/clover/api/device.cpp  | 6 
  +++---
   src/gallium/state_trackers/clover/core/device.cpp | 6 
  ++
   src/gallium/state_trackers/clover/core/device.hpp | 1 +
   src/gallium/state_trackers/clover/core/program.cpp| 5 -
   src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
   5 files changed, 14 insertions(+), 5 deletions(-)
 
  diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
  b/src/gallium/state_trackers/clover/api/device.cpp
  index 7006702..1176668 100644
  --- a/src/gallium/state_trackers/clover/api/device.cpp
  +++ b/src/gallium/state_trackers/clover/api/device.cpp
  @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
  cl_device_info param,
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
  @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
  cl_device_info param,
 break;
   
  case CL_DEVICE_EXTENSIONS:
  -  buf.as_string() = ;
  +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
 break;
   
  case CL_DEVICE_PLATFORM:
  @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
  cl_device_info param,
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
  diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
  b/src/gallium/state_trackers/clover/core/device.cpp
  index bc6b761..6bf33e0 100644
  --- a/src/gallium/state_trackers/clover/core/device.cpp
  +++ b/src/gallium/state_trackers/clover/core/device.cpp
  @@ -193,6 +193,12 @@ device::half_fp_config() const {
  return CL_FP_DENORM | CL_FP_INF_NAN | 
  CL_FP_ROUND_TO_NEAREST;
   }
   
  +bool
  +device::has_doubles() const {
  +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
  + PIPE_SHADER_CAP_DOUBLES);
  +}
  +
   std::vectorsize_t
   device::max_block_size() const {
  auto v = get_compute_paramuint64_t(pipe, 
  PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
  diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
  b/src/gallium/state_trackers/clover/core/device.hpp
  index 16831ab..025c648 100644
  --- a/src/gallium/state_trackers/clover/core/device.hpp
  +++ b/src/gallium/state_trackers/clover/core/device.hpp
  @@ -66,6 +66,7 @@ namespace clover {
 cl_device_fp_config single_fp_config() const;
 cl_device_fp_config double_fp_config() const;
 cl_device_fp_config half_fp_config() const;
  +  bool has_doubles() const;
   
 std::vectorsize_t max_block_size() const;
 std::string device_name() const;
  diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
  b/src/gallium/state_trackers/clover/core/program.cpp
  index e09c3aa..f65f321 100644
  --- a/src/gallium/state_trackers/clover/core/program.cpp
  +++ b/src/gallium/state_trackers/clover/core/program.cpp
  @@ -95,7 +95,10 @@ program::build_status(const device dev) 
  const {
   
   std::string
   program::build_opts(const device dev) const {
  -   return _opts.count(dev) ? _opts.find(dev)-second : ;
  +   std::string opts = _opts.count(dev) ? 
  _opts.find(dev)-second : ;
  +   if (dev.has_doubles())
  +  opts.append( -Dcl_khr_fp64);
  +   return opts;
 
 This define belongs in the target-specific part of libclc.  With 
 this
 hunk removed this patch is:
 

 The declarations for double 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-03 Thread Tom Stellard
On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
  Tom Stellard thomas.stell...@amd.com writes:
  
   v2:
 - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
   CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
 - Only define cl_khr_fp64 if the extension is supported.
 - Remove trailing space from extension string.
 - Rename device query function from cl_khr_fp86() to has_doubles().
   ---
src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
src/gallium/state_trackers/clover/core/device.cpp | 6 ++
src/gallium/state_trackers/clover/core/device.hpp | 1 +
src/gallium/state_trackers/clover/core/program.cpp| 5 -
src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
5 files changed, 14 insertions(+), 5 deletions(-)
  
   diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
   b/src/gallium/state_trackers/clover/api/device.cpp
   index 7006702..1176668 100644
   --- a/src/gallium/state_trackers/clover/api/device.cpp
   +++ b/src/gallium/state_trackers/clover/api/device.cpp
   @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
   -  buf.as_scalarcl_uint() = 2;
   +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
  break;

   case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
   @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_EXTENSIONS:
   -  buf.as_string() = ;
   +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
  break;

   case CL_DEVICE_PLATFORM:
   @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
   -  buf.as_scalarcl_uint() = 2;
   +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
  break;

   case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
   diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
   b/src/gallium/state_trackers/clover/core/device.cpp
   index bc6b761..6bf33e0 100644
   --- a/src/gallium/state_trackers/clover/core/device.cpp
   +++ b/src/gallium/state_trackers/clover/core/device.cpp
   @@ -193,6 +193,12 @@ device::half_fp_config() const {
   return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
}

   +bool
   +device::has_doubles() const {
   +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
   + PIPE_SHADER_CAP_DOUBLES);
   +}
   +
std::vectorsize_t
device::max_block_size() const {
   auto v = get_compute_paramuint64_t(pipe, 
   PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
   diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
   b/src/gallium/state_trackers/clover/core/device.hpp
   index 16831ab..025c648 100644
   --- a/src/gallium/state_trackers/clover/core/device.hpp
   +++ b/src/gallium/state_trackers/clover/core/device.hpp
   @@ -66,6 +66,7 @@ namespace clover {
  cl_device_fp_config single_fp_config() const;
  cl_device_fp_config double_fp_config() const;
  cl_device_fp_config half_fp_config() const;
   +  bool has_doubles() const;

  std::vectorsize_t max_block_size() const;
  std::string device_name() const;
   diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
   b/src/gallium/state_trackers/clover/core/program.cpp
   index e09c3aa..f65f321 100644
   --- a/src/gallium/state_trackers/clover/core/program.cpp
   +++ b/src/gallium/state_trackers/clover/core/program.cpp
   @@ -95,7 +95,10 @@ program::build_status(const device dev) const {

std::string
program::build_opts(const device dev) const {
   -   return _opts.count(dev) ? _opts.find(dev)-second : ;
   +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
   +   if (dev.has_doubles())
   +  opts.append( -Dcl_khr_fp64);
   +   return opts;
  
  This define belongs in the target-specific part of libclc.  With this
  hunk removed this patch is:
  
 
  The declarations for double functions in the libclc headers are wrapped in 
  this
  macro, so we need to set it here in order to be able to use them from 
  clover.
 
 
 This abuses the ::build_opts() accessor to that end, which is only
 supposed to return the compiler options that were specified by the user
 at build time, as required by the CL_PROGRAM_BUILD_OPTIONS build param.
 

You are right, I can fix that.

 IMO preprocessor macros defined by the spec belong in the standard
 library.  We probably need a specialization of libclc's header files for
 each triple (I hadn't noticed you didn't have one already -- it will
 probably be useful for other reasons too), as you have target-specific
 specializations of the LLVM bitcode 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-03 Thread Francisco Jerez
Tom Stellard t...@stellard.net writes:

 On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
  Tom Stellard thomas.stell...@amd.com writes:
  
   v2:
 - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
   CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
 - Only define cl_khr_fp64 if the extension is supported.
 - Remove trailing space from extension string.
 - Rename device query function from cl_khr_fp86() to has_doubles().
   ---
src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
src/gallium/state_trackers/clover/core/device.cpp | 6 ++
src/gallium/state_trackers/clover/core/device.hpp | 1 +
src/gallium/state_trackers/clover/core/program.cpp| 5 -
src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
5 files changed, 14 insertions(+), 5 deletions(-)
  
   diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
   b/src/gallium/state_trackers/clover/api/device.cpp
   index 7006702..1176668 100644
   --- a/src/gallium/state_trackers/clover/api/device.cpp
   +++ b/src/gallium/state_trackers/clover/api/device.cpp
   @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
   -  buf.as_scalarcl_uint() = 2;
   +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
  break;

   case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
   @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_EXTENSIONS:
   -  buf.as_string() = ;
   +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
  break;

   case CL_DEVICE_PLATFORM:
   @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
   param,
  break;

   case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
   -  buf.as_scalarcl_uint() = 2;
   +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
  break;

   case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
   diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
   b/src/gallium/state_trackers/clover/core/device.cpp
   index bc6b761..6bf33e0 100644
   --- a/src/gallium/state_trackers/clover/core/device.cpp
   +++ b/src/gallium/state_trackers/clover/core/device.cpp
   @@ -193,6 +193,12 @@ device::half_fp_config() const {
   return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
}

   +bool
   +device::has_doubles() const {
   +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
   + PIPE_SHADER_CAP_DOUBLES);
   +}
   +
std::vectorsize_t
device::max_block_size() const {
   auto v = get_compute_paramuint64_t(pipe, 
   PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
   diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
   b/src/gallium/state_trackers/clover/core/device.hpp
   index 16831ab..025c648 100644
   --- a/src/gallium/state_trackers/clover/core/device.hpp
   +++ b/src/gallium/state_trackers/clover/core/device.hpp
   @@ -66,6 +66,7 @@ namespace clover {
  cl_device_fp_config single_fp_config() const;
  cl_device_fp_config double_fp_config() const;
  cl_device_fp_config half_fp_config() const;
   +  bool has_doubles() const;

  std::vectorsize_t max_block_size() const;
  std::string device_name() const;
   diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
   b/src/gallium/state_trackers/clover/core/program.cpp
   index e09c3aa..f65f321 100644
   --- a/src/gallium/state_trackers/clover/core/program.cpp
   +++ b/src/gallium/state_trackers/clover/core/program.cpp
   @@ -95,7 +95,10 @@ program::build_status(const device dev) const {

std::string
program::build_opts(const device dev) const {
   -   return _opts.count(dev) ? _opts.find(dev)-second : ;
   +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : 
   ;
   +   if (dev.has_doubles())
   +  opts.append( -Dcl_khr_fp64);
   +   return opts;
  
  This define belongs in the target-specific part of libclc.  With this
  hunk removed this patch is:
  
 
  The declarations for double functions in the libclc headers are wrapped in 
  this
  macro, so we need to set it here in order to be able to use them from 
  clover.
 
 
 This abuses the ::build_opts() accessor to that end, which is only
 supposed to return the compiler options that were specified by the user
 at build time, as required by the CL_PROGRAM_BUILD_OPTIONS build param.
 

 You are right, I can fix that.

 IMO preprocessor macros defined by the spec belong in the standard
 library.  We probably need a specialization of libclc's header files for
 each triple (I hadn't noticed you didn't have one already -- it will
 probably be useful for other reasons too), as you have 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-03 Thread Tom Stellard
On Fri, Jul 04, 2014 at 12:28:20AM +0200, Francisco Jerez wrote:
 Tom Stellard t...@stellard.net writes:
 
  On Thu, Jul 03, 2014 at 01:12:07AM +0200, Francisco Jerez wrote:
  Tom Stellard t...@stellard.net writes:
  
   On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
   Tom Stellard thomas.stell...@amd.com writes:
   
v2:
  - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
  - Only define cl_khr_fp64 if the extension is supported.
  - Remove trailing space from extension string.
  - Rename device query function from cl_khr_fp86() to has_doubles().
---
 src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 src/gallium/state_trackers/clover/core/program.cpp| 5 -
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
 5 files changed, 14 insertions(+), 5 deletions(-)
   
diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 7006702..1176668 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
@@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
-  buf.as_string() = ;
+  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
   break;
 
case CL_DEVICE_PLATFORM:
@@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, 
cl_device_info param,
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index bc6b761..6bf33e0 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -193,6 +193,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
+bool
+device::has_doubles() const {
+   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_DOUBLES);
+}
+
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, 
PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 16831ab..025c648 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -66,6 +66,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
+  bool has_doubles() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index e09c3aa..f65f321 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -95,7 +95,10 @@ program::build_status(const device dev) const {
 
 std::string
 program::build_opts(const device dev) const {
-   return _opts.count(dev) ? _opts.find(dev)-second : ;
+   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : 
;
+   if (dev.has_doubles())
+  opts.append( -Dcl_khr_fp64);
+   return opts;
   
   This define belongs in the target-specific part of libclc.  With this
   hunk removed this patch is:
   
  
   The declarations for double functions in the libclc headers are wrapped 
   in this
   macro, so we need to set it here in order to be able to use them from 
   clover.
  
  
  This abuses the ::build_opts() accessor to that end, which is only
  supposed to return the compiler options that were specified by the user
  at build time, as required by the CL_PROGRAM_BUILD_OPTIONS build param.
  
 
  You are right, I can fix that.
 
  IMO preprocessor macros defined by the spec belong in the standard
  library.  We 

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-02 Thread Tom Stellard
On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
 Tom Stellard thomas.stell...@amd.com writes:
 
  v2:
- Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
  CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
- Only define cl_khr_fp64 if the extension is supported.
- Remove trailing space from extension string.
- Rename device query function from cl_khr_fp86() to has_doubles().
  ---
   src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
   src/gallium/state_trackers/clover/core/device.cpp | 6 ++
   src/gallium/state_trackers/clover/core/device.hpp | 1 +
   src/gallium/state_trackers/clover/core/program.cpp| 5 -
   src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
   5 files changed, 14 insertions(+), 5 deletions(-)
 
  diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
  b/src/gallium/state_trackers/clover/api/device.cpp
  index 7006702..1176668 100644
  --- a/src/gallium/state_trackers/clover/api/device.cpp
  +++ b/src/gallium/state_trackers/clover/api/device.cpp
  @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
  @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_EXTENSIONS:
  -  buf.as_string() = ;
  +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
 break;
   
  case CL_DEVICE_PLATFORM:
  @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
  diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
  b/src/gallium/state_trackers/clover/core/device.cpp
  index bc6b761..6bf33e0 100644
  --- a/src/gallium/state_trackers/clover/core/device.cpp
  +++ b/src/gallium/state_trackers/clover/core/device.cpp
  @@ -193,6 +193,12 @@ device::half_fp_config() const {
  return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
   }
   
  +bool
  +device::has_doubles() const {
  +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
  + PIPE_SHADER_CAP_DOUBLES);
  +}
  +
   std::vectorsize_t
   device::max_block_size() const {
  auto v = get_compute_paramuint64_t(pipe, 
  PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
  diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
  b/src/gallium/state_trackers/clover/core/device.hpp
  index 16831ab..025c648 100644
  --- a/src/gallium/state_trackers/clover/core/device.hpp
  +++ b/src/gallium/state_trackers/clover/core/device.hpp
  @@ -66,6 +66,7 @@ namespace clover {
 cl_device_fp_config single_fp_config() const;
 cl_device_fp_config double_fp_config() const;
 cl_device_fp_config half_fp_config() const;
  +  bool has_doubles() const;
   
 std::vectorsize_t max_block_size() const;
 std::string device_name() const;
  diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
  b/src/gallium/state_trackers/clover/core/program.cpp
  index e09c3aa..f65f321 100644
  --- a/src/gallium/state_trackers/clover/core/program.cpp
  +++ b/src/gallium/state_trackers/clover/core/program.cpp
  @@ -95,7 +95,10 @@ program::build_status(const device dev) const {
   
   std::string
   program::build_opts(const device dev) const {
  -   return _opts.count(dev) ? _opts.find(dev)-second : ;
  +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
  +   if (dev.has_doubles())
  +  opts.append( -Dcl_khr_fp64);
  +   return opts;
 
 This define belongs in the target-specific part of libclc.  With this
 hunk removed this patch is:
 

The declarations for double functions in the libclc headers are wrapped in this
macro, so we need to set it here in order to be able to use them from clover.

-Tom

 Reviewed-by: Francisco Jerez curroje...@riseup.net
 
   }
   
   std::string
  diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
  b/src/gallium/state_trackers/clover/llvm/invocation.cpp
  index 5d2efc4..f2b4fd9 100644
  --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
  +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
  @@ -183,7 +183,6 @@ namespace {
   
 // clc.h requires that this macro be defined:
 
  c.getPreprocessorOpts().addMacroDef(cl_clang_storage_class_specifiers);
  -  c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);
   
 c.getLangOpts().NoBuiltin = true;
 c.getTargetOpts().Triple = triple;
  -- 
  1.8.1.5
 
  ___
  mesa-dev mailing list
  

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-07-02 Thread Francisco Jerez
Tom Stellard t...@stellard.net writes:

 On Thu, Jun 26, 2014 at 04:15:39PM +0200, Francisco Jerez wrote:
 Tom Stellard thomas.stell...@amd.com writes:
 
  v2:
- Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
  CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
- Only define cl_khr_fp64 if the extension is supported.
- Remove trailing space from extension string.
- Rename device query function from cl_khr_fp86() to has_doubles().
  ---
   src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
   src/gallium/state_trackers/clover/core/device.cpp | 6 ++
   src/gallium/state_trackers/clover/core/device.hpp | 1 +
   src/gallium/state_trackers/clover/core/program.cpp| 5 -
   src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
   5 files changed, 14 insertions(+), 5 deletions(-)
 
  diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
  b/src/gallium/state_trackers/clover/api/device.cpp
  index 7006702..1176668 100644
  --- a/src/gallium/state_trackers/clover/api/device.cpp
  +++ b/src/gallium/state_trackers/clover/api/device.cpp
  @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
  @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_EXTENSIONS:
  -  buf.as_string() = ;
  +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
 break;
   
  case CL_DEVICE_PLATFORM:
  @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info 
  param,
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
  -  buf.as_scalarcl_uint() = 2;
  +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
 break;
   
  case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
  diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
  b/src/gallium/state_trackers/clover/core/device.cpp
  index bc6b761..6bf33e0 100644
  --- a/src/gallium/state_trackers/clover/core/device.cpp
  +++ b/src/gallium/state_trackers/clover/core/device.cpp
  @@ -193,6 +193,12 @@ device::half_fp_config() const {
  return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
   }
   
  +bool
  +device::has_doubles() const {
  +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
  + PIPE_SHADER_CAP_DOUBLES);
  +}
  +
   std::vectorsize_t
   device::max_block_size() const {
  auto v = get_compute_paramuint64_t(pipe, 
  PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
  diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
  b/src/gallium/state_trackers/clover/core/device.hpp
  index 16831ab..025c648 100644
  --- a/src/gallium/state_trackers/clover/core/device.hpp
  +++ b/src/gallium/state_trackers/clover/core/device.hpp
  @@ -66,6 +66,7 @@ namespace clover {
 cl_device_fp_config single_fp_config() const;
 cl_device_fp_config double_fp_config() const;
 cl_device_fp_config half_fp_config() const;
  +  bool has_doubles() const;
   
 std::vectorsize_t max_block_size() const;
 std::string device_name() const;
  diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
  b/src/gallium/state_trackers/clover/core/program.cpp
  index e09c3aa..f65f321 100644
  --- a/src/gallium/state_trackers/clover/core/program.cpp
  +++ b/src/gallium/state_trackers/clover/core/program.cpp
  @@ -95,7 +95,10 @@ program::build_status(const device dev) const {
   
   std::string
   program::build_opts(const device dev) const {
  -   return _opts.count(dev) ? _opts.find(dev)-second : ;
  +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
  +   if (dev.has_doubles())
  +  opts.append( -Dcl_khr_fp64);
  +   return opts;
 
 This define belongs in the target-specific part of libclc.  With this
 hunk removed this patch is:
 

 The declarations for double functions in the libclc headers are wrapped in 
 this
 macro, so we need to set it here in order to be able to use them from clover.


This abuses the ::build_opts() accessor to that end, which is only
supposed to return the compiler options that were specified by the user
at build time, as required by the CL_PROGRAM_BUILD_OPTIONS build param.

IMO preprocessor macros defined by the spec belong in the standard
library.  We probably need a specialization of libclc's header files for
each triple (I hadn't noticed you didn't have one already -- it will
probably be useful for other reasons too), as you have target-specific
specializations of the LLVM bitcode library.

Thanks.

 -Tom

 Reviewed-by: Francisco Jerez curroje...@riseup.net
 
   }
   
   std::string
  diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
  

Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-06-26 Thread Francisco Jerez
Tom Stellard thomas.stell...@amd.com writes:

 v2:
   - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
   - Only define cl_khr_fp64 if the extension is supported.
   - Remove trailing space from extension string.
   - Rename device query function from cl_khr_fp86() to has_doubles().
 ---
  src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
  src/gallium/state_trackers/clover/core/device.cpp | 6 ++
  src/gallium/state_trackers/clover/core/device.hpp | 1 +
  src/gallium/state_trackers/clover/core/program.cpp| 5 -
  src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
  5 files changed, 14 insertions(+), 5 deletions(-)

 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index 7006702..1176668 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
 @@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
  
 case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
break;
  
 case CL_DEVICE_PLATFORM:
 @@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
 -  buf.as_scalarcl_uint() = 2;
 +  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
break;
  
 case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index bc6b761..6bf33e0 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -193,6 +193,12 @@ device::half_fp_config() const {
 return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
  }
  
 +bool
 +device::has_doubles() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
  std::vectorsize_t
  device::max_block_size() const {
 auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 16831ab..025c648 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -66,6 +66,7 @@ namespace clover {
cl_device_fp_config single_fp_config() const;
cl_device_fp_config double_fp_config() const;
cl_device_fp_config half_fp_config() const;
 +  bool has_doubles() const;
  
std::vectorsize_t max_block_size() const;
std::string device_name() const;
 diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
 b/src/gallium/state_trackers/clover/core/program.cpp
 index e09c3aa..f65f321 100644
 --- a/src/gallium/state_trackers/clover/core/program.cpp
 +++ b/src/gallium/state_trackers/clover/core/program.cpp
 @@ -95,7 +95,10 @@ program::build_status(const device dev) const {
  
  std::string
  program::build_opts(const device dev) const {
 -   return _opts.count(dev) ? _opts.find(dev)-second : ;
 +   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
 +   if (dev.has_doubles())
 +  opts.append( -Dcl_khr_fp64);
 +   return opts;

This define belongs in the target-specific part of libclc.  With this
hunk removed this patch is:

Reviewed-by: Francisco Jerez curroje...@riseup.net

  }
  
  std::string
 diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
 b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 index 5d2efc4..f2b4fd9 100644
 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
 +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
 @@ -183,7 +183,6 @@ namespace {
  
// clc.h requires that this macro be defined:

 c.getPreprocessorOpts().addMacroDef(cl_clang_storage_class_specifiers);
 -  c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);
  
c.getLangOpts().NoBuiltin = true;
c.getTargetOpts().Triple = triple;
 -- 
 1.8.1.5

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev


pgpfeoB1xXxFt.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles v2

2014-06-25 Thread Tom Stellard
v2:
  - Report correct values for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE.
  - Only define cl_khr_fp64 if the extension is supported.
  - Remove trailing space from extension string.
  - Rename device query function from cl_khr_fp86() to has_doubles().
---
 src/gallium/state_trackers/clover/api/device.cpp  | 6 +++---
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 src/gallium/state_trackers/clover/core/program.cpp| 5 -
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 1 -
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 7006702..1176668 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -145,7 +145,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
@@ -290,7 +290,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
-  buf.as_string() = ;
+  buf.as_string() = dev.has_doubles() ? cl_khr_fp64 : ;
   break;
 
case CL_DEVICE_PLATFORM:
@@ -322,7 +322,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
-  buf.as_scalarcl_uint() = 2;
+  buf.as_scalarcl_uint() = dev.has_doubles() ? 2 : 0;
   break;
 
case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index bc6b761..6bf33e0 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -193,6 +193,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
+bool
+device::has_doubles() const {
+   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_DOUBLES);
+}
+
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 16831ab..025c648 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -66,6 +66,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
+  bool has_doubles() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index e09c3aa..f65f321 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -95,7 +95,10 @@ program::build_status(const device dev) const {
 
 std::string
 program::build_opts(const device dev) const {
-   return _opts.count(dev) ? _opts.find(dev)-second : ;
+   std::string opts = _opts.count(dev) ? _opts.find(dev)-second : ;
+   if (dev.has_doubles())
+  opts.append( -Dcl_khr_fp64);
+   return opts;
 }
 
 std::string
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 5d2efc4..f2b4fd9 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -183,7 +183,6 @@ namespace {
 
   // clc.h requires that this macro be defined:
   c.getPreprocessorOpts().addMacroDef(cl_clang_storage_class_specifiers);
-  c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);
 
   c.getLangOpts().NoBuiltin = true;
   c.getTargetOpts().Triple = triple;
-- 
1.8.1.5

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-21 Thread Francisco Jerez
Tom Stellard thomas.stell...@amd.com writes:

 ---
  src/gallium/state_trackers/clover/api/device.cpp  | 4 +++-
  src/gallium/state_trackers/clover/core/device.cpp | 6 ++
  src/gallium/state_trackers/clover/core/device.hpp | 1 +
  3 files changed, 10 insertions(+), 1 deletion(-)

 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index dc8e22c..275542d 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -290,7 +290,9 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
  
 case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  // The trailing space is intentional. It is a spec-ism that there is a
 +  // trailing space at the end of the list of extensions.

Hm...  Really?  Where does the spec say that?

 +  buf.as_string() = dev.cl_khr_fp64() ? cl_khr_fp64  : ;
break;
  
 case CL_DEVICE_PLATFORM:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index 6d52dd4..51b54fa 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -187,6 +187,12 @@ device::half_fp_config() const {
 return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
  }
  
 +bool
 +device::cl_khr_fp64() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +

Can we call this function has_doubles() or something similar?  The
extension name is somewhat cryptic.  Or, I don't know, maybe use
'device::double_fp_config()' to check if doubles are supported?  As
Bruno said, it should return 0 if doubles are not supported by the
implementation.

  std::vectorsize_t
  device::max_block_size() const {
 auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 380029e..38bea54 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -65,6 +65,7 @@ namespace clover {
cl_device_fp_config single_fp_config() const;
cl_device_fp_config double_fp_config() const;
cl_device_fp_config half_fp_config() const;
 +  bool cl_khr_fp64() const;
  
std::vectorsize_t max_block_size() const;
std::string device_name() const;
 -- 
 1.8.1.4


pgpSUyj6s8rWe.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-21 Thread Matt Arsenault

On Jun 21, 2014, at 9:37 AM, Francisco Jerez curroje...@riseup.net wrote:

 Tom Stellard thomas.stell...@amd.com writes:
 
 ---
 src/gallium/state_trackers/clover/api/device.cpp  | 4 +++-
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)
 
 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index dc8e22c..275542d 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -290,7 +290,9 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  // The trailing space is intentional. It is a spec-ism that there is a
 +  // trailing space at the end of the list of extensions.
 
 Hm...  Really?  Where does the spec say that?
 

I’m not really sure. I remember reporting a bug before about a trailing space 
in these outputs, and got the response that it is required by the spec, but 
never really finding where. I know it’s required for the versions (which also 
currently fails the conformance test with “A space must appear after the minor 
version! (returned: OpenCL C 1.1)”


 +  buf.as_string() = dev.cl_khr_fp64() ? cl_khr_fp64  : ;
   break;
 
case CL_DEVICE_PLATFORM:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index 6d52dd4..51b54fa 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -187,6 +187,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
 +bool
 +device::cl_khr_fp64() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
 
 Can we call this function has_doubles() or something similar?  The
 extension name is somewhat cryptic.  Or, I don't know, maybe use
 'device::double_fp_config()' to check if doubles are supported?  As
 Bruno said, it should return 0 if doubles are not supported by the
 implementation.

The extension is also “removed” in 1.2 and doubles become an “optional core 
extension” whatever that means, and is just required to be reported anyway for 
compatibility.

 
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 380029e..38bea54 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -65,6 +65,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
 +  bool cl_khr_fp64() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
 -- 
 1.8.1.4
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-21 Thread Francisco Jerez
Matt Arsenault arse...@gmail.com writes:

 On Jun 21, 2014, at 9:37 AM, Francisco Jerez curroje...@riseup.net wrote:

 Tom Stellard thomas.stell...@amd.com writes:
[...]
case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  // The trailing space is intentional. It is a spec-ism that there is 
 a
 +  // trailing space at the end of the list of extensions.
 
 Hm...  Really?  Where does the spec say that?
 

 I’m not really sure. I remember reporting a bug before about a trailing space 
 in these outputs, and got the response that it is required by the spec, but 
 never really finding where. I know it’s required for the versions (which also 
 currently fails the conformance test with “A space must appear after the 
 minor version! (returned: OpenCL C 1.1)”


That's because of the space-separated vendor-specific information that
CL_DEVICE_VERSION is supposed to include after the minor version, it
doesn't mean that the version string should necessarily be
space-terminated.

I don't think that the trailing space is required in the extension
string, let's get rid of it unless you can find evidence from the spec
that it should be otherwise.

Thanks.

[...]


pgpEtxErptRfQ.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-21 Thread Matt Arsenault

On Jun 21, 2014, at 12:32 PM, Francisco Jerez curroje...@riseup.net wrote:

 Matt Arsenault arse...@gmail.com writes:
 
 On Jun 21, 2014, at 9:37 AM, Francisco Jerez curroje...@riseup.net wrote:
 
 Tom Stellard thomas.stell...@amd.com writes:
 [...]
   case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  // The trailing space is intentional. It is a spec-ism that there 
 is a
 +  // trailing space at the end of the list of extensions.
 
 Hm...  Really?  Where does the spec say that?
 
 
 I’m not really sure. I remember reporting a bug before about a trailing 
 space in these outputs, and got the response that it is required by the 
 spec, but never really finding where. I know it’s required for the versions 
 (which also currently fails the conformance test with “A space must appear 
 after the minor version! (returned: OpenCL C 1.1)”
 
 
 That's because of the space-separated vendor-specific information that
 CL_DEVICE_VERSION is supposed to include after the minor version, it
 doesn't mean that the version string should necessarily be
 space-terminated.
 
 I don't think that the trailing space is required in the extension
 string, let's get rid of it unless you can find evidence from the spec
 that it should be otherwise.
 
 Thanks.
 

Fine with me
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-17 Thread Tom Stellard
---
 src/gallium/state_trackers/clover/api/device.cpp  | 4 +++-
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index dc8e22c..275542d 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -290,7 +290,9 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
-  buf.as_string() = ;
+  // The trailing space is intentional. It is a spec-ism that there is a
+  // trailing space at the end of the list of extensions.
+  buf.as_string() = dev.cl_khr_fp64() ? cl_khr_fp64  : ;
   break;
 
case CL_DEVICE_PLATFORM:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 6d52dd4..51b54fa 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -187,6 +187,12 @@ device::half_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
 }
 
+bool
+device::cl_khr_fp64() const {
+   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_DOUBLES);
+}
+
 std::vectorsize_t
 device::max_block_size() const {
auto v = get_compute_paramuint64_t(pipe, PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 380029e..38bea54 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -65,6 +65,7 @@ namespace clover {
   cl_device_fp_config single_fp_config() const;
   cl_device_fp_config double_fp_config() const;
   cl_device_fp_config half_fp_config() const;
+  bool cl_khr_fp64() const;
 
   std::vectorsize_t max_block_size() const;
   std::string device_name() const;
-- 
1.8.1.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-17 Thread Bruno Jimenez
Hi,

I have a couple of questions about this patch:

1) Could you please also change how the results of the
'CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE' and
'CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE' queries are generated?
According to the spec, if 'cl_khr_fp64' is not supported, they should be
0.

2) When llvm is invoked for compiling a module, a macro definition is
added with:
'c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);'
Is it ok to use this macro always or should it only be used when
'cl_khr_fp64' is supported?

Thanks!
Bruno

On Tue, 2014-06-17 at 09:44 -0700, Tom Stellard wrote:
 ---
  src/gallium/state_trackers/clover/api/device.cpp  | 4 +++-
  src/gallium/state_trackers/clover/core/device.cpp | 6 ++
  src/gallium/state_trackers/clover/core/device.hpp | 1 +
  3 files changed, 10 insertions(+), 1 deletion(-)
 
 diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
 b/src/gallium/state_trackers/clover/api/device.cpp
 index dc8e22c..275542d 100644
 --- a/src/gallium/state_trackers/clover/api/device.cpp
 +++ b/src/gallium/state_trackers/clover/api/device.cpp
 @@ -290,7 +290,9 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
  
 case CL_DEVICE_EXTENSIONS:
 -  buf.as_string() = ;
 +  // The trailing space is intentional. It is a spec-ism that there is a
 +  // trailing space at the end of the list of extensions.
 +  buf.as_string() = dev.cl_khr_fp64() ? cl_khr_fp64  : ;
break;
  
 case CL_DEVICE_PLATFORM:
 diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
 b/src/gallium/state_trackers/clover/core/device.cpp
 index 6d52dd4..51b54fa 100644
 --- a/src/gallium/state_trackers/clover/core/device.cpp
 +++ b/src/gallium/state_trackers/clover/core/device.cpp
 @@ -187,6 +187,12 @@ device::half_fp_config() const {
 return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
  }
  
 +bool
 +device::cl_khr_fp64() const {
 +   return pipe-get_shader_param(pipe, PIPE_SHADER_COMPUTE,
 + PIPE_SHADER_CAP_DOUBLES);
 +}
 +
  std::vectorsize_t
  device::max_block_size() const {
 auto v = get_compute_paramuint64_t(pipe, 
 PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
 diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
 b/src/gallium/state_trackers/clover/core/device.hpp
 index 380029e..38bea54 100644
 --- a/src/gallium/state_trackers/clover/core/device.hpp
 +++ b/src/gallium/state_trackers/clover/core/device.hpp
 @@ -65,6 +65,7 @@ namespace clover {
cl_device_fp_config single_fp_config() const;
cl_device_fp_config double_fp_config() const;
cl_device_fp_config half_fp_config() const;
 +  bool cl_khr_fp64() const;
  
std::vectorsize_t max_block_size() const;
std::string device_name() const;


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/5] clover: Enable cl_khr_fp64 for devices that support doubles

2014-06-17 Thread Matt Arsenault

On Jun 17, 2014, at 3:11 PM, Bruno Jimenez brunoji...@gmail.com wrote:

 Hi,
 
 I have a couple of questions about this patch:
 
 1) Could you please also change how the results of the
 'CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE' and
 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE' queries are generated?
 According to the spec, if 'cl_khr_fp64' is not supported, they should be
 0.
 



 2) When llvm is invoked for compiling a module, a macro definition is
 added with:
 'c.getPreprocessorOpts().addMacroDef(cl_khr_fp64);'
 Is it ok to use this macro always or should it only be used when
 'cl_khr_fp64' is supported?

It should only be added when supported. The most common way of testing for 
double support is ifdef cl_khr_fp64
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev