Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions sycl/test-e2e/SYCLBIN/Inputs/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,75 @@ int main(int argc, char *argv[]) {

// Compile the bundles.
auto KBObj1 = sycl::compile(KBInput1);
auto KBObj1Extra = sycl::compile(KBInput1);
auto KBObj2 = sycl::compile(KBInput2);
auto KBObj2Extra = sycl::compile(KBInput2);
#elif defined(SYCLBIN_OBJECT_STATE)
auto KBObj1 = syclex::get_kernel_bundle<sycl::bundle_state::object>(
Q.get_context(), {Q.get_device()}, std::string{argv[1]});
auto KBObj1Extra = syclex::get_kernel_bundle<sycl::bundle_state::object>(
Q.get_context(), {Q.get_device()}, std::string{argv[1]});
auto KBObj2 = syclex::get_kernel_bundle<sycl::bundle_state::object>(
Q.get_context(), {Q.get_device()}, std::string{argv[2]});
auto KBObj2Extra = syclex::get_kernel_bundle<sycl::bundle_state::object>(
Q.get_context(), {Q.get_device()}, std::string{argv[2]});
#else // defined(SYCLBIN_EXECUTABLE_STATE)
#error "Test does not work with executable state."
#endif

// Check that linking without all symbols resolved will result in an
// exception.
try {
auto KBExeFail = syclexp::link(
{KBObj2}, syclexp::properties{syclexp::fast_link{USE_FAST_LINK}});
std::cout << "No exception thrown for only KBObj2" << std::endl;
++Failed;
} catch (sycl::exception &E) {
if (E.code() != sycl::make_error_code(sycl::errc::invalid)) {
std::cout << "Unexpected exception code for only KBObj2" << std::endl;
++Failed;
}
} catch (...) {
std::cout << "Caught unexpected exception for only KBObj2" << std::endl;
++Failed;
}

// Check that linking bundles with conflicting kernels will result in an
// exception.
try {
auto KBExeFail =
syclexp::link({KBObj1, KBObj1Extra, KBObj2},
syclexp::properties{syclexp::fast_link{USE_FAST_LINK}});
std::cout << "No exception thrown for double KBObj1" << std::endl;
++Failed;
} catch (sycl::exception &E) {
if (E.code() != sycl::make_error_code(sycl::errc::invalid)) {
std::cout << "Unexpected exception code for double KBObj1" << std::endl;
++Failed;
}
} catch (...) {
std::cout << "Caught unexpected exception for double KBObj1" << std::endl;
++Failed;
}

// Check that linking bundles with conflicting exported symbols will result in
// an exception.
try {
auto KBExeFail =
syclexp::link({KBObj1, KBObj2, KBObj2Extra},
syclexp::properties{syclexp::fast_link{USE_FAST_LINK}});
std::cout << "No exception thrown for double KBObj2" << std::endl;
++Failed;
} catch (sycl::exception &E) {
if (E.code() != sycl::make_error_code(sycl::errc::invalid)) {
std::cout << "Unexpected exception code for double KBObj2" << std::endl;
++Failed;
}
} catch (...) {
std::cout << "Caught unexpected exception for double KBObj2" << std::endl;
++Failed;
}

// Link the bundles.
auto KBExe = syclexp::link(
{KBObj1, KBObj2}, syclexp::properties{syclexp::fast_link{USE_FAST_LINK}});
Expand Down
Loading