@@ -197,6 +197,48 @@ ur_program_handle_t ur_kernel_handle_t_::getProgramHandle() const {
197197 return hProgram;
198198}
199199
200+ ur_result_t ur_kernel_handle_t_::setExecInfo (ur_kernel_exec_info_t propName,
201+ const void *pPropValue) {
202+ std::scoped_lock<ur_shared_mutex> Guard (Mutex);
203+
204+ for (auto &kernel : deviceKernels) {
205+ if (!kernel.has_value ())
206+ continue ;
207+ if (propName == UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS &&
208+ *(static_cast <const ur_bool_t *>(pPropValue)) == true ) {
209+ // The whole point for users really was to not need to know anything
210+ // about the types of allocations kernel uses. So in DPC++ we always
211+ // just set all 3 modes for each kernel.
212+ ze_kernel_indirect_access_flags_t indirectFlags =
213+ ZE_KERNEL_INDIRECT_ACCESS_FLAG_HOST |
214+ ZE_KERNEL_INDIRECT_ACCESS_FLAG_DEVICE |
215+ ZE_KERNEL_INDIRECT_ACCESS_FLAG_SHARED;
216+ ZE2UR_CALL (zeKernelSetIndirectAccess,
217+ (kernel->hKernel .get (), indirectFlags));
218+ } else if (propName == UR_KERNEL_EXEC_INFO_CACHE_CONFIG) {
219+ ze_cache_config_flag_t zeCacheConfig{};
220+ auto cacheConfig =
221+ *(static_cast <const ur_kernel_cache_config_t *>(pPropValue));
222+ if (cacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_SLM)
223+ zeCacheConfig = ZE_CACHE_CONFIG_FLAG_LARGE_SLM;
224+ else if (cacheConfig == UR_KERNEL_CACHE_CONFIG_LARGE_DATA)
225+ zeCacheConfig = ZE_CACHE_CONFIG_FLAG_LARGE_DATA;
226+ else if (cacheConfig == UR_KERNEL_CACHE_CONFIG_DEFAULT)
227+ zeCacheConfig = static_cast <ze_cache_config_flag_t >(0 );
228+ else
229+ // Unexpected cache configuration value.
230+ return UR_RESULT_ERROR_INVALID_VALUE;
231+ ZE2UR_CALL (zeKernelSetCacheConfig,
232+ (kernel->hKernel .get (), zeCacheConfig););
233+ } else {
234+ logger::error (" urKernelSetExecInfo: unsupported ParamName" );
235+ return UR_RESULT_ERROR_INVALID_VALUE;
236+ }
237+ }
238+
239+ return UR_RESULT_SUCCESS;
240+ }
241+
200242namespace ur ::level_zero {
201243ur_result_t urKernelCreate (ur_program_handle_t hProgram,
202244 const char *pKernelName,
@@ -248,4 +290,19 @@ ur_result_t urKernelSetArgPointer(
248290 TRACK_SCOPE_LATENCY (" ur_kernel_handle_t_::setArgPointer" );
249291 return hKernel->setArgPointer (argIndex, pProperties, pArgValue);
250292}
293+
294+ ur_result_t urKernelSetExecInfo (
295+ ur_kernel_handle_t hKernel, // /< [in] handle of the kernel object
296+ ur_kernel_exec_info_t propName, // /< [in] name of the execution attribute
297+ size_t propSize, // /< [in] size in byte the attribute value
298+ const ur_kernel_exec_info_properties_t
299+ *pProperties, // /< [in][optional] pointer to execution info properties
300+ const void *pPropValue // /< [in][range(0, propSize)] pointer to memory
301+ // /< location holding the property value.
302+ ) {
303+ std::ignore = propSize;
304+ std::ignore = pProperties;
305+
306+ return hKernel->setExecInfo (propName, pPropValue);
307+ }
251308} // namespace ur::level_zero
0 commit comments