Skip to content

Commit 758c7e2

Browse files
authored
Merge pull request #536 from veselypeta/petr/device-partition-properties
[UR] Refactor urDevicePartition to use desc struct
2 parents e818777 + cf739e0 commit 758c7e2

File tree

22 files changed

+600
-346
lines changed

22 files changed

+600
-346
lines changed

include/ur.py

+63-37
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class ur_structure_type_v(IntEnum):
225225
PROGRAM_NATIVE_PROPERTIES = 23 ## ::ur_program_native_properties_t
226226
SAMPLER_NATIVE_PROPERTIES = 24 ## ::ur_sampler_native_properties_t
227227
QUEUE_NATIVE_DESC = 25 ## ::ur_queue_native_desc_t
228+
DEVICE_PARTITION_PROPERTIES = 26 ## ::ur_device_partition_properties_t
228229

229230
class ur_structure_type_t(c_int):
230231
def __str__(self):
@@ -502,8 +503,8 @@ class ur_device_info_v(IntEnum):
502503
PREFERRED_INTEROP_USER_SYNC = 74 ## [::ur_bool_t] prefer user synchronization when sharing object with
503504
## other API
504505
PARENT_DEVICE = 75 ## [::ur_device_handle_t] return parent device handle
505-
PARTITION_PROPERTIES = 76 ## [::ur_device_partition_property_t[]] Returns an array of partition
506-
## types supported by the device
506+
SUPPORTED_PARTITIONS = 76 ## [::ur_device_partition_t[]] Returns an array of partition types
507+
## supported by the device
507508
PARTITION_MAX_SUB_DEVICES = 77 ## [uint32_t] maximum number of sub-devices when the device is
508509
## partitioned
509510
PARTITION_AFFINITY_DOMAIN = 78 ## [::ur_device_affinity_domain_flags_t] Returns a bit-field of the
@@ -569,16 +570,39 @@ def __str__(self):
569570

570571

571572
###############################################################################
572-
## @brief Device partition property type
573-
class ur_device_partition_property_t(c_intptr_t):
574-
pass
573+
## @brief Device affinity domain
574+
class ur_device_affinity_domain_flags_v(IntEnum):
575+
NUMA = UR_BIT(0) ## Split the device into sub devices comprised of compute units that
576+
## share a NUMA node.
577+
L4_CACHE = UR_BIT(1) ## Split the device into sub devices comprised of compute units that
578+
## share a level 4 data cache.
579+
L3_CACHE = UR_BIT(2) ## Split the device into sub devices comprised of compute units that
580+
## share a level 3 data cache.
581+
L2_CACHE = UR_BIT(3) ## Split the device into sub devices comprised of compute units that
582+
## share a level 2 data cache.
583+
L1_CACHE = UR_BIT(4) ## Split the device into sub devices comprised of compute units that
584+
## share a level 1 data cache.
585+
NEXT_PARTITIONABLE = UR_BIT(5) ## Split the device along the next partitionable affinity domain.
586+
## The implementation shall find the first level along which the device
587+
## or sub device may be further subdivided in the order:
588+
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA,
589+
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE,
590+
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE,
591+
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE,
592+
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE,
593+
## and partition the device into sub devices comprised of compute units
594+
## that share memory subsystems at this level.
595+
596+
class ur_device_affinity_domain_flags_t(c_int):
597+
def __str__(self):
598+
return hex(self.value)
599+
575600

576601
###############################################################################
577602
## @brief Partition Properties
578603
class ur_device_partition_v(IntEnum):
579604
EQUALLY = 0x1086 ## Partition Equally
580605
BY_COUNTS = 0x1087 ## Partition by counts
581-
BY_COUNTS_LIST_END = 0x0 ## End of by counts list
582606
BY_AFFINITY_DOMAIN = 0x1088 ## Partition by affinity domain
583607
BY_CSLICE = 0x1089 ## Partition by c-slice
584608

@@ -587,6 +611,37 @@ def __str__(self):
587611
return str(ur_device_partition_v(self.value))
588612

589613

614+
###############################################################################
615+
## @brief Device partition value.
616+
class ur_device_partition_value_t(Structure):
617+
_fields_ = [
618+
("equally", c_ulong), ## [in] Number of compute units per sub-device when partitioning with
619+
## ::UR_DEVICE_PARTITION_EQUALLY.
620+
("count", c_ulong), ## [in] Number of compute units in a sub-device when partitioning with
621+
## ::UR_DEVICE_PARTITION_BY_COUNTS.
622+
("affinity_domain", ur_device_affinity_domain_flags_t) ## [in] The affinity domain to partition for when partitioning with
623+
## $UR_DEVICE_PARTITION_BY_AFFINITY_DOMAIN.
624+
]
625+
626+
###############################################################################
627+
## @brief Device partition property
628+
class ur_device_partition_property_t(Structure):
629+
_fields_ = [
630+
("type", ur_device_partition_t), ## [in] The partitioning type to be used.
631+
("value", ur_device_partition_value_t) ## [in] The paritioning value.
632+
]
633+
634+
###############################################################################
635+
## @brief Device Partition Properties
636+
class ur_device_partition_properties_t(Structure):
637+
_fields_ = [
638+
("stype", ur_structure_type_t), ## [in] type of this structure, must be
639+
## ::UR_STRUCTURE_TYPE_DEVICE_PARTITION_PROPERTIES
640+
("pNext", c_void_p), ## [in,out][optional] pointer to extension-specific structure
641+
("pProperties", POINTER(ur_device_partition_property_t)), ## [in] Pointer to the beginning of the properties array.
642+
("PropCount", c_size_t) ## [in] The length of properties pointed to by `pProperties`.
643+
]
644+
590645
###############################################################################
591646
## @brief FP capabilities
592647
class ur_device_fp_capability_flags_v(IntEnum):
@@ -639,35 +694,6 @@ def __str__(self):
639694
return hex(self.value)
640695

641696

642-
###############################################################################
643-
## @brief Device affinity domain
644-
class ur_device_affinity_domain_flags_v(IntEnum):
645-
NUMA = UR_BIT(0) ## Split the device into sub devices comprised of compute units that
646-
## share a NUMA node.
647-
L4_CACHE = UR_BIT(1) ## Split the device into sub devices comprised of compute units that
648-
## share a level 4 data cache.
649-
L3_CACHE = UR_BIT(2) ## Split the device into sub devices comprised of compute units that
650-
## share a level 3 data cache.
651-
L2_CACHE = UR_BIT(3) ## Split the device into sub devices comprised of compute units that
652-
## share a level 2 data cache.
653-
L1_CACHE = UR_BIT(4) ## Split the device into sub devices comprised of compute units that
654-
## share a level 1 data cache.
655-
NEXT_PARTITIONABLE = UR_BIT(5) ## Split the device along the next partitionable affinity domain.
656-
## The implementation shall find the first level along which the device
657-
## or sub device may be further subdivided in the order:
658-
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_NUMA,
659-
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L4_CACHE,
660-
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L3_CACHE,
661-
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L2_CACHE,
662-
## ::UR_DEVICE_AFFINITY_DOMAIN_FLAG_L1_CACHE,
663-
## and partition the device into sub devices comprised of compute units
664-
## that share memory subsystems at this level.
665-
666-
class ur_device_affinity_domain_flags_t(c_int):
667-
def __str__(self):
668-
return hex(self.value)
669-
670-
671697
###############################################################################
672698
## @brief Native device creation properties
673699
class ur_device_native_properties_t(Structure):
@@ -2805,9 +2831,9 @@ class ur_usm_dditable_t(Structure):
28052831
###############################################################################
28062832
## @brief Function-pointer for urDevicePartition
28072833
if __use_win_types:
2808-
_urDevicePartition_t = WINFUNCTYPE( ur_result_t, ur_device_handle_t, POINTER(ur_device_partition_property_t), c_ulong, POINTER(ur_device_handle_t), POINTER(c_ulong) )
2834+
_urDevicePartition_t = WINFUNCTYPE( ur_result_t, ur_device_handle_t, POINTER(ur_device_partition_properties_t), c_ulong, POINTER(ur_device_handle_t), POINTER(c_ulong) )
28092835
else:
2810-
_urDevicePartition_t = CFUNCTYPE( ur_result_t, ur_device_handle_t, POINTER(ur_device_partition_property_t), c_ulong, POINTER(ur_device_handle_t), POINTER(c_ulong) )
2836+
_urDevicePartition_t = CFUNCTYPE( ur_result_t, ur_device_handle_t, POINTER(ur_device_partition_properties_t), c_ulong, POINTER(ur_device_handle_t), POINTER(c_ulong) )
28112837

28122838
###############################################################################
28132839
## @brief Function-pointer for urDeviceSelectBinary

0 commit comments

Comments
 (0)