diff --git a/llvm/include/llvm/Support/PropertySetIO.h b/llvm/include/llvm/Support/PropertySetIO.h index d88a7e0261bf9..e571a3679c1f7 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_MISC_PROP[] = "SYCL/misc properties"; // 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..f583c91088762 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_MISC_PROP[]; } // namespace util } // namespace llvm diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 693f15153340a..da4a71c03aba0 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_MISC_PROP defined in PropertySetIO.h +#define __SYCL_PI_PROPERTY_SET_SYCL_MISC_PROP "SYCL/misc properties" /// 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..a5998d9fbe1de 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 a single property from SYCL_MISC_PROP category. + pi_device_binary_property getProperty(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..5d94cd3fe4537 100644 --- a/sycl/source/detail/pi.cpp +++ b/sycl/source/detail/pi.cpp @@ -565,6 +565,22 @@ void DeviceBinaryImage::PropertyRange::init(pi_device_binary Bin, End = Begin ? PS->PropertiesEnd : nullptr; } +pi_device_binary_property +DeviceBinaryImage::getProperty(const char *PropName) const { + DeviceBinaryImage::PropertyRange BoolProp; + BoolProp.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_MISC_PROP); + if (!BoolProp.isAvailable()) + return nullptr; + auto It = std::find_if(BoolProp.begin(), BoolProp.end(), + [=](pi_device_binary_property Prop) { + return !strcmp(PropName, Prop->Name); + }); + if (It == BoolProp.end()) + return nullptr; + + return *It; +} + RT::PiDeviceBinaryType getBinaryImageFormat(const unsigned char *ImgData, size_t ImgSize) { struct {