From 400847a990033c6d7e0bfab716bce49ec600358d Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 24 Apr 2023 12:54:59 +0200 Subject: [PATCH] rusticl/device: improve advertisement of fp64 support Enabling fp64 support makes rarely sense, but in case we do claim it, we should also tell if it's a pure software implementation. Signed-off-by: Karol Herbst Part-of: --- src/gallium/frontends/rusticl/api/device.rs | 21 ++++++++++++++------- src/gallium/frontends/rusticl/core/device.rs | 13 ++++++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 6b36054..2428d99 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -45,18 +45,23 @@ impl CLInfo for cl_device_id { CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES => { cl_prop::(0) } - CL_DEVICE_DOUBLE_FP_CONFIG => { - cl_prop::(if dev.doubles_supported() { - (CL_FP_FMA + CL_DEVICE_DOUBLE_FP_CONFIG => cl_prop::( + if dev.doubles_supported() { + let mut fp64_config = 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) as cl_device_fp_config + | CL_FP_DENORM; + if dev.doubles_is_softfp() { + fp64_config |= CL_FP_SOFT_FLOAT; + } + fp64_config } else { 0 - }) - } + } + .into(), + ), CL_DEVICE_ENDIAN_LITTLE => cl_prop::(dev.little_endian()), CL_DEVICE_ERROR_CORRECTION_SUPPORT => cl_prop::(false), CL_DEVICE_EXECUTION_CAPABILITIES => { @@ -125,7 +130,9 @@ impl CLInfo for cl_device_id { } CL_DEVICE_NAME => cl_prop(dev.screen().name()), CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR => cl_prop::(1), - CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE => cl_prop::(0), + CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE => { + cl_prop::(if dev.doubles_supported() { 1 } else { 0 }) + } CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT => cl_prop::(1), CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF => cl_prop::(0), CL_DEVICE_NATIVE_VECTOR_WIDTH_INT => cl_prop::(1), diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index b3f6aee..35711d3 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -584,17 +584,20 @@ impl Device { pub fn doubles_supported(&self) -> bool { false /* - if self.screen.param(pipe_cap::PIPE_CAP_DOUBLES) == 0 { - return false; - } + + self.screen.param(pipe_cap::PIPE_CAP_DOUBLES) == 1 + */ + } + + pub fn doubles_is_softfp(&self) -> bool { let nir_options = self .screen .nir_shader_compiler_options(pipe_shader_type::PIPE_SHADER_COMPUTE); - !bit_check( + + bit_check( unsafe { *nir_options }.lower_doubles_options as u32, nir_lower_doubles_options::nir_lower_fp64_full_software as u32, ) - */ } pub fn long_supported(&self) -> bool { -- 2.7.4