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

Commit 249d196

Browse files
Adding test to ensure the exception errc values thrown by create_sub_devices is correct (#488)
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
1 parent 6ff631b commit 249d196

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

SYCL/Basic/subdevice.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,30 @@ int main() {
142142
} catch (feature_not_supported) {
143143
// okay skip it
144144
}
145+
146+
// test exception
147+
try {
148+
const size_t out_of_bounds = std::numeric_limits<size_t>::max();
149+
const auto partition =
150+
sycl::info::partition_property::partition_equally;
151+
dev.create_sub_devices<partition>(out_of_bounds);
152+
std::cout << "we should not be here. Exception not thrown."
153+
<< std::endl;
154+
return 1;
155+
} catch (sycl::exception &e) {
156+
const auto code = e.code();
157+
158+
if (!(code == sycl::errc::feature_not_supported ||
159+
code == sycl::errc::invalid)) {
160+
std::cout << "SYCL exception has wrong error code: " << code
161+
<< std::endl;
162+
return 1;
163+
}
164+
} catch (...) {
165+
std::cout << "Something besides a sycl::exception was thrown."
166+
<< std::endl;
167+
return 1;
168+
}
145169
}
146170
} catch (exception e) {
147171
std::cout << "SYCL exception caught: " << e.what() << std::endl;

0 commit comments

Comments
 (0)