feature: initial support of zexCounterBasedEventCreate

Related-To: NEO-8145

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz 2024-01-12 10:26:36 +00:00 committed by Compute-Runtime-Automation
parent d1061cd923
commit d8f8b70dd7
3 changed files with 48 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include "shared/source/memory_manager/graphics_allocation.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/event/event.h"
namespace L0 {
@ -36,7 +37,29 @@ zexEventGetDeviceAddress(ze_event_handle_t event, uint64_t *completionValue, uin
ZE_APIEXPORT ze_result_t ZE_APICALL
zexCounterBasedEventCreate(ze_context_handle_t hContext, ze_device_handle_t hDevice, uint64_t *deviceAddress, uint64_t *hostAddress, uint64_t completionValue, const ze_event_desc_t *desc, ze_event_handle_t *phEvent) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
constexpr uint32_t counterBasedFlags = (ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE | ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_NON_IMMEDIATE);
constexpr EventDescriptor eventDescriptor = {
nullptr, // eventPoolAllocation
0, // totalEventSize
EventPacketsCount::maxKernelSplit, // maxKernelCount
0, // maxPacketsCount
counterBasedFlags, // counterBasedFlags
false, // timestampPool
false, // kerneMappedTsPoolFlag
false, // importedIpcPool
false, // ipcPool
};
auto device = Device::fromHandle(hDevice);
if (!hDevice || !deviceAddress || !hostAddress || !desc || !phEvent) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*phEvent = Event::create<uint64_t>(eventDescriptor, desc, device);
return ZE_RESULT_SUCCESS;
}
} // namespace L0

View File

@ -422,7 +422,9 @@ void EventImp<TagSizeT>::copyDataToEventAlloc(void *dstHostAddr, uint64_t dstGpu
template <typename TagSizeT>
ze_result_t EventImp<TagSizeT>::hostEventSetValue(TagSizeT eventVal) {
UNRECOVERABLE_IF(hostAddress == nullptr);
if (!hostAddress) {
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
}
if (isEventTimestampFlagSet()) {
return hostEventSetValueTimestamps(eventVal);

View File

@ -3527,6 +3527,27 @@ HWTEST2_F(InOrderCmdListTests, givenIncorrectInputParamsWhenAskingForEventAddres
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexEventGetDeviceAddress(eventHandle, &counterValue, &address));
}
HWTEST2_F(InOrderCmdListTests, givenCorrectInputParamsWhenCreatingCbEventThenReturnSuccess, IsAtLeastSkl) {
uint64_t counterValue = 0;
uint64_t *hostAddress = &counterValue;
uint64_t *gpuAddress = &counterValue;
ze_event_desc_t eventDesc = {};
ze_event_handle_t handle = nullptr;
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, &eventDesc, nullptr));
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, nullptr, &handle));
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, gpuAddress, nullptr, counterValue, &eventDesc, &handle));
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, device, nullptr, hostAddress, counterValue, &eventDesc, &handle));
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zexCounterBasedEventCreate(context, nullptr, gpuAddress, hostAddress, counterValue, &eventDesc, &handle));
EXPECT_EQ(ZE_RESULT_SUCCESS, zexCounterBasedEventCreate(context, device, gpuAddress, hostAddress, counterValue, &eventDesc, &handle));
ASSERT_NE(nullptr, Event::fromHandle(handle));
zeEventDestroy(handle);
}
HWTEST2_F(InOrderCmdListTests, givenCounterBasedEventWhenAskingForEventAddressAndValueThenReturnCorrectValues, IsAtLeastSkl) {
auto eventPool = createEvents<FamilyType>(1, false);
uint64_t counterValue = -1;