diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h index e5efc239da..86aa65881c 100644 --- a/lib/gpu/geryon/ocl_device.h +++ b/lib/gpu/geryon/ocl_device.h @@ -556,16 +556,22 @@ void UCL_Device::add_properties(cl_device_id device_list) { sizeof(float_width),&float_width,nullptr)); op.preferred_vector_width32=float_width; - // Determine if double precision is supported cl_uint double_width; CL_SAFE_CALL(clGetDeviceInfo(device_list, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(double_width),&double_width,nullptr)); op.preferred_vector_width64=double_width; - if (double_width==0) - op.double_precision=false; - else + + // Determine if double precision is supported: All bits in the mask must be set. + cl_device_fp_config double_mask = (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); + cl_device_fp_config double_avail; + CL_SAFE_CALL(clGetDeviceInfo(device_list,CL_DEVICE_DOUBLE_FP_CONFIG, + sizeof(double_avail),&double_avail,nullptr)); + if (((double_avail & double_mask) ^ double_mask) == 0) op.double_precision=true; + else + op.double_precision=false; CL_SAFE_CALL(clGetDeviceInfo(device_list, CL_DEVICE_PROFILING_TIMER_RESOLUTION,