Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,26 +836,28 @@ class __SYCL_EXPORT handler {
Dims>());
#endif

// SYCL unittests are built without sycl compiler, so "host" information
// about kernels isn't provided (e.g., via integration headers or compiler
// builtins).
//
// However, some copy/fill USM operation are implemented via SYCL kernels
// and are instantiated resulting in all the `static_assert` checks being
// exercised. Without kernel information that would fail, so we explicitly
// disable such checks when this macro is defined. Note that the unittests
// don't actually execute those operation, that's why disabling
// unconditional `static_asserts`s is enough for now.
#ifndef __SYCL_UNITTESTS_BYPASS_KERNEL_NAME_CHECK
constexpr auto Info = detail::CompileTimeKernelInfo<KernelName>;

static_assert(Info.Name != std::string_view{}, "Kernel must have a name!");
// Ideally, the following should be a `static_assert` but cannot do that as
// it would fail in at least two scenarios:
//
// * Our own unittests that are compiled with an arbitrary host compiler
// without SYCL knowledge (i.e., no integration headers
// generated/supplied). Those that don't have to supply any stub kernel
// information test exceptions thrown before kernel enqueue, so having a
// run-time assert here doesn't affect them.
//
// * Mixed SYCL/OpenMP compilation, device code generation for OpenMP in
// * particular. For that scenario this code is compiled but never
// * executed.
assert(Info.Name != std::string_view{} && "Kernel must have a name!");

// Some host compilers may have different captures from Clang. Currently
// there is no stable way of handling this when extracting the captures,
// so a static assert is made to fail for incompatible kernel lambdas.
static_assert(
sizeof(KernelType) == Info.KernelSize,
Info.Name == std::string_view{} ||
sizeof(KernelType) == Info.KernelSize,
"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."
Expand All @@ -866,7 +868,6 @@ class __SYCL_EXPORT handler {
"In case of MSVC, passing "
"-fsycl-host-compiler-options='/std:c++latest' "
"might also help.");
#endif

setDeviceKernelInfo<KernelName>((void *)MHostKernel->getPtr());

Expand Down
4 changes: 1 addition & 3 deletions sycl/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@
llvm_symbolizer = os.path.join(config.llvm_build_bin_dir, "llvm-symbolizer")
llvm_config.with_environment("LLVM_SYMBOLIZER_PATH", llvm_symbolizer)

sycl_host_only_options = (
"-std=c++17 -Xclang -fsycl-is-host -D__SYCL_UNITTESTS_BYPASS_KERNEL_NAME_CHECK=1"
)
sycl_host_only_options = "-std=c++17 -Xclang -fsycl-is-host"
for include_dir in [
config.sycl_include,
config.level_zero_include_dir,
Expand Down
2 changes: 0 additions & 2 deletions sycl/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ endforeach()

add_compile_definitions(SYCL2020_DISABLE_DEPRECATION_WARNINGS SYCL_DISABLE_FSYCL_SYCLHPP_WARNING)

add_compile_definitions(__SYCL_UNITTESTS_BYPASS_KERNEL_NAME_CHECK)

# suppress warnings which came from Google Test sources
if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
add_compile_options("-Wno-suggest-override")
Expand Down