Skip to content

Commit 3de61fe

Browse files
committed
[L0 v2] Implement urKernelSetExecInfo
1 parent 7f528f1 commit 3de61fe

File tree

7 files changed

+988
-1065
lines changed

7 files changed

+988
-1065
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,6 @@ ur_result_t urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel,
250250
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
251251
}
252252

253-
ur_result_t
254-
urKernelSetExecInfo(ur_kernel_handle_t hKernel, ur_kernel_exec_info_t propName,
255-
size_t propSize,
256-
const ur_kernel_exec_info_properties_t *pProperties,
257-
const void *pPropValue) {
258-
logger::error("{} function not implemented!", __FUNCTION__);
259-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
260-
}
261-
262253
ur_result_t
263254
urKernelSetArgSampler(ur_kernel_handle_t hKernel, uint32_t argIndex,
264255
const ur_kernel_arg_sampler_properties_t *pProperties,

source/adapters/level_zero/v2/kernel.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
200242
namespace ur::level_zero {
201243
ur_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

source/adapters/level_zero/v2/kernel.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ struct ur_kernel_handle_t_ : _ur_object {
5757
const ur_kernel_arg_pointer_properties_t *pProperties,
5858
const void *pArgValue);
5959

60+
// Implementation of urKernelSetExecInfo.
61+
ur_result_t setExecInfo(ur_kernel_exec_info_t propName,
62+
const void *pPropValue);
63+
6064
// Perform cleanup.
6165
ur_result_t release();
6266

0 commit comments

Comments
 (0)