[Mesa-dev] [PATCH 2/2] clover: Enable cl_khr_fp64 for devices that support doubles v3
Tom Stellard
thomas.stellard at amd.com
Mon Mar 2 07:55:22 PST 2015
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().
v3:
- Return 0 for device::doubled_fp_confg() when doubles aren't
supported.
---
src/gallium/state_trackers/clover/api/device.cpp | 10 +++++++---
src/gallium/state_trackers/clover/core/device.cpp | 21 +++++++++++++++++++++
src/gallium/state_trackers/clover/core/device.hpp | 2 ++
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp
index e8750e8..a7ea34a 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_scalar<cl_uint>() = 2;
+ buf.as_scalar<cl_uint>() = dev.has_doubles() ? 2 : 0;
break;
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
@@ -204,6 +204,10 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
buf.as_scalar<cl_device_fp_config>() = dev.single_fp_config();
break;
+ case CL_DEVICE_DOUBLE_FP_CONFIG:
+ buf.as_scalar<cl_device_fp_config>() = dev.double_fp_config();
+ break;
+
case CL_DEVICE_GLOBAL_MEM_CACHE_TYPE:
buf.as_scalar<cl_device_mem_cache_type>() = CL_NONE;
break;
@@ -282,7 +286,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:
@@ -314,7 +318,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
break;
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
- buf.as_scalar<cl_uint>() = 2;
+ buf.as_scalar<cl_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 34f0372..56f3570 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -179,6 +179,27 @@ device::single_fp_config() const {
return CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST;
}
+cl_device_fp_config
+device::double_fp_config() const {
+ if (!has_doubles())
+ return 0;
+
+ // TODO: Get these from somewhere. This is the "mandated minimum double
+ // precision floating-point capability"
+ return CL_FP_FMA
+ | CL_FP_ROUND_TO_NEAREST
+ | CL_FP_ROUND_TO_ZERO
+ | CL_FP_ROUND_TO_INF
+ | CL_FP_INF_NAN
+ | CL_FP_DENORM;
+}
+
+bool
+device::has_doubles() const {
+ return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_DOUBLES);
+}
+
std::vector<size_t>
device::max_block_size() const {
auto v = get_compute_param<uint64_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 6d3c2c3..3d08873 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -65,6 +65,8 @@ namespace clover {
cl_uint max_compute_units() const;
bool image_support() const;
cl_device_fp_config single_fp_config() const;
+ cl_device_fp_config double_fp_config() const;
+ bool has_doubles() const;
std::vector<size_t> max_block_size() const;
std::string device_name() const;
--
2.0.4
More information about the mesa-dev
mailing list