Skip to content

Commit 85c7217

Browse files
authored
Fix FP64 support reporting (#766)
- Make reported native and preferred vector widths conditional to support (and do the same for FP16) - Report cl_khr_fp64 and __opencl_c_fp64 when FP64 is supported - Always use cvk_device::supports_fp64() to determine support - Force disable support for now This fixes compier::features_macro and api::consistency_requirements_fp64 CTS tests. Change-Id: I454bcb70090aeccf0c7b67911e16745e4728acc9 Signed-off-by: Kévin Petit <[email protected]>
1 parent e063032 commit 85c7217

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/api.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -620,25 +620,30 @@ cl_int CLVK_API_CALL clGetDeviceInfo(cl_device_id dev,
620620
copy_ptr = &val_ulong;
621621
size_ret = sizeof(val_ulong);
622622
break;
623+
// FIXME can we do better for vector width queries?
623624
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR:
624625
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT:
625626
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT:
626627
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG:
627628
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT:
628-
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
629629
case CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR:
630630
case CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT:
631631
case CL_DEVICE_NATIVE_VECTOR_WIDTH_INT:
632632
case CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG:
633633
case CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT:
634+
val_uint = 1;
635+
copy_ptr = &val_uint;
636+
size_ret = sizeof(val_uint);
637+
break;
638+
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF:
634639
case CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF:
635-
val_uint = 1; // FIXME can we do better?
640+
val_uint = device->supports_fp16() ? 1 : 0;
636641
copy_ptr = &val_uint;
637642
size_ret = sizeof(val_uint);
638643
break;
639644
case CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE:
640645
case CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE:
641-
val_uint = 0;
646+
val_uint = device->supports_fp64() ? 1 : 0;
642647
copy_ptr = &val_uint;
643648
size_ret = sizeof(val_uint);
644649
break;

src/device.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,10 @@ void cvk_device::build_extension_ils_list() {
661661
m_extensions.push_back(MAKE_NAME_VERSION(1, 0, 0, "cl_khr_fp16"));
662662
}
663663

664+
if (supports_fp64()) {
665+
m_extensions.push_back(MAKE_NAME_VERSION(1, 0, 0, "cl_khr_fp64"));
666+
}
667+
664668
// Enable 8-bit integer support if possible
665669
if ((is_vulkan_extension_enabled(VK_KHR_8BIT_STORAGE_EXTENSION_NAME) &&
666670
m_features_8bit_storage.storageBuffer8BitAccess) &&
@@ -794,8 +798,7 @@ void cvk_device::build_extension_ils_list() {
794798
m_opencl_c_features.push_back(
795799
MAKE_NAME_VERSION(3, 0, 0, "__opencl_c_int64"));
796800
}
797-
if (m_features.features.shaderFloat64) {
798-
m_has_fp64_support = true;
801+
if (supports_fp64()) {
799802
m_opencl_c_features.push_back(
800803
MAKE_NAME_VERSION(3, 0, 0, "__opencl_c_fp64"));
801804
}

src/device.hpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ struct cvk_device : public _cl_device_id,
438438

439439
bool supports_fp16() const { return m_has_fp16_support; }
440440

441-
bool supports_fp64() const { return m_has_fp64_support; }
441+
// TODO(kpet): support FP64 (clspv has very little support)
442+
bool supports_fp64() const {
443+
return 0 && m_features.features.shaderFloat64;
444+
}
442445

443446
bool supports_int8() const { return m_has_int8_support; }
444447

@@ -558,6 +561,12 @@ struct cvk_device : public _cl_device_id,
558561
return CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN | CL_FP_FMA;
559562
}
560563

564+
if ((fptype == CL_DEVICE_DOUBLE_FP_CONFIG) && supports_fp64()) {
565+
return CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO |
566+
CL_FP_ROUND_TO_INF | CL_FP_INF_NAN | CL_FP_FMA |
567+
CL_FP_DENORM;
568+
}
569+
561570
return 0;
562571
}
563572

@@ -794,7 +803,6 @@ struct cvk_device : public _cl_device_id,
794803

795804
bool m_has_timer_support{};
796805
bool m_has_fp16_support{};
797-
bool m_has_fp64_support{};
798806
bool m_has_int8_support{};
799807
bool m_has_subgroups_support{};
800808
bool m_has_subgroup_size_selection{};

0 commit comments

Comments
 (0)