File: driver.h

package info (click to toggle)
intel-compute-runtime 26.05.37020.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,596 kB
  • sloc: cpp: 976,037; lisp: 2,096; sh: 704; makefile: 162
file content (55 lines) | stat: -rw-r--r-- 1,307 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
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (C) 2020-2026 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include <level_zero/ze_api.h>

#include <atomic>
#include <mutex>
#include <vector>

namespace L0 {

class Driver {
  public:
    MOCKABLE_VIRTUAL ze_result_t driverInit();
    MOCKABLE_VIRTUAL void initialize(ze_result_t *result);
    static Driver *get() { return driver; }
    virtual ~Driver() = default;
    void tryInitGtpin();
    MOCKABLE_VIRTUAL ze_result_t driverHandleGet(uint32_t *pCount, ze_driver_handle_t *phDrivers);
    unsigned int getPid() const {
        return pid;
    }

  protected:
    static Driver *driver;
    uint32_t pid = 0;
    std::once_flag initDriverOnce;
    static ze_result_t initStatus;
    std::atomic<bool> gtPinInitializationNeeded{false};
    std::mutex gtpinInitMtx;
};

struct L0EnvVariables {
    uint32_t programDebugging;
    bool metrics;
    bool pin;
    bool sysman;
    bool pciIdDeviceOrder;
    bool fp64Emulation;
};

ze_result_t init(ze_init_flags_t);
ze_result_t initDrivers(uint32_t *pCount, ze_driver_handle_t *phDrivers, ze_init_driver_type_desc_t *desc);

extern bool sysmanInitFromCore;
extern uint32_t driverCount;
extern std::vector<_ze_driver_handle_t *> *globalDriverHandles;
extern bool levelZeroDriverInitialized;
} // namespace L0