From 1c2f31aa1f390fe9ceb19417b8207d6e40929b97 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Tue, 30 Jan 2024 09:58:52 -0800 Subject: [PATCH] Handle malloc_shared exceptions in tests --- .../Annotated_arg_ptr/annotated_arg.cpp | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp b/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp index a512f9cfd87d7..d6774bc7ae70a 100644 --- a/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp +++ b/sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp @@ -3,7 +3,7 @@ // #include "common.hpp" - +#include struct test { int a; int *b; @@ -76,40 +76,40 @@ MyStruct operator<<(const MyStruct &lhs, const MyStruct &rhs) { int main() { queue Q; + int *a = nullptr; try { - auto *a = malloc_shared(8, Q); + a = malloc_shared(8, Q); } catch (sycl::exception &) { - a = nullptr; } auto a_ptr = annotated_arg{a}; for (int i = 0; i < 8; i++) a_ptr[i] = i; - + std::cout << "Hello!" << std::endl; + int *b = nullptr; try { - auto *b = malloc_shared(4, Q); + b = malloc_shared(4, Q); } catch (sycl::exception &) { - b = nullptr; } auto b_ptr = annotated_arg{b}; + test *c = nullptr; try { - auto *c = malloc_shared(1, Q); + c = malloc_shared(1, Q); } catch (sycl::exception &) { - c = nullptr; } + c->b = nullptr; try { c->b = malloc_shared(1, Q); } catch (sycl::exception &) { - c->b = nullptr; } auto c_ptr = annotated_arg{c}; c_ptr->a = 0; c_ptr->b[0] = 0; + int *d = nullptr; try { - auto *d = malloc_shared(4, Q); + d = malloc_shared(4, Q); } catch (sycl::exception &) { - d = nullptr; } auto d_ptr = annotated_arg{d}; for (int i = 0; i < 4; i++) @@ -121,40 +121,40 @@ int main() { annotated_arg> g = MyStruct(3); annotated_arg> h = MyStruct(2); + MyStruct *r1 = nullptr; try { - auto *r1 = malloc_shared>(5, Q); + r1 = malloc_shared>(5, Q); } catch (sycl::exception &) { - r1 = nullptr; } + MyStruct *r2 = nullptr; try { - auto *r2 = malloc_shared>(5, Q); + r2 = malloc_shared>(5, Q); } catch (sycl::exception &) { - r2 = nullptr; } + MyStruct *r3 = nullptr; try { - auto *r3 = malloc_shared>(5, Q); + r3 = malloc_shared>(5, Q); } catch (sycl::exception &) { - r3 = nullptr; } // testing logical overloaded operators annotated_arg> m = MyStruct(true); annotated_arg> n = MyStruct(false); + MyStruct *r4 = nullptr; try { - auto *r4 = malloc_shared>(3, Q); + r4 = malloc_shared>(3, Q); } catch (sycl::exception &) { - r4 = nullptr; } + MyStruct *r5 = nullptr; try { - auto *r5 = malloc_shared>(3, Q); + r5 = malloc_shared>(3, Q); } catch (sycl::exception &) { - r5 = nullptr; } + MyStruct *r6 = nullptr; try { - auto *r6 = malloc_shared>(3, Q); + r6 = malloc_shared>(3, Q); } catch (sycl::exception &) { - r6 = nullptr; } // testing bit shift overloaded operators @@ -162,20 +162,20 @@ int main() { annotated_arg> y = MyStruct(2); annotated_arg> z = MyStruct(4); + MyStruct *r7 = nullptr; try { - auto *r7 = malloc_shared>(2, Q); + r7 = malloc_shared>(2, Q); } catch (sycl::exception &) { - r7 = nullptr; } + MyStruct *r8 = nullptr; try { - auto *r8 = malloc_shared>(2, Q); + r8 = malloc_shared>(2, Q); } catch (sycl::exception &) { - r8 = nullptr; } + MyStruct *r9 = nullptr; try { - auto *r9 = malloc_shared>(2, Q); + r9 = malloc_shared>(2, Q); } catch (sycl::exception &) { - r9 = nullptr; } Q.single_task([=]() {