Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 20 additions & 24 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,16 +825,24 @@ class __SYCL_EXPORT handler {
#endif
constexpr auto Info = detail::CompileTimeKernelInfo<KernelName>;

constexpr bool KernelHasName = (Info.Name != std::string_view{});
// 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
static_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.

// TODO remove the ifdef once the kernel size builtin is supported.
#ifdef __INTEL_SYCL_USE_INTEGRATION_HEADERS
static_assert(
!KernelHasName || sizeof(KernelType) == Info.KernelSize,
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 @@ -846,25 +854,13 @@ class __SYCL_EXPORT handler {
"-fsycl-host-compiler-options='/std:c++latest' "
"might also help.");
#endif
// Empty name indicates that the compilation happens without integration
// header, so don't perform things that require it.
if constexpr (KernelHasName) {
// TODO support ESIMD in no-integration-header case too.

// Force hasSpecialCaptures to be evaluated at compile-time.
setKernelInfo((void *)MHostKernel->getPtr(), Info.NumParams,
Info.ParamDescGetter, Info.IsESIMD,
Info.HasSpecialCaptures);

MKernelName = Info.Name;
setDeviceKernelInfoPtr(&detail::getDeviceKernelInfo<KernelName>());
} else {
// In case w/o the integration header it is necessary to process
// accessors from the list(which are associated with this handler) as
// arguments. We must copy the associated accessors as they are checked
// later during finalize.
setArgsToAssociatedAccessors();
}

// Force hasSpecialCaptures to be evaluated at compile-time.
setKernelInfo((void *)MHostKernel->getPtr(), Info.NumParams,
Info.ParamDescGetter, Info.IsESIMD, Info.HasSpecialCaptures);

MKernelName = Info.Name;
setDeviceKernelInfoPtr(&detail::getDeviceKernelInfo<KernelName>());

// If the kernel lambda is callable with a kernel_handler argument, manifest
// the associated kernel handler.
Expand Down
4 changes: 3 additions & 1 deletion sycl/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
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"
sycl_host_only_options = (
"-std=c++17 -Xclang -fsycl-is-host -D__SYCL_UNITTESTS_BYPASS_KERNEL_NAME_CHECK=1"
)
for include_dir in [
config.sycl_include,
config.level_zero_include_dir,
Expand Down
2 changes: 2 additions & 0 deletions sycl/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ 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