-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fail on kernel lambda size mismatch #6374
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
#include <CL/sycl/detail/defines_elementary.hpp> | ||
#include <CL/sycl/detail/export.hpp> | ||
|
||
#include <cstdint> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, perhaps this will also fix one of internal trackers reporting problems with undefined int8_t type slipped into integration-header file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This inclusion is giving oneapi/dpl a stomach ache. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace detail { | ||
|
@@ -79,6 +81,7 @@ template <class KernelNameType> struct KernelInfo { | |
static constexpr const char *getFunctionName() { return ""; } | ||
static constexpr unsigned getLineNumber() { return 0; } | ||
static constexpr unsigned getColumnNumber() { return 0; } | ||
static constexpr int64_t getKernelSize() { return 0; } | ||
}; | ||
#else | ||
template <char...> struct KernelInfoData { | ||
|
@@ -93,6 +96,7 @@ template <char...> struct KernelInfoData { | |
static constexpr const char *getFunctionName() { return ""; } | ||
static constexpr unsigned getLineNumber() { return 0; } | ||
static constexpr unsigned getColumnNumber() { return 0; } | ||
static constexpr int64_t getKernelSize() { return 0; } | ||
}; | ||
|
||
// C++14 like index_sequence and make_index_sequence | ||
|
@@ -135,6 +139,9 @@ template <class KernelNameType> struct KernelInfo { | |
static constexpr const char *getFunctionName() { return ""; } | ||
static constexpr unsigned getLineNumber() { return 0; } | ||
static constexpr unsigned getColumnNumber() { return 0; } | ||
static constexpr int64_t getKernelSize() { | ||
return SubKernelInfo::getKernelSize(); | ||
bader marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
#endif //__SYCL_UNNAMED_LAMBDA__ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning -o - %s | ||
|
||
// Tests for static assertion failure when kernel lambda mismatches between host | ||
// and device. | ||
|
||
#include <CL/sycl.hpp> | ||
|
||
int main() { | ||
sycl::queue Q; | ||
int A = 1; | ||
Q.single_task([=]() { | ||
#ifdef __SYCL_DEVICE_ONLY__ | ||
(void)A; | ||
// expected-no-diagnostics | ||
#else | ||
// expected-error-re@CL/sycl/handler.hpp:* {{static_assert failed due to requirement '{{.*}}' "Unexpected kernel lambda size. This can be caused by an external host compiler producing a lambda with an unexpected layout. This is a limitation of the compiler."}} | ||
#endif | ||
}).wait(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should check that
sizeof(long long)
is 8, ifsizeof(long)
!= 8.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but this mimics the decision made by SemaSYCL when generating the specialization, so it should be fine for our testing.