DPC++ Runtime
Runtime libraries for oneAPI DPC++
compiler.hpp
Go to the documentation of this file.
1 //==-------- compiler.hpp - Interface between compiler and runtime ---------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <cstddef>
12 #include <cstdint>
13 
20 #define __SYCL_DEVICE_BINARY_TARGET_UNKNOWN "<unknown>"
22 #define __SYCL_DEVICE_BINARY_TARGET_SPIRV32 "spir"
24 #define __SYCL_DEVICE_BINARY_TARGET_SPIRV64 "spir64"
27 #define __SYCL_DEVICE_BINARY_TARGET_SPIRV64_X86_64 "spir64_x86_64"
28 #define __SYCL_DEVICE_BINARY_TARGET_SPIRV64_GEN "spir64_gen"
29 #define __SYCL_DEVICE_BINARY_TARGET_SPIRV64_FPGA "spir64_fpga"
31 #define __SYCL_DEVICE_BINARY_TARGET_NVPTX64 "nvptx64"
32 #define __SYCL_DEVICE_BINARY_TARGET_AMDGCN "amdgcn"
33 #define __SYCL_DEVICE_BINARY_TARGET_NATIVE_CPU "native_cpu"
34 
39 #define __SYCL_PROPERTY_SET_SPEC_CONST_MAP "SYCL/specialization constants"
42 #define __SYCL_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP \
43  "SYCL/specialization constants default values"
45 #define __SYCL_PROPERTY_SET_DEVICELIB_REQ_MASK "SYCL/devicelib req mask"
47 #define __SYCL_PROPERTY_SET_KERNEL_PARAM_OPT_INFO "SYCL/kernel param opt"
49 #define __SYCL_PROPERTY_SET_PROGRAM_METADATA "SYCL/program metadata"
51 #define __SYCL_PROPERTY_SET_SYCL_MISC_PROP "SYCL/misc properties"
53 #define __SYCL_PROPERTY_SET_SYCL_ASSERT_USED "SYCL/assert used"
55 #define __SYCL_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS "SYCL/exported symbols"
57 #define __SYCL_PROPERTY_SET_SYCL_IMPORTED_SYMBOLS "SYCL/imported symbols"
59 #define __SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS "SYCL/device globals"
61 #define __SYCL_PROPERTY_SET_SYCL_DEVICE_REQUIREMENTS "SYCL/device requirements"
63 #define __SYCL_PROPERTY_SET_SYCL_HOST_PIPES "SYCL/host pipes"
65 #define __SYCL_PROPERTY_SET_SYCL_VIRTUAL_FUNCTIONS "SYCL/virtual functions"
66 
69 #define __SYCL_PROGRAM_METADATA_TAG_REQD_WORK_GROUP_SIZE "@reqd_work_group_size"
70 #define __SYCL_PROGRAM_METADATA_GLOBAL_ID_MAPPING "@global_id_mapping"
71 
72 #define __SYCL_PROGRAM_METADATA_TAG_NEED_FINALIZATION "Requires finalization"
73 
74 // Entry type, matches OpenMP for compatibility
76  void *addr;
77  char *name;
78  size_t size;
79  int32_t flags;
80  int32_t reserved;
81 };
83 
84 // A type of a binary image property.
87  SYCL_PROPERTY_TYPE_UINT32, // 32-bit integer
89  SYCL_PROPERTY_TYPE_STRING // null-terminated string
90 };
91 
92 // Device binary image property.
93 // If the type size of the property value is fixed and is no greater than
94 // 64 bits, then ValAddr is 0 and the value is stored in the ValSize field.
95 // Example - PI_PROPERTY_TYPE_UINT32, which is 32-bit
97  char *Name; // null-terminated property name
98  void *ValAddr; // address of property value
99  uint32_t Type; // _pi_property_type
100  uint64_t ValSize; // size of property value in bytes
101 };
103 
104 // Named array of properties.
106  char *Name; // the name
109 };
112 
114 enum sycl_device_binary_type : uint8_t {
115  SYCL_DEVICE_BINARY_TYPE_NONE = 0, // undetermined
116  SYCL_DEVICE_BINARY_TYPE_NATIVE = 1, // specific to a device
119 };
120 
121 // Device binary descriptor version supported by this library.
122 static const uint16_t SYCL_DEVICE_BINARY_VERSION = 1;
123 
124 // The kind of offload model the binary employs; must be 4 for SYCL
125 static const uint8_t SYCL_DEVICE_BINARY_OFFLOAD_KIND_SYCL = 4;
126 
136  uint16_t Version;
138  uint8_t Kind;
140  uint8_t Format;
152  const char *DeviceTargetSpec;
155  const char *CompileOptions;
158  const char *LinkOptions;
160  const char *ManifestStart;
162  const char *ManifestEnd;
164  const unsigned char *BinaryStart;
166  const unsigned char *BinaryEnd;
170  // Array of preperty sets; e.g. specialization constants symbol-int ID map is
171  // propagated to runtime with this mechanism.
174  // TODO Other fields like entries, link options can be propagated using
175  // the property set infrastructure. This will improve binary compatibility and
176  // add flexibility.
177 };
179 
180 // Offload binaries descriptor version supported by this library.
181 static const uint16_t SYCL_DEVICE_BINARIES_VERSION = 1;
182 
190  uint16_t Version;
198 };
sycl_property_type
Definition: compiler.hpp:85
@ SYCL_PROPERTY_TYPE_UNKNOWN
Definition: compiler.hpp:86
@ SYCL_PROPERTY_TYPE_STRING
Definition: compiler.hpp:89
@ SYCL_PROPERTY_TYPE_BYTE_ARRAY
Definition: compiler.hpp:88
@ SYCL_PROPERTY_TYPE_UINT32
Definition: compiler.hpp:87
static const uint16_t SYCL_DEVICE_BINARIES_VERSION
Definition: compiler.hpp:181
sycl_device_binary_type
Types of device binary.
Definition: compiler.hpp:114
@ SYCL_DEVICE_BINARY_TYPE_SPIRV
Definition: compiler.hpp:117
@ SYCL_DEVICE_BINARY_TYPE_LLVMIR_BITCODE
Definition: compiler.hpp:118
@ SYCL_DEVICE_BINARY_TYPE_NONE
Definition: compiler.hpp:115
@ SYCL_DEVICE_BINARY_TYPE_NATIVE
Definition: compiler.hpp:116
static const uint8_t SYCL_DEVICE_BINARY_OFFLOAD_KIND_SYCL
Definition: compiler.hpp:125
static const uint16_t SYCL_DEVICE_BINARY_VERSION
Definition: compiler.hpp:122
sycl_device_binary_property PropertiesBegin
Definition: compiler.hpp:107
sycl_device_binary_property PropertiesEnd
Definition: compiler.hpp:108
Definition: compiler.hpp:75
void * addr
Definition: compiler.hpp:76
char * name
Definition: compiler.hpp:77
int32_t flags
Definition: compiler.hpp:79
size_t size
Definition: compiler.hpp:78
int32_t reserved
Definition: compiler.hpp:80
This struct is a record of all the device code that may be offloaded.
Definition: compiler.hpp:186
uint16_t NumDeviceBinaries
Number of device binaries in this descriptor.
Definition: compiler.hpp:192
sycl_offload_entry * HostEntriesEnd
Definition: compiler.hpp:197
sycl_offload_entry * HostEntriesBegin
the offload entry table (not used, for compatibility with OpenMP)
Definition: compiler.hpp:196
uint16_t Version
version of this structure - for backward compatibility; all modifications which change order/type/off...
Definition: compiler.hpp:190
sycl_device_binary DeviceBinaries
Device binaries data.
Definition: compiler.hpp:194
This struct is a record of the device binary information.
Definition: compiler.hpp:132
uint8_t Kind
the type of offload model the binary employs; must be 4 for SYCL
Definition: compiler.hpp:138
sycl_offload_entry EntriesEnd
Definition: compiler.hpp:169
const char * LinkOptions
a null-terminated string; target- and compiler-specific options which are suggested to use to "link" ...
Definition: compiler.hpp:158
sycl_offload_entry EntriesBegin
the offload entry table
Definition: compiler.hpp:168
const char * ManifestEnd
Pointer to the manifest data end.
Definition: compiler.hpp:162
const char * CompileOptions
a null-terminated string; target- and compiler-specific options which are suggested to use to "compil...
Definition: compiler.hpp:155
const unsigned char * BinaryStart
Pointer to the target code start.
Definition: compiler.hpp:164
uint8_t Format
format of the binary data - SPIR-V, LLVM IR bitcode,...
Definition: compiler.hpp:140
sycl_device_binary_property_set PropertySetsBegin
Definition: compiler.hpp:172
sycl_device_binary_property_set PropertySetsEnd
Definition: compiler.hpp:173
const char * ManifestStart
Pointer to the manifest data start.
Definition: compiler.hpp:160
const char * DeviceTargetSpec
null-terminated string representation of the device's target architecture which holds one of: __SYCL_...
Definition: compiler.hpp:152
uint16_t Version
version of this structure - for backward compatibility; all modifications which change order/type/off...
Definition: compiler.hpp:136
const unsigned char * BinaryEnd
Pointer to the target code end.
Definition: compiler.hpp:166