diff --git a/llvm/include/llvm/Support/PropertySetIO.h b/llvm/include/llvm/Support/PropertySetIO.h index d88a7e0261bf9..89978f7e140ff 100644 --- a/llvm/include/llvm/Support/PropertySetIO.h +++ b/llvm/include/llvm/Support/PropertySetIO.h @@ -187,6 +187,7 @@ class PropertySetRegistry { "SYCL/composite specialization constants"; static constexpr char SYCL_DEVICELIB_REQ_MASK[] = "SYCL/devicelib req mask"; static constexpr char SYCL_KERNEL_PARAM_OPT_INFO[] = "SYCL/kernel param opt"; + static constexpr char SYCL_IS_ESIMD_IMAGE[] = "SYCL/is ESIMD image"; // Function for bulk addition of an entire property set under given category // (property set name). diff --git a/llvm/lib/Support/PropertySetIO.cpp b/llvm/lib/Support/PropertySetIO.cpp index a47cf4fea8d25..4742ccda7a135 100644 --- a/llvm/lib/Support/PropertySetIO.cpp +++ b/llvm/lib/Support/PropertySetIO.cpp @@ -197,6 +197,7 @@ constexpr char PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS[]; constexpr char PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK[]; constexpr char PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO[]; constexpr char PropertySetRegistry::SYCL_COMPOSITE_SPECIALIZATION_CONSTANTS[]; +constexpr char PropertySetRegistry::SYCL_IS_ESIMD_IMAGE[]; } // namespace util } // namespace llvm diff --git a/llvm/test/tools/sycl-post-link/sycl-esimd/basic-sycl-esimd-split.ll b/llvm/test/tools/sycl-post-link/sycl-esimd/basic-sycl-esimd-split.ll index 94f52ff519d0d..bd87bcf6a58c3 100644 --- a/llvm/test/tools/sycl-post-link/sycl-esimd/basic-sycl-esimd-split.ll +++ b/llvm/test/tools/sycl-post-link/sycl-esimd/basic-sycl-esimd-split.ll @@ -2,9 +2,11 @@ ; RUN: FileCheck %s -input-file=%t.table ; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR ; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR +; RUN: FileCheck %s -input-file=%t_0.prop --check-prefixes CHECK-SYCL-PROP +; RUN: FileCheck %s -input-file=%t_esimd_0.prop --check-prefixes CHECK-ESIMD-PROP -; This is basic test of splitting SYCL and ESIMD kernels into separate -; modules. +; This is basic test of splitting SYCL and ESIMD kernels into separate modules. +; ESIMD module should have isEsimdImage=1 property set after splitting. target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" target triple = "spir64-unknown-linux-sycldevice" @@ -41,5 +43,11 @@ attributes #0 = { "sycl-module-id"="a.cpp" } ; CHECK-SYCL-IR-DAG: define dso_local spir_kernel void @SYCL_kernel() ; CHECK-SYCL-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv() +; CHECK-SYCL-PROP-NOT: [SYCL/is ESIMD image] +; CHECK-SYCL-PROP-NOT: isEsimdImage=1|1 + ; CHECK-ESIMD-IR-DAG: define dso_local spir_kernel void @ESIMD_kernel() ; CHECK-ESIMD-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv() + +; CHECK-ESIMD-PROP: [SYCL/is ESIMD image] +; CHECK-ESIMD-PROP: isEsimdImage=1|1 diff --git a/llvm/tools/sycl-post-link/sycl-post-link.cpp b/llvm/tools/sycl-post-link/sycl-post-link.cpp index 2e16ed5612539..40adc94207318 100644 --- a/llvm/tools/sycl-post-link/sycl-post-link.cpp +++ b/llvm/tools/sycl-post-link/sycl-post-link.cpp @@ -586,6 +586,13 @@ static string_vector saveDeviceImageProperty( NameInfoPair.first, llvm::util::PropertyValue(Data, DataBitSize))); } } + + if (ImgPSInfo.IsEsimdKernel) { + std::map RMEntry = {{"isEsimdImage", true}}; + PropSet.add(llvm::util::PropertySetRegistry::SYCL_IS_ESIMD_IMAGE, + RMEntry); + } + std::error_code EC; std::string SCFile = makeResultFileName(".prop", I, ImgPSInfo.IsEsimdKernel ? "esimd_" : ""); diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 693f15153340a..b92ca77a33ba7 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -670,6 +670,8 @@ static const uint8_t PI_DEVICE_BINARY_OFFLOAD_KIND_SYCL = 4; #define __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK "SYCL/devicelib req mask" /// PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO defined in PropertySetIO.h #define __SYCL_PI_PROPERTY_SET_KERNEL_PARAM_OPT_INFO "SYCL/kernel param opt" +/// PropertySetRegistry::SYCL_IS_ESIMD_IMAGE defined in PropertySetIO.h +#define __SYCL_PI_PROPERTY_SET_SYCL_IS_ESIMD_IMAGE "SYCL/is ESIMD image" /// This struct is a record of the device binary information. If the Kind field /// denotes a portable binary type (SPIR-V or LLVM IR), the DeviceTargetSpec diff --git a/sycl/include/CL/sycl/detail/pi.hpp b/sycl/include/CL/sycl/detail/pi.hpp index 661fffe971e7d..c70b16be5923a 100644 --- a/sycl/include/CL/sycl/detail/pi.hpp +++ b/sycl/include/CL/sycl/detail/pi.hpp @@ -290,6 +290,9 @@ class DeviceBinaryImage { return Format; } + /// Returns the value of a single property + bool isBoolPropertyTrue(const char *PropName) const; + /// Gets the iterator range over scalar specialization constants in this /// binary image. For each property pointed to by an iterator within the /// range, the name of the property is the specialization constant symbolic ID diff --git a/sycl/source/detail/pi.cpp b/sycl/source/detail/pi.cpp index be58c43e42881..8b595d6e4910c 100644 --- a/sycl/source/detail/pi.cpp +++ b/sycl/source/detail/pi.cpp @@ -565,6 +565,13 @@ void DeviceBinaryImage::PropertyRange::init(pi_device_binary Bin, End = Begin ? PS->PropertiesEnd : nullptr; } +bool DeviceBinaryImage::isBoolPropertyTrue(const char *PropName) const { + DeviceBinaryImage::PropertyRange BoolProp; + BoolProp.init(Bin, PropName); + return BoolProp.isAvailable() && + pi::DeviceBinaryProperty(*(BoolProp.begin())).asUint32(); +} + RT::PiDeviceBinaryType getBinaryImageFormat(const unsigned char *ImgData, size_t ImgSize) { struct { diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index e4894186a1f1c..506df7ba8578e 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -390,8 +390,15 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M, !SYCLConfig::get()) DeviceLibReqMask = getDeviceLibReqMask(Img); + std::string CompileOpts = Img.getCompileOptions(); + if (Img.isBoolPropertyTrue(__SYCL_PI_PROPERTY_SET_SYCL_IS_ESIMD_IMAGE)) { + if (!CompileOpts.empty()) + CompileOpts += " "; + CompileOpts += "-vc-codegen"; + } + ProgramPtr BuiltProgram = - build(std::move(ProgramManaged), ContextImpl, Img.getCompileOptions(), + build(std::move(ProgramManaged), ContextImpl, CompileOpts, Img.getLinkOptions(), getRawSyclObjImpl(Device)->getHandleRef(), ContextImpl->getCachedLibPrograms(), DeviceLibReqMask);