diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 44b46d4960910..004b122b80a44 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -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; - 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." @@ -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((void *)MHostKernel->getPtr()); diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 94408de4ec328..4ebe0b06ff040 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -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, diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index 6002f48d214a7..62af3d0074cac 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -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")