-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL] Throw exception if range/offset of kernel execution exceeds INT_MAX #1713
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
bader
merged 13 commits into
intel:sycl
from
s-kanaev:private/s-kanaev/id-int-exception
May 28, 2020
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
778145b
[SYCL] Throw exception if range/offset of kernel execution exceeds IN…
9833d3d
[SYCL] Reword exception message
1401a63
Merge branch 'sycl' into private/s-kanaev/id-int-exception
217791d
[SYCL] Add test
298f867
[SYCL] Fix style issues
e81218a
[SYCL] Stylistic changes in test
c82c6d6
Merge branch 'sycl' into private/s-kanaev/id-int-exception
26fbe53
[SYCL] Address comments
8fbd039
[SYCL] Address comments
a8dcc96
[SYCL] Address comments.
cfbf2b6
[SYCL] Fix style issues
c382be7
[SYCL] Address comments.
9a9279f
[SYCL] Resolve issue with 'max' and windows.h
s-kanaev 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D__SYCL_ID_QUERIES_FIT_IN_INT__=1 %s -o %t.out | ||
// RUN: %CPU_RUN_PLACEHOLDER %t.out | ||
|
||
#include <CL/sycl.hpp> | ||
#include <climits> | ||
|
||
namespace S = cl::sycl; | ||
|
||
void checkRangeException(S::runtime_error &E) { | ||
constexpr char Msg[] = "Provided range is out of integer limits. Suggest " | ||
"disabling `id-queries-fit-in-int32' optimizations " | ||
"flag."; | ||
s-kanaev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
std::cerr << E.what() << std::endl; | ||
|
||
assert(std::string(E.what()).find(Msg) == 0 && "Unexpected message"); | ||
} | ||
|
||
void checkOffsetException(S::runtime_error &E) { | ||
constexpr char Msg[] = "Provided offset is out of integer limits. Suggest " | ||
"disabling `id-queries-fit-in-int32' optimizations " | ||
"flag."; | ||
|
||
std::cerr << E.what() << std::endl; | ||
|
||
assert(std::string(E.what()).find(Msg) == 0 && "Unexpected message"); | ||
} | ||
|
||
void test() { | ||
auto EH = [](S::exception_list EL) { | ||
for (const std::exception_ptr &E : EL) { | ||
throw E; | ||
} | ||
}; | ||
|
||
S::queue Queue(EH); | ||
|
||
static constexpr size_t OutOfLimitsSize = static_cast<size_t>(INT_MAX) + 1; | ||
|
||
S::range<1> RangeOutOfLimits{OutOfLimitsSize}; | ||
S::range<1> RangeInLimits{1}; | ||
S::id<1> OffsetOutOfLimits{OutOfLimitsSize}; | ||
S::id<1> OffsetInLimits{1}; | ||
S::nd_range<1> NDRange_ROL_LIL_OIL{RangeOutOfLimits, RangeInLimits, | ||
OffsetInLimits}; | ||
S::nd_range<1> NDRange_RIL_LOL_OIL{RangeInLimits, RangeOutOfLimits, | ||
OffsetInLimits}; | ||
S::nd_range<1> NDRange_RIL_LIL_OOL{RangeInLimits, RangeInLimits, | ||
OffsetOutOfLimits}; | ||
S::nd_range<1> NDRange_RIL_LIL_OIL(RangeInLimits, RangeInLimits, | ||
OffsetInLimits); | ||
|
||
int Data = 0; | ||
S::buffer<int, 1> Buf{&Data, 1}; | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ROL>(RangeOutOfLimits, | ||
[=](S::id<1> Id) { Acc[0] += 1; }); | ||
}); | ||
|
||
assert(false && "Exception expected"); | ||
} catch (S::runtime_error &E) { | ||
checkRangeException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_RIL>(RangeInLimits, | ||
[Acc](S::id<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ROL_OIL>(RangeOutOfLimits, OffsetInLimits, | ||
[Acc](S::id<1> Id) { Acc[0] += 1; }); | ||
}); | ||
|
||
assert(false && "Exception expected"); | ||
} catch (S::runtime_error &E) { | ||
checkRangeException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_RIL_OOL>(RangeInLimits, OffsetOutOfLimits, | ||
[Acc](S::id<1> Id) { Acc[0] += 1; }); | ||
}); | ||
|
||
assert(false && "Exception expected"); | ||
} catch (S::runtime_error &E) { | ||
checkOffsetException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_RIL_OIL>(RangeInLimits, OffsetInLimits, | ||
[Acc](S::id<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ND_GOL_LIL_OIL>( | ||
NDRange_ROL_LIL_OIL, [Acc](S::nd_item<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (S::runtime_error &E) { | ||
checkRangeException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ND_GIL_LOL_OIL>( | ||
NDRange_RIL_LOL_OIL, [Acc](S::nd_item<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (S::runtime_error &E) { | ||
checkRangeException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ND_GIL_LIL_OOL>( | ||
NDRange_RIL_LIL_OOL, [Acc](S::nd_item<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (S::runtime_error &E) { | ||
checkOffsetException(E); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
|
||
try { | ||
Queue.submit([&](S::handler &CGH) { | ||
auto Acc = Buf.get_access<cl::sycl::access::mode::read_write>(CGH); | ||
|
||
CGH.parallel_for<class PF_ND_GIL_LIL_OIL>( | ||
NDRange_RIL_LIL_OIL, [Acc](S::nd_item<1> Id) { Acc[0] += 1; }); | ||
}); | ||
} catch (...) { | ||
assert(false && "Unexpected exception catched"); | ||
} | ||
} | ||
|
||
int main(void) { | ||
test(); | ||
return 0; | ||
} |
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.