Skip to content

[WIP][SYCL][CUDA] Lit exceptions #1304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions sycl/test/aot/accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down
1 change: 1 addition & 0 deletions sycl/test/aot/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down
1 change: 1 addition & 0 deletions sycl/test/aot/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down
1 change: 1 addition & 0 deletions sycl/test/aot/multiple-devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down
1 change: 1 addition & 0 deletions sycl/test/aot/with-llvm-bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down
12 changes: 6 additions & 6 deletions sycl/test/basic_tests/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int main() {

} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
throw;
}
}

Expand All @@ -237,7 +237,7 @@ int main() {
buf.get_access<sycl::access::mode::discard_read_write>();
} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
throw;
}
}

Expand Down Expand Up @@ -349,11 +349,11 @@ int main() {

auto host_acc = buf.get_access<sycl::access::mode::read>();
for (int i = 0; i != 3; ++i)
assert(host_acc[i] == 42);
CHECK(host_acc[i] == 42);

} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
throw;
}
}

Expand All @@ -376,8 +376,8 @@ int main() {
}
assert(data == 399);
} catch (sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
std::cerr << "SYCL exception caught: " << e.what();
throw;
}
}

Expand Down
17 changes: 7 additions & 10 deletions sycl/test/basic_tests/buffer/buffer_full_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,21 @@ void check_copy_host_to_device(cl::sycl::queue &Queue) {
// check that there was no data corruption/loss
for (int i = 0; i < size; ++i) {
for (int j = 0; j < size; ++j)
assert(expected_res_3[i * size + j] == acc_1[i][j]);
CHECK(expected_res_3[i * size + j] == acc_1[i][j]);
}

for (int i = 0; i < size / 2; ++i)
for (int j = 0; j < size / 2; ++j)
assert(expected_res_4[i * size / 2 + j] == acc_2[i][j]);
CHECK(expected_res_4[i * size / 2 + j] == acc_2[i][j]);
}
}

int main() {
try {
cl::sycl::queue Queue;
check_copy_host_to_device(Queue);
check_copy_device_to_host(Queue);
check_fill(Queue);
} catch (cl::sycl::exception &ex) {
std::cerr << ex.what() << std::endl;
}
// Not catching exceptions to make test fail instead.
cl::sycl::queue Queue;
check_copy_host_to_device(Queue);
check_copy_device_to_host(Queue);
check_fill(Queue);

return 0;
}
3 changes: 3 additions & 0 deletions sycl/test/basic_tests/buffer/subbuffer_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ int main() {
clReleaseProgram(clProgram);
} catch (exception &ex) {
std::cout << ex.what() << std::endl;
throw;
}

for (int i = 0; i < NSize; ++i) {
Expand Down Expand Up @@ -173,6 +174,7 @@ int main() {
clReleaseProgram(clProgram);
} catch (exception &ex) {
std::cout << ex.what() << std::endl;
throw;
}

for (int i = 0; i < NSize; ++i) {
Expand Down Expand Up @@ -263,6 +265,7 @@ int main() {
clReleaseProgram(clProgram);
} catch (exception &ex) {
std::cout << ex.what() << std::endl;
throw;
}

for (int i = 0; i < NSize; ++i) {
Expand Down
1 change: 1 addition & 0 deletions sycl/test/basic_tests/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int main() {
context c;
} catch (device_error e) {
std::cout << "Failed to create device for context" << std::endl;
throw;
}

auto devices = device::get_devices();
Expand Down
3 changes: 2 additions & 1 deletion sycl/test/basic_tests/device_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ int test_strideN(size_t stride) {
std::cout << e.what();
}
}
throw "ERROR: Asynchronous exception(s)";
});

buffer<int, 1> out_buf(out_data, range<1>(nElems));
Expand Down Expand Up @@ -109,7 +110,7 @@ int test_strideN(size_t stride) {

} catch (exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 2;
throw;
}

return check_results(out_data, stride);
Expand Down
6 changes: 4 additions & 2 deletions sycl/test/basic_tests/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ int main() {
cl::sycl::event e;
} catch (cl::sycl::device_error e) {
std::cout << "Failed to create device for event" << std::endl;
throw;
}
try {
std::cout << "Try create OpenCL event" << std::endl;
Expand All @@ -28,11 +29,10 @@ int main() {
<< ((cl_e.get() == u_e) ? " matches " : " does not match ")
<< u_e << std::endl;

} else {
std::cout << "Failed to create OpenCL context" << std::endl;
}
} catch (cl::sycl::device_error e) {
std::cout << "Failed to create device for context" << std::endl;
throw;
}

{
Expand Down Expand Up @@ -106,4 +106,6 @@ int main() {
}
}
}

return 0;
}
2 changes: 1 addition & 1 deletion sycl/test/basic_tests/event_async_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main() {

e.wait_and_throw();
return 1;
} catch (runtime_error e) {
} catch (runtime_error expectedException) {
return 0;
}
}
1 change: 1 addition & 0 deletions sycl/test/basic_tests/image_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ int main() {
EventRet.wait();
} catch (const s::exception &E) {
std::cout << "SYCL exception caught: " << E.what() << std::endl;
throw;
}

s::float4 Expected{10.f, 20.f, 30.f, 40.f};
Expand Down
2 changes: 2 additions & 0 deletions sycl/test/basic_tests/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,6 @@ int main() {
std::cout << separator << "Platform from context information\n" << separator;
auto cplt = ctx.get_info<cl::sycl::info::context::platform>();
print_info<info::platform::name, string_class>(cplt, "Name");

return 0;
}
1 change: 1 addition & 0 deletions sycl/test/basic_tests/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int main() {

} catch (device_error e) {
std::cout << "Failed to create device for context" << std::endl;
throw;
}

auto devices = device::get_devices();
Expand Down
Loading