@@ -108,7 +108,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
108
108
phProgram);
109
109
}
110
110
111
- ur_program_handle_t Program = new ur_program_handle_t_ ();
111
+ ur_program_handle_t Program = new ur_program_handle_t_{};
112
+ Program->URContext = hContext;
113
+ Program->Binary = RealBinary;
114
+ Program->BinarySizeInBytes = RealLength;
112
115
auto Res = olCreateProgram (hContext->Device ->OffloadDevice , RealBinary,
113
116
RealLength, &Program->OffloadProgram );
114
117
@@ -137,6 +140,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
137
140
return UR_RESULT_SUCCESS;
138
141
}
139
142
143
+ UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile (ur_context_handle_t ,
144
+ ur_program_handle_t ,
145
+ const char *) {
146
+ // Do nothing, program is built upon creation
147
+ return UR_RESULT_SUCCESS;
148
+ }
149
+
150
+ UR_APIEXPORT ur_result_t UR_APICALL
151
+ urProgramCreateWithIL (ur_context_handle_t , const void *, size_t ,
152
+ const ur_program_properties_t *, ur_program_handle_t *) {
153
+ return UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE;
154
+ }
155
+
140
156
UR_APIEXPORT ur_result_t UR_APICALL
141
157
urProgramGetInfo (ur_program_handle_t hProgram, ur_program_info_t propName,
142
158
size_t propSize, void *pPropValue, size_t *pPropSizeRet) {
@@ -145,8 +161,42 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
145
161
switch (propName) {
146
162
case UR_PROGRAM_INFO_REFERENCE_COUNT:
147
163
return ReturnValue (hProgram->RefCount .load ());
148
- default :
164
+ case UR_PROGRAM_INFO_CONTEXT:
165
+ return ReturnValue (hProgram->URContext );
166
+ case UR_PROGRAM_INFO_NUM_DEVICES:
167
+ return ReturnValue (1 );
168
+ case UR_PROGRAM_INFO_DEVICES:
169
+ return ReturnValue (&hProgram->URContext ->Device , 1 );
170
+ case UR_PROGRAM_INFO_IL:
171
+ return ReturnValue (reinterpret_cast <const char *>(0 ), 0 );
172
+ case UR_PROGRAM_INFO_BINARY_SIZES:
173
+ return ReturnValue (&hProgram->BinarySizeInBytes , 1 );
174
+ case UR_PROGRAM_INFO_BINARIES: {
175
+ if (!pPropValue && !pPropSizeRet) {
176
+ return UR_RESULT_ERROR_INVALID_NULL_POINTER;
177
+ }
178
+
179
+ if (pPropValue != nullptr ) {
180
+ if (propSize < sizeof (void *)) {
181
+ return UR_RESULT_ERROR_INVALID_SIZE;
182
+ }
183
+
184
+ std::memcpy (*reinterpret_cast <void **>(pPropValue), hProgram->Binary ,
185
+ hProgram->BinarySizeInBytes );
186
+ }
187
+
188
+ if (pPropSizeRet != nullptr ) {
189
+ *pPropSizeRet = sizeof (void *);
190
+ }
191
+ break ;
192
+ }
193
+ case UR_PROGRAM_INFO_NUM_KERNELS:
194
+ case UR_PROGRAM_INFO_KERNEL_NAMES:
195
+ // Program introspection is not available for liboffload (or generally,
196
+ // amdgpu/cuda)
149
197
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
198
+ default :
199
+ return UR_RESULT_ERROR_INVALID_ENUMERATION;
150
200
}
151
201
152
202
return UR_RESULT_SUCCESS;
0 commit comments