Skip to content

[SYCL] Add -vc-codegen compile option for ESIMD images #3074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/PropertySetIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Support/PropertySetIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@ static string_vector saveDeviceImageProperty(
NameInfoPair.first, llvm::util::PropertyValue(Data, DataBitSize)));
}
}

if (ImgPSInfo.IsEsimdKernel) {
std::map<StringRef, bool> 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_" : "");
Expand Down
2 changes: 2 additions & 0 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,15 @@ RT::PiProgram ProgramManager::getBuiltPIProgram(OSModuleHandle M,
!SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK>::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);

Expand Down