Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 1733d55

Browse files
committed
test needs to ensure partition_equally is supported before exercising it
Signed-off-by: Chris Perkins <[email protected]>
1 parent 5b15a63 commit 1733d55

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

SYCL/Basic/partition_supported.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
// Nvidia should not allow sub_devices but does not throw corresponding error.
77
// XFAIL: hip_nvidia
88
/* Check that:
9-
1) [info::device::partition_properties]: returns the partition properties
9+
1) if partition_equally is supported, then we check that the correct
10+
invalid errc is returned if more than max_compute_units are requested
11+
12+
2) [info::device::partition_properties]: returns the partition properties
1013
supported by this SYCL device; a vector of info::partition_property. If this
1114
SYCL device cannot be partitioned into at least two sub devices then the
1215
returned vector **must be empty**.
1316
14-
2) [create_sub_devices()]: If the SYCL device
17+
3) [create_sub_devices()]: If the SYCL device
1518
does not support info::partition_property::partition_by_affinity_domain or the
1619
SYCL device does not support the info::partition_affinity_domain provided, an
1720
exception with the **feature_not_supported error code must be thrown**.
@@ -57,24 +60,10 @@ int main() {
5760

5861
auto dev = cl::sycl::device(cl::sycl::default_selector());
5962

60-
cl::sycl::info::partition_property partitionProperty =
61-
cl::sycl::info::partition_property::partition_by_affinity_domain;
62-
cl::sycl::info::partition_affinity_domain affinityDomain =
63-
cl::sycl::info::partition_affinity_domain::next_partitionable;
64-
65-
if (supports_partition_property(dev, partitionProperty)) {
66-
if (supports_affinity_domain(dev, partitionProperty, affinityDomain)) {
67-
auto subDevices = dev.create_sub_devices<
68-
cl::sycl::info::partition_property::partition_by_affinity_domain>(
69-
affinityDomain);
70-
71-
if (subDevices.size() < 2) {
72-
std::cerr << "device::create_sub_device(info::partition_affinity_"
73-
"domain) should have returned at least 2 devices"
74-
<< std::endl;
75-
return -1;
76-
}
77-
}
63+
// check exceed max_compute_units
64+
cl::sycl::info::partition_property partitionEqually =
65+
cl::sycl::info::partition_property::partition_equally;
66+
if (supports_partition_property(dev, partitionEqually)) {
7867
auto maxUnits = dev.get_info<sycl::info::device::max_compute_units>();
7968
try {
8069
std::vector<sycl::device> v = dev.create_sub_devices<
@@ -93,6 +82,27 @@ int main() {
9382
return -1;
9483
}
9584
}
85+
}
86+
87+
cl::sycl::info::partition_property partitionProperty =
88+
cl::sycl::info::partition_property::partition_by_affinity_domain;
89+
cl::sycl::info::partition_affinity_domain affinityDomain =
90+
cl::sycl::info::partition_affinity_domain::next_partitionable;
91+
92+
if (supports_partition_property(dev, partitionProperty)) {
93+
if (supports_affinity_domain(dev, partitionProperty, affinityDomain)) {
94+
auto subDevices = dev.create_sub_devices<
95+
cl::sycl::info::partition_property::partition_by_affinity_domain>(
96+
affinityDomain);
97+
98+
if (subDevices.size() < 2) {
99+
std::cerr << "device::create_sub_device(info::partition_affinity_"
100+
"domain) should have returned at least 2 devices"
101+
<< std::endl;
102+
return -1;
103+
}
104+
}
105+
96106
} else {
97107
try {
98108
auto subDevices = dev.create_sub_devices<

0 commit comments

Comments
 (0)