Skip to content

Commit

Permalink
Add try/catch clauses
Browse files Browse the repository at this point in the history
  • Loading branch information
lbushi25 committed Jan 29, 2024
1 parent eb25955 commit 1091fe9
Showing 1 changed file with 70 additions and 56 deletions.
126 changes: 70 additions & 56 deletions sycl/test-e2e/Annotated_arg_ptr/annotated_arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,41 @@ MyStruct<T> operator<<(const MyStruct<T> &lhs, const MyStruct<T> &rhs) {
int main() {
queue Q;

try {
auto *a = malloc_shared<int>(8, Q);
}
catch (sycl::exception&) { a = nullptr; }
try {
auto *a = malloc_shared<int>(8, Q);
} catch (sycl::exception &) {
a = nullptr;
}
auto a_ptr = annotated_arg{a};
for (int i = 0; i < 8; i++)
a_ptr[i] = i;

try {
auto *b = malloc_shared<int>(4, Q);
}
catch (sycl::exception&) { b = nullptr; }
try {
auto *b = malloc_shared<int>(4, Q);
} catch (sycl::exception &) {
b = nullptr;
}
auto b_ptr = annotated_arg{b};

try {
auto *c = malloc_shared<test>(1, Q);
}
catch (sycl::exception&) { c = nullptr; }
try {
c->b = malloc_shared<int>(1, Q);
}
catch (sycl::exception&) { c->b = nullptr; }
try {
auto *c = malloc_shared<test>(1, Q);
} catch (sycl::exception &) {
c = nullptr;
}
try {
c->b = malloc_shared<int>(1, Q);
} catch (sycl::exception &) {
c->b = nullptr;
}
auto c_ptr = annotated_arg{c};
c_ptr->a = 0;
c_ptr->b[0] = 0;

try {
auto *d = malloc_shared<int>(4, Q);
}
catch (sycl::exception&) { d = nullptr; }
try {
auto *d = malloc_shared<int>(4, Q);
} catch (sycl::exception &) {
d = nullptr;
}
auto d_ptr = annotated_arg{d};
for (int i = 0; i < 4; i++)
d_ptr[i] = i;
Expand All @@ -116,53 +121,62 @@ catch (sycl::exception&) { d = nullptr; }
annotated_arg<MyStruct<int>> g = MyStruct(3);
annotated_arg<MyStruct<int>> h = MyStruct(2);

try {
auto *r1 = malloc_shared<MyStruct<int>>(5, Q);
}
catch (sycl::exception&) { r1 = nullptr; }
try {
auto *r2 = malloc_shared<MyStruct<int>>(5, Q);
}
catch (sycl::exception&) { r2 = nullptr; }
try {
auto *r3 = malloc_shared<MyStruct<int>>(5, Q);
}
catch (sycl::exception&) { r3 = nullptr; }
try {
auto *r1 = malloc_shared<MyStruct<int>>(5, Q);
} catch (sycl::exception &) {
r1 = nullptr;
}
try {
auto *r2 = malloc_shared<MyStruct<int>>(5, Q);
} catch (sycl::exception &) {
r2 = nullptr;
}
try {
auto *r3 = malloc_shared<MyStruct<int>>(5, Q);
} catch (sycl::exception &) {
r3 = nullptr;
}

// testing logical overloaded operators
annotated_arg<MyStruct<bool>> m = MyStruct(true);
annotated_arg<MyStruct<bool>> n = MyStruct(false);

try {
auto *r4 = malloc_shared<MyStruct<bool>>(3, Q);
}
catch (sycl::exception&) { r4 = nullptr; }
try {
auto *r5 = malloc_shared<MyStruct<bool>>(3, Q);
}
catch (sycl::exception&) { r5 = nullptr; }
try {
auto *r6 = malloc_shared<MyStruct<bool>>(3, Q);
}
catch (sycl::exception&) { r6 = nullptr; }
try {
auto *r4 = malloc_shared<MyStruct<bool>>(3, Q);
} catch (sycl::exception &) {
r4 = nullptr;
}
try {
auto *r5 = malloc_shared<MyStruct<bool>>(3, Q);
} catch (sycl::exception &) {
r5 = nullptr;
}
try {
auto *r6 = malloc_shared<MyStruct<bool>>(3, Q);
} catch (sycl::exception &) {
r6 = nullptr;
}

// testing bit shift overloaded operators
annotated_arg<MyStruct<int>> x = MyStruct(1);
annotated_arg<MyStruct<int>> y = MyStruct(2);
annotated_arg<MyStruct<int>> z = MyStruct(4);

try {
auto *r7 = malloc_shared<MyStruct<int>>(2, Q);
}
catch (sycl::exception&) { r7 = nullptr; }
try {
auto *r8 = malloc_shared<MyStruct<int>>(2, Q);
}
catch (sycl::exception&) { r8 = nullptr; }
try {
auto *r9 = malloc_shared<MyStruct<int>>(2, Q);
}
catch (sycl::exception&) { r9 = nullptr; }
try {
auto *r7 = malloc_shared<MyStruct<int>>(2, Q);
} catch (sycl::exception &) {
r7 = nullptr;
}
try {
auto *r8 = malloc_shared<MyStruct<int>>(2, Q);
} catch (sycl::exception &) {
r8 = nullptr;
}
try {
auto *r9 = malloc_shared<MyStruct<int>>(2, Q);
} catch (sycl::exception &) {
r9 = nullptr;
}

Q.single_task([=]() {
a_ptr[0] += 1;
Expand Down

0 comments on commit 1091fe9

Please sign in to comment.