-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] SYCL 2020 exceptions support #4072
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
Merged
romanovvlad
merged 17 commits into
intel:sycl
from
cperkinsintel:cperkins-exceptions-2020
Jul 15, 2021
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
50f5f59
[SYCL] Mark SYCL 1.2.1 exceptions deprecated
vladimirlaz 1e7af48
Merge remote-tracking branch 'vladimirlaz/sycl2020_exceptions' into c…
cperkinsintel 82012ab
checkpoint before wrestling .h file order issue
cperkinsintel 298d2a0
working, but still probs with circular dependencies once context type…
cperkinsintel 719a176
initial draft of data hiding. Encountering difficulties with incomple…
cperkinsintel 6f00b3d
lower 6 constructors
cperkinsintel a120efb
new constructors for SYCL2020
cperkinsintel 16d74ef
code() retrieval working and tested.
cperkinsintel 0dab12e
minor adjustments, comments, and ABI dump
cperkinsintel 376a783
merge conflicts addressed
cperkinsintel c40ea1e
clang-format
cperkinsintel 71ba3d2
reviewer feedback
cperkinsintel 3c0045b
clang-format does not approve
cperkinsintel 2fa6e11
requested changes from reviewers
cperkinsintel 804d98c
switched to memcpy as requested
cperkinsintel 090bb78
adding deprecation to default constructor
cperkinsintel 3ec03ec
reviewer feedback
cperkinsintel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// RUN: %clangxx -fsycl %s -o %t.out | ||
// RUN: %RUN_ON_HOST %t.out | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
using namespace cl::sycl; | ||
|
||
int main() { | ||
// Test new constructors, initially each with empty string messages. | ||
std::string emptyStr; | ||
const char *emptyCharPtr = ""; | ||
|
||
// Going to set the error code values to each of the enum (0-12). | ||
exception ex1(make_error_code(errc::runtime), emptyStr); | ||
exception ex2(make_error_code(errc::kernel), emptyCharPtr); | ||
exception ex3(make_error_code(errc::accessor)); | ||
exception ex4(static_cast<int>(errc::nd_range), sycl_category(), emptyStr); | ||
exception ex5(static_cast<int>(errc::event), sycl_category(), emptyCharPtr); | ||
exception ex6(static_cast<int>(errc::kernel_argument), sycl_category()); | ||
|
||
queue Q; | ||
context ctx = Q.get_context(); | ||
exception ex7(ctx, make_error_code(errc::build), emptyStr); | ||
exception ex8(ctx, make_error_code(errc::invalid), emptyCharPtr); | ||
exception ex9(ctx, make_error_code(errc::memory_allocation)); | ||
exception ex10(ctx, static_cast<int>(errc::platform), sycl_category(), | ||
emptyStr); | ||
exception ex11(ctx, static_cast<int>(errc::profiling), sycl_category(), | ||
emptyCharPtr); | ||
exception ex12(ctx, static_cast<int>(errc::feature_not_supported), | ||
sycl_category()); | ||
|
||
std::vector<exception> v{ex1, ex2, ex3, ex4, ex5, ex6, | ||
ex7, ex8, ex9, ex10, ex11, ex12}; | ||
for (int i = 0; i < 12; i++) { | ||
exception ex = v[i]; | ||
assert(ex.code().value() == i && "unexpected error_code.value() retrieved"); | ||
assert(ex.category() == sycl_category() && "expected SYCL error category"); | ||
if (i < 6) { | ||
assert(!ex.has_context() && | ||
"none of the first six exceptions should have a context"); | ||
} else { | ||
assert(ex.has_context() && ex.get_context() == ctx && | ||
"the second six exceptions should have a context equal to ctx"); | ||
} | ||
assert(strlen(ex.what()) == 0 && | ||
"all these exceptions were initialized with empty strings. We " | ||
"should not have anything in the 'what' message"); | ||
} | ||
|
||
// Now test constructor with a real string value, including one containing | ||
// null string terminator | ||
std::string testString("this is a test"); | ||
exception ex_string1(make_error_code(errc::kernel_not_supported), testString); | ||
assert(testString.compare(ex_string1.what()) == 0); | ||
cperkinsintel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testString[0] = '\0'; | ||
exception ex_early_terminated(make_error_code(errc::kernel_not_supported), | ||
testString); | ||
assert(ex_early_terminated.code().value() == | ||
static_cast<int>(errc::kernel_not_supported)); | ||
char testCharPtr[] = "this is also a test"; | ||
exception ex_string2(make_error_code(errc::backend_mismatch), testCharPtr); | ||
assert(strcmp(ex_string2.what(), testCharPtr) == 0); | ||
|
||
// Test sycl_category. | ||
assert(std::string("SYCL").compare(sycl_category().name()) == 0 && | ||
"sycl_category name should be SYCL"); | ||
|
||
// Test make_error_code. | ||
std::error_code ec = make_error_code(errc::feature_not_supported); | ||
assert(ec.value() == static_cast<int>(errc::feature_not_supported)); | ||
assert(std::string("SYCL").compare(ec.category().name()) == 0 && | ||
"error code category name should be SYCL"); | ||
|
||
std::cout << "OK" << std::endl; | ||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.