2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2022-01-31 11:06:18 +00:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-03-06 11:09:57 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
#include "shared/source/command_stream/task_count_helper.h"
|
|
|
|
|
|
2020-07-29 02:45:54 -07:00
|
|
|
#include <level_zero/ze_api.h>
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2022-02-16 10:22:03 +00:00
|
|
|
#include <chrono>
|
2020-03-06 11:09:57 +01:00
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
|
|
struct _ze_fence_handle_t {};
|
|
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
|
2022-08-30 11:35:43 +00:00
|
|
|
struct CommandQueueImp;
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
struct Fence : _ze_fence_handle_t {
|
|
|
|
|
static Fence *create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc);
|
|
|
|
|
virtual ~Fence() = default;
|
2022-03-17 09:43:17 +00:00
|
|
|
MOCKABLE_VIRTUAL ze_result_t destroy() {
|
2020-05-13 11:25:29 +02:00
|
|
|
delete this;
|
|
|
|
|
return ZE_RESULT_SUCCESS;
|
|
|
|
|
}
|
2022-03-17 09:43:17 +00:00
|
|
|
MOCKABLE_VIRTUAL ze_result_t hostSynchronize(uint64_t timeout);
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t queryStatus();
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t assignTaskCountFromCsr();
|
2022-03-17 09:43:17 +00:00
|
|
|
MOCKABLE_VIRTUAL ze_result_t reset(bool signaled);
|
2020-05-13 11:25:29 +02:00
|
|
|
|
2022-03-17 09:43:17 +00:00
|
|
|
static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }
|
2020-05-13 11:25:29 +02:00
|
|
|
|
2022-03-17 09:43:17 +00:00
|
|
|
inline ze_fence_handle_t toHandle() { return this; }
|
2020-05-13 11:25:29 +02:00
|
|
|
|
|
|
|
|
protected:
|
2022-03-17 09:43:17 +00:00
|
|
|
Fence(CommandQueueImp *cmdQueueImp) : cmdQueue(cmdQueueImp) {}
|
|
|
|
|
|
|
|
|
|
std::chrono::microseconds gpuHangCheckPeriod{500'000};
|
2020-05-13 11:25:29 +02:00
|
|
|
CommandQueueImp *cmdQueue;
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType taskCount = 0;
|
2020-05-13 11:25:29 +02:00
|
|
|
};
|
2022-03-17 09:43:17 +00:00
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
} // namespace L0
|