File: sysman_ras.h

package info (click to toggle)
intel-compute-runtime 25.48.36300.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,652 kB
  • sloc: cpp: 939,022; lisp: 2,090; sh: 722; makefile: 162; python: 21
file content (62 lines) | stat: -rw-r--r-- 1,781 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
56
57
58
59
60
61
62
/*
 * Copyright (C) 2023-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once
#include "level_zero/api/sysman/zes_handles_struct.h"
#include "level_zero/sysman/source/device/sysman_device.h"
#include <level_zero/zes_api.h>

#include <mutex>
#include <vector>

namespace L0 {
namespace Sysman {

struct OsSysman;

class Ras : _zes_ras_handle_t {
  public:
    virtual ~Ras() = default;
    virtual ze_result_t rasGetProperties(zes_ras_properties_t *pProperties) = 0;
    virtual ze_result_t rasGetConfig(zes_ras_config_t *pConfig) = 0;
    virtual ze_result_t rasSetConfig(const zes_ras_config_t *pConfig) = 0;
    virtual ze_result_t rasGetState(zes_ras_state_t *pState, ze_bool_t clear) = 0;
    virtual ze_result_t rasGetStateExp(uint32_t *pCount, zes_ras_state_exp_t *pState) = 0;
    virtual ze_result_t rasClearStateExp(zes_ras_error_category_exp_t category) = 0;

    static Ras *fromHandle(zes_ras_handle_t handle) {
        return static_cast<Ras *>(handle);
    }

    inline zes_ras_handle_t toHandle() { return this; }
    bool isRasErrorSupported = false;
    zes_ras_error_type_t rasErrorType{};
};

struct RasHandleContext {
    RasHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
    MOCKABLE_VIRTUAL ~RasHandleContext();

    MOCKABLE_VIRTUAL void init(uint32_t subDeviceCount);
    void releaseRasHandles();

    ze_result_t rasGet(uint32_t *pCount, zes_ras_handle_t *phRas);

    OsSysman *pOsSysman = nullptr;
    std::vector<Ras *> handleList = {};
    bool isRasInitDone() {
        return rasInitDone;
    }

  private:
    void createHandle(zes_ras_error_type_t type, ze_bool_t isSubDevice, uint32_t subDeviceId);
    std::once_flag initRasOnce;
    bool rasInitDone = false;
};

} // namespace Sysman
} // namespace L0