@@ -569,6 +569,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
569
569
return ReturnValue (
570
570
static_cast <ur_memory_order_capability_flags_t >(URCapabilities));
571
571
}
572
+
572
573
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
573
574
/* Initialize result to minimum mandated capabilities according to
574
575
* SYCL2020 4.6.3.2. Because scopes are hierarchical, wider scopes support
@@ -624,6 +625,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
624
625
return ReturnValue (
625
626
static_cast <ur_memory_scope_capability_flags_t >(URCapabilities));
626
627
}
628
+
627
629
case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
628
630
/* Initialize result to minimum mandated capabilities according to
629
631
* SYCL2020 4.6.3.2 */
@@ -671,6 +673,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
671
673
return ReturnValue (
672
674
static_cast <ur_memory_order_capability_flags_t >(URCapabilities));
673
675
}
676
+
674
677
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
675
678
/* Initialize result to minimum mandated capabilities according to
676
679
* SYCL2020 4.6.3.2. Because scopes are hierarchical, wider scopes support
@@ -686,38 +689,53 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
686
689
CL_RETURN_ON_FAILURE (cl_adapter::getDeviceVersion (
687
690
cl_adapter::cast<cl_device_id>(hDevice), DevVer));
688
691
689
- cl_device_atomic_capabilities CLCapabilities;
692
+ auto convertCapabilities =
693
+ [](cl_device_atomic_capabilities CLCapabilities) {
694
+ ur_memory_scope_capability_flags_t URCapabilities = 0 ;
695
+ /* Because scopes are hierarchical, wider scopes support all narrower
696
+ * scopes. At a minimum, each device must support WORK_ITEM,
697
+ * SUB_GROUP and WORK_GROUP.
698
+ * (https://github.com/KhronosGroup/SYCL-Docs/pull/382). We already
699
+ * initialized to these minimum mandated capabilities. Just check
700
+ * wider scopes. */
701
+ if (CLCapabilities & CL_DEVICE_ATOMIC_SCOPE_DEVICE) {
702
+ URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE;
703
+ }
704
+
705
+ if (CLCapabilities & CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES) {
706
+ URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
707
+ }
708
+ return URCapabilities;
709
+ };
710
+
690
711
if (DevVer >= oclv::V3_0) {
712
+ cl_device_atomic_capabilities CLCapabilities;
691
713
CL_RETURN_ON_FAILURE (clGetDeviceInfo (
692
714
cl_adapter::cast<cl_device_id>(hDevice),
693
715
CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
694
716
sizeof (cl_device_atomic_capabilities), &CLCapabilities, nullptr ));
695
-
696
717
assert ((CLCapabilities & CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP) &&
697
718
" Violates minimum mandated guarantee" );
719
+ URCapabilities |= convertCapabilities (CLCapabilities);
720
+ } else if (DevVer >= oclv::V2_0) {
721
+ /* OpenCL 2.x minimum mandated capabilities are WORK_GROUP | DEVICE |
722
+ ALL_DEVICES */
723
+ URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE |
724
+ UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
698
725
699
- /* Because scopes are hierarchical, wider scopes support all narrower
700
- * scopes. At a minimum, each device must support WORK_ITEM, SUB_GROUP and
701
- * WORK_GROUP. (https://github.com/KhronosGroup/SYCL-Docs/pull/382). We
702
- * already initialized to these minimum mandated capabilities. Just check
703
- * wider scopes. */
704
- if (CLCapabilities & CL_DEVICE_ATOMIC_SCOPE_DEVICE) {
705
- URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE;
706
- }
707
-
708
- if (CLCapabilities & CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES) {
709
- URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
710
- }
711
726
} else {
712
- /* This info is only available in OpenCL version >= 3.0. Just return
713
- * minimum mandated capabilities for older versions. OpenCL 1.x minimum
714
- * mandated capabilities are WORK_GROUP, we already initialized using it.
715
- */
716
- if (DevVer >= oclv::V2_0) {
717
- /* OpenCL 2.x minimum mandated capabilities are WORK_GROUP | DEVICE |
718
- * ALL_DEVICES */
719
- URCapabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE |
720
- UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
727
+ // FIXME: Special case for Intel FPGA driver which is currently an
728
+ // OpenCL 1.2 device but is more capable than the default. This is a
729
+ // temporary work around until the Intel FPGA driver is updated to
730
+ // OpenCL 3.0. If the query is successful, then use the result but do
731
+ // not return an error if the query is unsuccessful as this is expected
732
+ // of an OpenCL 1.2 driver.
733
+ cl_device_atomic_capabilities CLCapabilities;
734
+ if (CL_SUCCESS == clGetDeviceInfo (cl_adapter::cast<cl_device_id>(hDevice),
735
+ CL_DEVICE_ATOMIC_FENCE_CAPABILITIES,
736
+ sizeof (cl_device_atomic_capabilities),
737
+ &CLCapabilities, nullptr )) {
738
+ URCapabilities |= convertCapabilities (CLCapabilities);
721
739
}
722
740
}
723
741
0 commit comments