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

Commit 12fdee6

Browse files
[SYCL] test needs to ensure partition_equally is supported before exercising (#1027)
Signed-off-by: Chris Perkins <[email protected]>
1 parent 533dc7a commit 12fdee6

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

SYCL/Basic/partition_supported.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
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
10-
supported by this SYCL device; a vector of info::partition_property. If this
11-
SYCL device cannot be partitioned into at least two sub devices then the
12-
returned vector **must be empty**.
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
1311
14-
2) [create_sub_devices()]: If the SYCL device
15-
does not support info::partition_property::partition_by_affinity_domain or the
16-
SYCL device does not support the info::partition_affinity_domain provided, an
17-
exception with the **feature_not_supported error code must be thrown**.
12+
2) If the SYCL device does not support
13+
info::partition_property::partition_by_affinity_domain or the SYCL device does
14+
not support the info::partition_affinity_domain provided, an exception with the
15+
**feature_not_supported error code must be thrown**.
1816
*/
1917

2018
#include <CL/sycl.hpp>
@@ -57,24 +55,10 @@ int main() {
5755

5856
auto dev = cl::sycl::device(cl::sycl::default_selector());
5957

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-
}
58+
// 1 - check exceed max_compute_units
59+
cl::sycl::info::partition_property partitionEqually =
60+
cl::sycl::info::partition_property::partition_equally;
61+
if (supports_partition_property(dev, partitionEqually)) {
7862
auto maxUnits = dev.get_info<sycl::info::device::max_compute_units>();
7963
try {
8064
std::vector<sycl::device> v = dev.create_sub_devices<
@@ -93,6 +77,26 @@ int main() {
9377
return -1;
9478
}
9579
}
80+
}
81+
82+
// 2 - check affinity
83+
cl::sycl::info::partition_property partitionProperty =
84+
cl::sycl::info::partition_property::partition_by_affinity_domain;
85+
cl::sycl::info::partition_affinity_domain affinityDomain =
86+
cl::sycl::info::partition_affinity_domain::next_partitionable;
87+
if (supports_partition_property(dev, partitionProperty)) {
88+
if (supports_affinity_domain(dev, partitionProperty, affinityDomain)) {
89+
auto subDevices = dev.create_sub_devices<
90+
cl::sycl::info::partition_property::partition_by_affinity_domain>(
91+
affinityDomain);
92+
93+
if (subDevices.size() < 2) {
94+
std::cerr << "device::create_sub_device(info::partition_affinity_"
95+
"domain) should have returned at least 2 devices"
96+
<< std::endl;
97+
return -1;
98+
}
99+
}
96100
} else {
97101
try {
98102
auto subDevices = dev.create_sub_devices<

0 commit comments

Comments
 (0)