Skip to content

Commit e67b566

Browse files
author
Hugh Delaney
committed
Use urEnqueueNativeCommandExp if supported
Don't branch on backend, use UR entry point if it is supported. Also add equivalent enum to PI.
1 parent df7f0ae commit e67b566

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

sycl/include/sycl/detail/pi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ typedef enum {
513513

514514
// Virtual memory support
515515
PI_EXT_ONEAPI_DEVICE_INFO_SUPPORTS_VIRTUAL_MEM = 0x2011E,
516+
// Native enqueue
517+
PI_EXT_ONEAPI_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT = 0x2011F,
516518
} _pi_device_info;
517519

518520
typedef enum {

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,9 @@ inline pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
13251325
PI_TO_UR_MAP_DEVICE_INFO(
13261326
PI_EXT_ONEAPI_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT,
13271327
UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP)
1328+
PI_TO_UR_MAP_DEVICE_INFO(
1329+
PI_EXT_ONEAPI_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT,
1330+
UR_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT_EXP)
13281331
PI_TO_UR_MAP_DEVICE_INFO(PI_EXT_INTEL_DEVICE_INFO_ESIMD_SUPPORT,
13291332
UR_DEVICE_INFO_ESIMD_SUPPORT)
13301333
PI_TO_UR_MAP_DEVICE_INFO(PI_EXT_ONEAPI_DEVICE_INFO_COMPONENT_DEVICES,

sycl/source/detail/scheduler/commands.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,13 @@ class DispatchHostTask {
420420
HostTask.MQueue->getContextImplPtr()};
421421
// TODO: should all the backends that support this entry point use this
422422
// for host task?
423-
if (IH.get_backend() == backend::ext_oneapi_cuda ||
424-
IH.get_backend() == backend::ext_oneapi_hip) {
423+
auto &Queue = HostTask.MQueue;
424+
bool NativeCommandSupport = false;
425+
Queue->getPlugin()->call<PiApiKind::piDeviceGetInfo>(
426+
detail::getSyclObjImpl(Queue->get_device())->getHandleRef(),
427+
PI_EXT_ONEAPI_DEVICE_INFO_ENQUEUE_NATIVE_COMMAND_SUPPORT,
428+
sizeof(NativeCommandSupport), &NativeCommandSupport, nullptr);
429+
if (NativeCommandSupport) {
425430
EnqueueNativeCommandData CustomOpData{
426431
IH, HostTask.MHostTask->MInteropTask};
427432

@@ -432,11 +437,9 @@ class DispatchHostTask {
432437
//
433438
// This entry point is needed in order to migrate memory across
434439
// devices in the same context for CUDA and HIP backends
435-
HostTask.MQueue->getPlugin()
436-
->call<PiApiKind::piextEnqueueNativeCommand>(
437-
HostTask.MQueue->getHandleRef(), InteropFreeFunc,
438-
&CustomOpData, MReqPiMem.size(), MReqPiMem.data(), 0, nullptr,
439-
nullptr);
440+
Queue->getPlugin()->call<PiApiKind::piextEnqueueNativeCommand>(
441+
HostTask.MQueue->getHandleRef(), InteropFreeFunc, &CustomOpData,
442+
MReqPiMem.size(), MReqPiMem.data(), 0, nullptr, nullptr);
440443
} else {
441444
HostTask.MHostTask->call(MThisCmd->MEvent->getHostProfilingInfo(),
442445
IH);

0 commit comments

Comments
 (0)