Skip to content

Commit de4e843

Browse files
committed
[SYCL] Add property set fields to the binary image descriptor, bump PI version.
This change breaks backward binary compatibility of device binary image descriptors. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
1 parent ccac682 commit de4e843

File tree

1 file changed

+51
-2
lines changed
  • sycl/include/CL/sycl/detail

1 file changed

+51
-2
lines changed

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

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@
2727
// maintained there should be a (+1) change to the major version in
2828
// addition to the increase of the minor.
2929
//
30+
// PI version changes log:
31+
// -- Version 1.2:
32+
// 1. (Binary backward compatibility breaks) Two fields added to the
33+
// pi_device_binary_struct structure:
34+
// pi_device_binary_property_set PropertySetsBegin;
35+
// pi_device_binary_property_set PropertySetsEnd;
36+
// 2. A number of types needed to define pi_device_binary_property_set added.
37+
//
3038
#define _PI_H_VERSION_MAJOR 1
31-
#define _PI_H_VERSION_MINOR 1
39+
#define _PI_H_VERSION_MINOR 2
3240

3341
#define _PI_STRING_HELPER(a) #a
3442
#define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b)
@@ -531,6 +539,35 @@ struct _pi_offload_entry_struct {
531539

532540
using _pi_offload_entry = _pi_offload_entry_struct *;
533541

542+
// A type of a binary image property.
543+
typedef enum {
544+
PI_PROP_TYPE_UNKNOWN,
545+
PI_PROP_TYPE_UINT32, // 32-bit integer
546+
PI_PROP_TYPE_STRING // null-terminated string
547+
} _pi_property_type;
548+
549+
// Device binary image property.
550+
// If the type size of the property value is fixed and is no greater than
551+
// 64 bits, then ValAddr is 0 and the value is stored in the ValSize field.
552+
// Example - PI_PROP_TYPE_UINT32, which is 32-bit
553+
struct _pi_device_binary_property_struct {
554+
char *Name; // null-terminated property name
555+
void *ValAddr; // address of property value
556+
uint32_t Type; // _pi_property_type
557+
uint64_t ValSize; // size of property value in bytes
558+
};
559+
560+
typedef _pi_device_binary_property_struct *pi_device_binary_property;
561+
562+
// Named array of properties.
563+
struct _pi_device_binary_property_set_struct {
564+
char *Name; // the name
565+
pi_device_binary_property PropertiesBegin; // array start
566+
pi_device_binary_property PropertiesEnd; // array end
567+
};
568+
569+
typedef _pi_device_binary_property_set_struct *pi_device_binary_property_set;
570+
534571
/// Types of device binary.
535572
using pi_device_binary_type = uint8_t;
536573
// format is not determined
@@ -566,10 +603,15 @@ static const uint8_t PI_DEVICE_BINARY_OFFLOAD_KIND_SYCL = 4;
566603
#define PI_DEVICE_BINARY_TARGET_SPIRV64_X86_64 "spir64_x86_64"
567604
#define PI_DEVICE_BINARY_TARGET_SPIRV64_GEN "spir64_gen"
568605
#define PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA "spir64_fpga"
569-
570606
/// PTX 64-bit image <-> "nvptx64", 64-bit NVIDIA PTX device
571607
#define PI_DEVICE_BINARY_TARGET_NVPTX64 "nvptx64"
572608

609+
/// Device binary image property set names recognized by the SYCL runtime.
610+
/// Name must be consistent with
611+
/// PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS defined in
612+
/// PropertySetIO.h
613+
#define PI_PROPERTY_SET_SPEC_CONST_MAP "SYCL/specialization constants"
614+
573615
/// This struct is a record of the device binary information. If the Kind field
574616
/// denotes a portable binary type (SPIR-V or LLVM IR), the DeviceTargetSpec
575617
/// field can still be specific and denote e.g. FPGA target. It must match the
@@ -610,6 +652,13 @@ struct pi_device_binary_struct {
610652
/// the offload entry table
611653
_pi_offload_entry EntriesBegin;
612654
_pi_offload_entry EntriesEnd;
655+
// Array of preperty sets; e.g. specialization constants symbol-int ID map is
656+
// propagated to runtime with this mechanism.
657+
pi_device_binary_property_set PropertySetsBegin;
658+
pi_device_binary_property_set PropertySetsEnd;
659+
// TODO Other fields like entries, link options can be propagated using
660+
// the property set infrastructure. This will improve binary compatibility and
661+
// add flexibility.
613662
};
614663
using pi_device_binary = pi_device_binary_struct *;
615664

0 commit comments

Comments
 (0)