diff --git a/buildbot/configure.py b/buildbot/configure.py index a45995af492ca..74733d3b99fe1 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -29,7 +29,7 @@ def do_configure(args): libclc_targets_to_build = '' libclc_gen_remangled_variants = 'OFF' sycl_build_pi_cuda = 'OFF' - sycl_build_pi_esimd_cpu = 'OFF' + sycl_build_pi_esimd_emulator = 'OFF' sycl_build_pi_hip = 'OFF' sycl_build_pi_hip_platform = 'AMD' sycl_clang_extra_flags = '' @@ -53,7 +53,7 @@ def do_configure(args): llvm_targets_to_build = 'ARM;AArch64' if args.enable_esimd_cpu_emulation: - sycl_build_pi_esimd_cpu = 'ON' + sycl_build_pi_esimd_emulator = 'ON' if args.cuda or args.hip: llvm_enable_projects += ';libclc' @@ -128,7 +128,7 @@ def do_configure(args): "-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs), "-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing), "-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld), - "-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu), + "-DSYCL_BUILD_PI_ESIMD_EMULATOR={}".format(sycl_build_pi_esimd_emulator), "-DXPTI_ENABLE_WERROR={}".format(xpti_enable_werror), "-DSYCL_CLANG_EXTRA_FLAGS={}".format(sycl_clang_extra_flags) ] diff --git a/sycl/.gitignore b/sycl/.gitignore index 6f61542267633..a3fcfee0cf3ca 100644 --- a/sycl/.gitignore +++ b/sycl/.gitignore @@ -1 +1,2 @@ include/CL/sycl/version.hpp +include/CL/sycl/feature_test.hpp diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 219f9fba74551..85a7d62b50970 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -100,6 +100,8 @@ set(sycl_plugin_dir ${CMAKE_CURRENT_SOURCE_DIR}/plugins) string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d") set(version_header "${sycl_inc_dir}/CL/sycl/version.hpp") configure_file("${version_header}.in" "${version_header}") +set(feature_header "${sycl_inc_dir}/CL/sycl/feature_test.hpp") +configure_file("${feature_header}.in" "${feature_header}") # This is workaround to detect changes (add or modify) in subtree which # are not detected by copy_directory command. @@ -310,7 +312,7 @@ endif() # TODO : Remove 'if (NOT MSVC)' when CM_EMU supports Windows # environment if (NOT MSVC) - if (SYCL_BUILD_PI_ESIMD_CPU) + if (SYCL_BUILD_PI_ESIMD_EMULATOR) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS pi_esimd_cpu libcmrt-headers) if (MSVC) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libcmrt-libs libcmrt-dlls) diff --git a/sycl/include/CL/sycl/backend_types.hpp b/sycl/include/CL/sycl/backend_types.hpp index 42568222c0f10..d18a04b1a265a 100644 --- a/sycl/include/CL/sycl/backend_types.hpp +++ b/sycl/include/CL/sycl/backend_types.hpp @@ -26,7 +26,9 @@ enum class backend : char { ext_oneapi_level_zero, cuda = 3, all = 4, - esimd_cpu = 5, + ext_intel_esimd_emulator = 5, + esimd_cpu __SYCL2020_DEPRECATED("use 'ext_oneapi_esimd_emulator' instead") = + ext_intel_esimd_emulator, hip = 6, }; @@ -55,8 +57,8 @@ inline std::ostream &operator<<(std::ostream &Out, backend be) { case backend::cuda: Out << "cuda"; break; - case backend::esimd_cpu: - Out << "esimd_cpu"; + case backend::ext_intel_esimd_emulator: + Out << "ext_intel_esimd_emulator"; break; case backend::hip: Out << "hip"; diff --git a/sycl/include/CL/sycl/feature_test.hpp b/sycl/include/CL/sycl/feature_test.hpp.in similarity index 76% rename from sycl/include/CL/sycl/feature_test.hpp rename to sycl/include/CL/sycl/feature_test.hpp.in index cd6ca9cd988df..dff0f3a3a9ed5 100644 --- a/sycl/include/CL/sycl/feature_test.hpp +++ b/sycl/include/CL/sycl/feature_test.hpp.in @@ -10,6 +10,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { +#define SYCL_BACKEND_OPENCL 1 // Feature test macro definitions // TODO: Move these feature-test macros to compiler driver. @@ -29,6 +30,18 @@ namespace sycl { #define SYCL_EXT_INTEL_MEM_CHANNEL_PROPERTY 1 #define SYCL_EXT_INTEL_USM_ADDRESS_SPACES 1 #define SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO 1 +#cmakedefine01 SYCL_BUILD_PI_CUDA +#if SYCL_BUILD_PI_CUDA +#define SYCL_EXT_ONEAPI_BACKEND_CUDA 1 +#endif +#cmakedefine01 SYCL_BUILD_PI_ESIMD_EMULATOR +#if SYCL_BUILD_PI_ESIMD_EMULATOR +#define SYCL_EXT_INTEL_BACKEND_ESIMD_EMULATOR 1 +#endif +#cmakedefine01 SYCL_BUILD_PI_HIP +#if SYCL_BUILD_PI_HIP +#define SYCL_EXT_ONEAPI_BACKEND_HIP 1 +#endif } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/include/sycl/ext/intel/experimental/esimd/emu/detail/esimdcpu_device_interface.hpp b/sycl/include/sycl/ext/intel/experimental/esimd/emu/detail/esimdcpu_device_interface.hpp index ca24b20b38019..dbf7ad20b0618 100644 --- a/sycl/include/sycl/ext/intel/experimental/esimd/emu/detail/esimdcpu_device_interface.hpp +++ b/sycl/include/sycl/ext/intel/experimental/esimd/emu/detail/esimdcpu_device_interface.hpp @@ -75,7 +75,9 @@ ESIMDDeviceInterface *getESIMDDeviceInterface() { // tight loop) void *PIOpaqueData = nullptr; - PIOpaqueData = getPluginOpaqueData(nullptr); + PIOpaqueData = + getPluginOpaqueData( + nullptr); ESIMDEmuPluginOpaqueData *OpaqueData = reinterpret_cast(PIOpaqueData); diff --git a/sycl/plugins/CMakeLists.txt b/sycl/plugins/CMakeLists.txt index fb153cdf74548..b5e3b8213401d 100644 --- a/sycl/plugins/CMakeLists.txt +++ b/sycl/plugins/CMakeLists.txt @@ -18,7 +18,7 @@ add_subdirectory(level_zero) # TODO : Remove 'if (NOT MSVC)' when CM_EMU supports Windows # environment if (NOT MSVC) - if (SYCL_BUILD_PI_ESIMD_CPU) + if (SYCL_BUILD_PI_ESIMD_EMULATOR) add_subdirectory(esimd_cpu) endif() endif() diff --git a/sycl/source/detail/pi.cpp b/sycl/source/detail/pi.cpp index a372f676b7016..7b7460630e3d4 100644 --- a/sycl/source/detail/pi.cpp +++ b/sycl/source/detail/pi.cpp @@ -74,7 +74,7 @@ void *getPluginOpaqueData(void *OpaqueDataParam) { } template __SYCL_EXPORT void * -getPluginOpaqueData(void *); +getPluginOpaqueData(void *); namespace pi { @@ -504,7 +504,8 @@ template const plugin &getPlugin() { template __SYCL_EXPORT const plugin &getPlugin(); template __SYCL_EXPORT const plugin &getPlugin(); -template __SYCL_EXPORT const plugin &getPlugin(); +template __SYCL_EXPORT const plugin & +getPlugin(); // Report error and no return (keeps compiler from printing warnings). // TODO: Probably change that to throw a catchable exception, diff --git a/sycl/test/basic_tests/exceptions-SYCL-2020.cpp b/sycl/test/basic_tests/exceptions-SYCL-2020.cpp index 192e9b4fcc1f5..c432a6b9ea1b8 100644 --- a/sycl/test/basic_tests/exceptions-SYCL-2020.cpp +++ b/sycl/test/basic_tests/exceptions-SYCL-2020.cpp @@ -91,8 +91,10 @@ int main() { sycl::backend_traits::errc someCUDAErrCode{EC}; sycl::errc_for anotherCUDAErrCode{EC}; assert(someCUDAErrCode == anotherCUDAErrCode); - sycl::backend_traits::errc someESIMDErrCode{EC}; - sycl::errc_for anotherESIMDErrCode{EC}; + sycl::backend_traits::errc + someESIMDErrCode{EC}; + sycl::errc_for anotherESIMDErrCode{ + EC}; assert(someESIMDErrCode == anotherESIMDErrCode); sycl::backend_traits::errc someHIPErrCode{EC}; sycl::errc_for anotherHIPErrCode{EC}; diff --git a/sycl/test/extensions/macro.cpp b/sycl/test/extensions/macro.cpp index 7264ac21e4264..91b353c8970e1 100644 --- a/sycl/test/extensions/macro.cpp +++ b/sycl/test/extensions/macro.cpp @@ -5,11 +5,23 @@ #include #include int main() { +#if SYCL_BACKEND_OPENCL == 1 + std::cout << "SYCL_BACKEND_OPENCL=1" << std::endl; +#else + std::cerr << "SYCL_BACKEND_OPENCL!=1" << std::endl; + exit(1); +#endif #if SYCL_EXT_ONEAPI_SUB_GROUP_MASK == 1 std::cout << "SYCL_EXT_ONEAPI_SUB_GROUP_MASK=1" << std::endl; #else std::cerr << "SYCL_EXT_ONEAPI_SUB_GROUP_MASK!=1" << std::endl; exit(1); +#endif +#if SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO == 1 + std::cout << "SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO=1" << std::endl; +#else + std::cerr << "SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO!=1" << std::endl; + exit(1); #endif exit(0); } diff --git a/sycl/test/extensions/macro_cuda.cpp b/sycl/test/extensions/macro_cuda.cpp new file mode 100644 index 0000000000000..247c96489fc0f --- /dev/null +++ b/sycl/test/extensions/macro_cuda.cpp @@ -0,0 +1,15 @@ +// This test checks presence of macros for available extensions. +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %t.out +// REQUIRES: cuda_be +#include +#include +int main() { +#if SYCL_EXT_ONEAPI_BACKEND_CUDA == 1 + std::cout << "SYCL_EXT_ONEAPI_BACKEND_CUDA=1" << std::endl; +#else + std::cerr << "SYCL_EXT_ONEAPI_BACKEND_CUDA!=1" << std::endl; + exit(1); +#endif + exit(0); +} diff --git a/sycl/test/extensions/macro_esimd_emulator.cpp b/sycl/test/extensions/macro_esimd_emulator.cpp new file mode 100644 index 0000000000000..13891c99dd969 --- /dev/null +++ b/sycl/test/extensions/macro_esimd_emulator.cpp @@ -0,0 +1,15 @@ +// This test checks presence of macros for available extensions. +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %t.out +// REQUIRES: esimd_emulator_be +#include +#include +int main() { +#if SYCL_EXT_INTEL_BACKEND_ESIMD_EMULATOR == 1 + std::cout << "SYCL_EXT_INTEL_BACKEND_ESIMD_EMULATOR=1" << std::endl; +#else + std::cerr << "SYCL_EXT_INTEL_BACKEND_ESIMD_EMULATOR!=1" << std::endl; + exit(1); +#endif + exit(0); +} diff --git a/sycl/test/extensions/macro_hip.cpp b/sycl/test/extensions/macro_hip.cpp new file mode 100644 index 0000000000000..9319d9da35697 --- /dev/null +++ b/sycl/test/extensions/macro_hip.cpp @@ -0,0 +1,15 @@ +// This test checks presence of macros for available extensions. +// RUN: %clangxx -fsycl %s -o %t.out +// RUN: %t.out +// REQUIRES: hip_be +#include +#include +int main() { +#if SYCL_EXT_ONEAPI_BACKEND_HIP == 1 + std::cout << "SYCL_EXT_ONEAPI_BACKEND_HIP=1" << std::endl; +#else + std::cerr << "SYCL_EXT_ONEAPI_BACKEND_HIP!=1" << std::endl; + exit(1); +#endif + exit(0); +} diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 750895ffe49dd..57d7f8ffaed55 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -100,6 +100,15 @@ lit_config.note("Triple: {}".format(triple)) config.substitutions.append( ('%sycl_triple', triple ) ) +if config.cuda_be == "ON": + config.available_features.add('cuda_be') + +if config.hip_be == "ON": + config.available_features.add('hip_be') + +if config.esimd_emulator_be == "ON": + config.available_features.add('esimd_emulator_be') + if triple == 'nvptx64-nvidia-cuda': config.available_features.add('cuda') diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index dcd7b25678c1e..98fc85b35b797 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -24,6 +24,9 @@ config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@" config.sycl_threads_lib = '@SYCL_THREADS_LIB@' config.sycl_use_libcxx = '@SYCL_USE_LIBCXX@' config.extra_environment = lit_config.params.get("extra_environment", "@LIT_EXTRA_ENVIRONMENT@") +config.cuda_be = '@SYCL_BUILD_PI_CUDA@' +config.esimd_emulator_be = '@SYCL_BUILD_PI_ESIMD_EMULATOR@' +config.hip_be = '@SYCL_BUILD_PI_HIP@' import lit.llvm lit.llvm.initialize(lit_config, config) diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index 81c4792149c33..39f1e22f8ec6f 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -158,6 +158,10 @@ int main() { auto LevelZeroBackend = sycl::backend::level_zero; (void)LevelZeroBackend; + // expected-warning@+1{{'esimd_cpu' is deprecated: use 'ext_oneapi_esimd_emulator' instead}} + auto ESIMDCPUBackend = sycl::backend::esimd_cpu; + (void)ESIMDCPUBackend; + sycl::half Val = 1.0f; // expected-warning@+1{{'bit_cast' is deprecated: use 'sycl::bit_cast' instead}} auto BitCastRes = sycl::detail::bit_cast(Val);