[Beignet] [PATCH 2/2] Runtime: initialize single fp mode correctly.
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Aug 28 19:47:35 PDT 2013
According to opencl spec,
The mandated minimum single precision floating-point capability given by
CL_DEVICE_SINGLE_FP_CONFIG is CL_FP_ROUND_TO_ZERO or CL_FP_ROUND_TO_NEAREST.
We set the single float mode to IEEE 754 and set the rounding mode
to RTN.
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
src/cl_gt_device.h | 2 ++
src/intel/intel_gpgpu.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index f58e1fd..7f67697 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -62,6 +62,8 @@
.execution_capabilities = CL_EXEC_KERNEL,
.queue_properties = CL_QUEUE_PROFILING_ENABLE,
.platform = NULL, /* == intel_platform (set when requested) */
+/* IEEE 754, XXX does IVB support CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT? */
+.single_fp_config = CL_FP_DENORM | CL_FP_INF_NAN | CL_FP_ROUND_TO_NEAREST , /* IEEE 754. */
#define DECL_INFO_STRING(FIELD, STRING) \
.FIELD = STRING, \
diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c
index 1301b66..073e255 100644
--- a/src/intel/intel_gpgpu.c
+++ b/src/intel/intel_gpgpu.c
@@ -608,6 +608,8 @@ intel_gpgpu_build_idrt(intel_gpgpu_t *gpgpu, cl_gpgpu_kernel *kernel)
ker_bo = (drm_intel_bo *) kernel->bo;
desc->desc0.kernel_start_pointer = ker_bo->offset >> 6; /* reloc */
desc->desc1.single_program_flow = 1;
+ desc->desc1.floating_point_mode = 0; /* use IEEE-754 rule */
+ desc->desc5.rounding_mode = 0; /* round to nearest even */
desc->desc2.sampler_state_pointer = gpgpu->sampler_state_b.bo->offset >> 5;
desc->desc3.binding_table_entry_count = 0; /* no prefetch */
desc->desc3.binding_table_pointer = 0;
--
1.7.9.5
More information about the Beignet
mailing list