File: fence.h

package info (click to toggle)
intel-compute-runtime 22.43.24595.41-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,740 kB
  • sloc: cpp: 631,142; lisp: 3,515; sh: 470; makefile: 76; python: 21
file content (45 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download
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
/*
 * Copyright (C) 2020-2022 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include <level_zero/ze_api.h>

#include <chrono>
#include <limits>

struct _ze_fence_handle_t {};

namespace L0 {

struct CommandQueueImp;

struct Fence : _ze_fence_handle_t {
    static Fence *create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc);
    virtual ~Fence() = default;
    MOCKABLE_VIRTUAL ze_result_t destroy() {
        delete this;
        return ZE_RESULT_SUCCESS;
    }
    MOCKABLE_VIRTUAL ze_result_t hostSynchronize(uint64_t timeout);
    MOCKABLE_VIRTUAL ze_result_t queryStatus();
    MOCKABLE_VIRTUAL ze_result_t assignTaskCountFromCsr();
    MOCKABLE_VIRTUAL ze_result_t reset(bool signaled);

    static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }

    inline ze_fence_handle_t toHandle() { return this; }

  protected:
    Fence(CommandQueueImp *cmdQueueImp) : cmdQueue(cmdQueueImp) {}

    std::chrono::microseconds gpuHangCheckPeriod{500'000};
    CommandQueueImp *cmdQueue;
    uint32_t taskCount = 0;
};

} // namespace L0