1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
/*
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/driver_experimental/zex_cmdlist.h"
#include "level_zero/core/source/cmdlist/cmdlist.h"
#include "level_zero/core/source/cmdlist/cmdlist_host_function_parameters.h"
#include "level_zero/ze_intel_gpu.h"
namespace L0 {
ze_result_t ZE_APICALL
zexCommandListAppendWaitOnMemory(
zex_command_list_handle_t hCommandList,
zex_wait_on_mem_desc_t *desc,
void *ptr,
uint32_t data,
zex_event_handle_t hSignalEvent) {
try {
{
hCommandList = toInternalType(hCommandList);
if (nullptr == hCommandList) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
}
return L0::CommandList::fromHandle(hCommandList)->appendWaitOnMemory(reinterpret_cast<void *>(desc), ptr, static_cast<uint64_t>(data), static_cast<ze_event_handle_t>(hSignalEvent), false);
} catch (ze_result_t &result) {
return result;
} catch (std::bad_alloc &) {
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
} catch (std::exception &) {
return ZE_RESULT_ERROR_UNKNOWN;
}
}
ze_result_t ZE_APICALL
zexCommandListAppendWaitOnMemory64(
zex_command_list_handle_t hCommandList,
zex_wait_on_mem_desc_t *desc,
void *ptr,
uint64_t data,
zex_event_handle_t hSignalEvent) {
hCommandList = toInternalType(hCommandList);
if (!hCommandList) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
return L0::CommandList::fromHandle(hCommandList)->appendWaitOnMemory(reinterpret_cast<void *>(desc), ptr, data, static_cast<ze_event_handle_t>(hSignalEvent), true);
}
ze_result_t ZE_APICALL
zexCommandListAppendWriteToMemory(
zex_command_list_handle_t hCommandList,
zex_write_to_mem_desc_t *desc,
void *ptr,
uint64_t data) {
try {
{
hCommandList = toInternalType(hCommandList);
if (nullptr == hCommandList) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
}
return L0::CommandList::fromHandle(hCommandList)->appendWriteToMemory(reinterpret_cast<void *>(desc), ptr, data);
} catch (ze_result_t &result) {
return result;
} catch (std::bad_alloc &) {
return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
} catch (std::exception &) {
return ZE_RESULT_ERROR_UNKNOWN;
}
}
ze_result_t ZE_APICALL
zexCommandListAppendHostFunction(
ze_command_list_handle_t hCommandList,
void *pHostFunction,
void *pUserData,
void *pNext,
ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) {
CmdListHostFunctionParameters parameters{};
return L0::CommandList::fromHandle(hCommandList)->appendHostFunction(pHostFunction, pUserData, pNext, hSignalEvent, numWaitEvents, phWaitEvents, parameters);
}
} // namespace L0
extern "C" {
ZE_APIEXPORT ze_result_t ZE_APICALL
zexCommandListAppendWaitOnMemory(
zex_command_list_handle_t hCommandList,
zex_wait_on_mem_desc_t *desc,
void *ptr,
uint32_t data,
zex_event_handle_t hSignalEvent) {
return L0::zexCommandListAppendWaitOnMemory(hCommandList, desc, ptr, data, hSignalEvent);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zexCommandListAppendWaitOnMemory64(
zex_command_list_handle_t hCommandList,
zex_wait_on_mem_desc_t *desc,
void *ptr,
uint64_t data,
zex_event_handle_t hSignalEvent) {
return L0::zexCommandListAppendWaitOnMemory64(hCommandList, desc, ptr, data, hSignalEvent);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zexCommandListAppendWriteToMemory(
zex_command_list_handle_t hCommandList,
zex_write_to_mem_desc_t *desc,
void *ptr,
uint64_t data) {
return L0::zexCommandListAppendWriteToMemory(hCommandList, desc, ptr, data);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zexCommandListAppendHostFunction(
ze_command_list_handle_t hCommandList,
void *pHostFunction,
void *pUserData,
void *pNext,
ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) {
return L0::zexCommandListAppendHostFunction(hCommandList, pHostFunction, pUserData, pNext, hSignalEvent, numWaitEvents, phWaitEvents);
}
} // extern "C"
|