Skip to content

Commit

Permalink
Merge pull request #992 from dyniols/udpate_device_info_test
Browse files Browse the repository at this point in the history
Update checks for `sycl::info::device::preferred_interop_user_sync` and  `sycl::info::device::profile` in `device_info` test
  • Loading branch information
bader authored Jan 15, 2025
2 parents 684620e + ea27006 commit 02f35e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
19 changes: 19 additions & 0 deletions tests/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ void check_get_info_param(const ObjectT& object) {
check_return_type<ReturnT>(returnValue, "object::get_info()");
}

/**
* @brief Helper function to check an info parameter for specific backend.
*/
template <typename InfoDesc, typename ReturnT, sycl::backend Backend,
typename ObjectT>
void check_get_info_param_backend_specific(const ObjectT& object) {
try {
check_get_info_param<InfoDesc, ReturnT>(object);
CHECK(object.get_backend() == Backend);
} catch (const sycl::exception& e) {
#ifndef SYCL_CTS_COMPILING_WITH_HIPSYCL
CHECK(e.code() == sycl::make_error_code(sycl::errc::invalid));
#endif
CHECK(object.get_backend() != Backend);
} catch (...) {
FAIL("Unexpected exception");
}
}

/**
* @deprecated Use overload without logger.
*/
Expand Down
9 changes: 6 additions & 3 deletions tests/device/device_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ TEST_CASE("device info", "[device]") {
check_get_info_param<sycl::info::device::name, std::string>(dev);
check_get_info_param<sycl::info::device::vendor, std::string>(dev);
check_get_info_param<sycl::info::device::driver_version, std::string>(dev);
check_get_info_param<sycl::info::device::profile, std::string>(dev);
check_get_info_param_backend_specific<sycl::info::device::profile,
std::string, sycl::backend::opencl>(
dev);
check_get_info_param<sycl::info::device::version, std::string>(dev);
check_get_info_param<sycl::info::device::backend_version, std::string>(dev);

Expand All @@ -230,8 +232,9 @@ TEST_CASE("device info", "[device]") {
check_get_info_param<sycl::info::device::extensions,
std::vector<std::string>>(dev);
check_get_info_param<sycl::info::device::printf_buffer_size, size_t>(dev);
check_get_info_param<sycl::info::device::preferred_interop_user_sync, bool>(
dev);
check_get_info_param_backend_specific<
sycl::info::device::preferred_interop_user_sync, bool,
sycl::backend::opencl>(dev);
auto SupportedProperties =
dev.get_info<sycl::info::device::partition_properties>();
if (std::find(SupportedProperties.begin(), SupportedProperties.end(),
Expand Down

0 comments on commit 02f35e9

Please sign in to comment.