Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,10 @@ static const uint8_t PI_DEVICE_BINARY_OFFLOAD_KIND_SYCL = 4;
/// PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS defined in
/// PropertySetIO.h
#define __SYCL_PI_PROPERTY_SET_SPEC_CONST_MAP "SYCL/specialization constants"
/// PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES defined in
/// PropertySetIO.h
#define __SYCL_PI_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP \
"SYCL/specialization constants default values"
/// PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK defined in PropertySetIO.h
#define __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK "SYCL/devicelib req mask"
/// PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO defined in PropertySetIO.h
Expand Down
4 changes: 4 additions & 0 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ class DeviceBinaryImage {
/// like:
/// { ID5, 0, 4 }
const PropertyRange &getSpecConstants() const { return SpecConstIDMap; }
const PropertyRange &getSpecConstantsDefaultValues() const {
return SpecConstDefaultValuesMap;
}
const PropertyRange &getDeviceLibReqMask() const { return DeviceLibReqMask; }
const PropertyRange &getKernelParamOptInfo() const {
return KernelParamOptInfo;
Expand All @@ -331,6 +334,7 @@ class DeviceBinaryImage {
pi_device_binary Bin;
pi::PiDeviceBinaryType Format = PI_DEVICE_BINARY_TYPE_NONE;
DeviceBinaryImage::PropertyRange SpecConstIDMap;
DeviceBinaryImage::PropertyRange SpecConstDefaultValuesMap;
DeviceBinaryImage::PropertyRange DeviceLibReqMask;
DeviceBinaryImage::PropertyRange KernelParamOptInfo;
};
Expand Down
14 changes: 14 additions & 0 deletions sycl/source/detail/device_image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ class device_image_impl {
}
}
MSpecConstsBlob.resize(BlobOffset);

// set default values for specialization constants
const pi::DeviceBinaryImage::PropertyRange &SCDefValRange =
MBinImage->getSpecConstantsDefaultValues();
for (SCItTy SCIt : SCDefValRange) {
const char *SCName = (*SCIt)->Name;
pi::ByteArray Descriptors =
pi::DeviceBinaryProperty(*SCIt).asByteArray();
// TODO: same 8 bytes are the size of this new property?
assert(Descriptors.size() > 8 && "Unexpected property size");
// TODO: need to simplify it
const auto Value = reinterpret_cast<const void *>(&Descriptors[8]);
set_specialization_constant_raw_value(SCName, Value);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ void DeviceBinaryImage::init(pi_device_binary Bin) {
Format = getBinaryImageFormat(Bin->BinaryStart, getSize());

SpecConstIDMap.init(Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_MAP);
SpecConstDefaultValuesMap.init(
Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP);
DeviceLibReqMask.init(Bin, __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK);
KernelParamOptInfo.init(Bin, __SYCL_PI_PROPERTY_SET_KERNEL_PARAM_OPT_INFO);
}
Expand Down