@@ -598,6 +598,16 @@ DPCTLDevice_CreateSubDevicesEqually(__dpctl_keep const DPCTLSyclDeviceRef DRef,
598598 return nullptr ;
599599 }
600600 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+ }
601611 try {
602612 auto subDevices = D->create_sub_devices <
603613 info::partition_property::partition_equally>(count);
@@ -631,6 +641,16 @@ DPCTLDevice_CreateSubDevicesByCounts(__dpctl_keep const DPCTLSyclDeviceRef DRef,
631641 }
632642 if (DRef) {
633643 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+ }
634654 std::vector<std::remove_pointer<decltype (D)>::type> subDevices;
635655 try {
636656 subDevices = D->create_sub_devices <
@@ -661,9 +681,29 @@ __dpctl_give DPCTLDeviceVectorRef DPCTLDevice_CreateSubDevicesByAffinity(
661681 vecTy *Devices = nullptr ;
662682 auto D = unwrap<device>(DRef);
663683 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+ }
664695 try {
665696 auto domain = DPCTL_DPCTLPartitionAffinityDomainTypeToSycl (
666697 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+ }
667707 auto subDevices = D->create_sub_devices <
668708 info::partition_property::partition_by_affinity_domain>(domain);
669709 Devices = new vecTy ();
0 commit comments