Skip to content

Commit 31edc2b

Browse files
[SYCL] Added a new category for device binary properties (#3072)
This commit introduces a new category for general properties of device binary images. And it adds an API to retrieve properties from that common category.
1 parent b7eabf0 commit 31edc2b

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

llvm/include/llvm/Support/PropertySetIO.h

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class PropertySetRegistry {
187187
"SYCL/composite specialization constants";
188188
static constexpr char SYCL_DEVICELIB_REQ_MASK[] = "SYCL/devicelib req mask";
189189
static constexpr char SYCL_KERNEL_PARAM_OPT_INFO[] = "SYCL/kernel param opt";
190+
static constexpr char SYCL_MISC_PROP[] = "SYCL/misc properties";
190191

191192
// Function for bulk addition of an entire property set under given category
192193
// (property set name).

llvm/lib/Support/PropertySetIO.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ constexpr char PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS[];
197197
constexpr char PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK[];
198198
constexpr char PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO[];
199199
constexpr char PropertySetRegistry::SYCL_COMPOSITE_SPECIALIZATION_CONSTANTS[];
200+
constexpr char PropertySetRegistry::SYCL_MISC_PROP[];
200201

201202
} // namespace util
202203
} // namespace llvm

sycl/include/CL/sycl/detail/pi.h

+2
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ static const uint8_t PI_DEVICE_BINARY_OFFLOAD_KIND_SYCL = 4;
670670
#define __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK "SYCL/devicelib req mask"
671671
/// PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO defined in PropertySetIO.h
672672
#define __SYCL_PI_PROPERTY_SET_KERNEL_PARAM_OPT_INFO "SYCL/kernel param opt"
673+
/// PropertySetRegistry::SYCL_MISC_PROP defined in PropertySetIO.h
674+
#define __SYCL_PI_PROPERTY_SET_SYCL_MISC_PROP "SYCL/misc properties"
673675

674676
/// This struct is a record of the device binary information. If the Kind field
675677
/// denotes a portable binary type (SPIR-V or LLVM IR), the DeviceTargetSpec

sycl/include/CL/sycl/detail/pi.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ class DeviceBinaryImage {
290290
return Format;
291291
}
292292

293+
/// Returns a single property from SYCL_MISC_PROP category.
294+
pi_device_binary_property getProperty(const char *PropName) const;
295+
293296
/// Gets the iterator range over scalar specialization constants in this
294297
/// binary image. For each property pointed to by an iterator within the
295298
/// range, the name of the property is the specialization constant symbolic ID

sycl/source/detail/pi.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,22 @@ void DeviceBinaryImage::PropertyRange::init(pi_device_binary Bin,
565565
End = Begin ? PS->PropertiesEnd : nullptr;
566566
}
567567

568+
pi_device_binary_property
569+
DeviceBinaryImage::getProperty(const char *PropName) const {
570+
DeviceBinaryImage::PropertyRange BoolProp;
571+
BoolProp.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_MISC_PROP);
572+
if (!BoolProp.isAvailable())
573+
return nullptr;
574+
auto It = std::find_if(BoolProp.begin(), BoolProp.end(),
575+
[=](pi_device_binary_property Prop) {
576+
return !strcmp(PropName, Prop->Name);
577+
});
578+
if (It == BoolProp.end())
579+
return nullptr;
580+
581+
return *It;
582+
}
583+
568584
RT::PiDeviceBinaryType getBinaryImageFormat(const unsigned char *ImgData,
569585
size_t ImgSize) {
570586
struct {

0 commit comments

Comments
 (0)