@@ -598,6 +598,16 @@ DPCTLDevice_CreateSubDevicesEqually(__dpctl_keep const DPCTLSyclDeviceRef DRef,
598
598
return nullptr ;
599
599
}
600
600
auto D = unwrap<device>(DRef);
601
+ const auto &supported_properties =
602
+ D->get_info <info::device::partition_properties>();
603
+ const auto &beg_it = supported_properties.begin ();
604
+ const auto &end_it = supported_properties.end ();
605
+ if (std::find (beg_it, end_it,
606
+ info::partition_property::partition_equally) == end_it)
607
+ {
608
+ // device does not support partition equally
609
+ return nullptr ;
610
+ }
601
611
try {
602
612
auto subDevices = D->create_sub_devices <
603
613
info::partition_property::partition_equally>(count);
@@ -631,6 +641,16 @@ DPCTLDevice_CreateSubDevicesByCounts(__dpctl_keep const DPCTLSyclDeviceRef DRef,
631
641
}
632
642
if (DRef) {
633
643
auto D = unwrap<device>(DRef);
644
+ const auto &supported_properties =
645
+ D->get_info <info::device::partition_properties>();
646
+ const auto &beg_it = supported_properties.begin ();
647
+ const auto &end_it = supported_properties.end ();
648
+ if (std::find (beg_it, end_it,
649
+ info::partition_property::partition_by_counts) == end_it)
650
+ {
651
+ // device does not support partition by counts
652
+ return nullptr ;
653
+ }
634
654
std::vector<std::remove_pointer<decltype (D)>::type> subDevices;
635
655
try {
636
656
subDevices = D->create_sub_devices <
@@ -661,9 +681,29 @@ __dpctl_give DPCTLDeviceVectorRef DPCTLDevice_CreateSubDevicesByAffinity(
661
681
vecTy *Devices = nullptr ;
662
682
auto D = unwrap<device>(DRef);
663
683
if (D) {
684
+ const auto &supported_properties =
685
+ D->get_info <info::device::partition_properties>();
686
+ const auto &beg_it = supported_properties.begin ();
687
+ const auto &end_it = supported_properties.end ();
688
+ if (std::find (beg_it, end_it,
689
+ info::partition_property::partition_by_affinity_domain) ==
690
+ end_it)
691
+ {
692
+ // device does not support partition by affinity domain
693
+ return nullptr ;
694
+ }
664
695
try {
665
696
auto domain = DPCTL_DPCTLPartitionAffinityDomainTypeToSycl (
666
697
PartitionAffinityDomainTy);
698
+ const auto &supported_affinity_domains =
699
+ D->get_info <info::device::partition_affinity_domains>();
700
+ const auto &beg_it = supported_affinity_domains.begin ();
701
+ const auto &end_it = supported_affinity_domains.end ();
702
+ if (std::find (beg_it, end_it, domain) == end_it) {
703
+ // device does not support partitioning by this particular
704
+ // affinity domain
705
+ return nullptr ;
706
+ }
667
707
auto subDevices = D->create_sub_devices <
668
708
info::partition_property::partition_by_affinity_domain>(domain);
669
709
Devices = new vecTy ();
0 commit comments