File: wait_util.cpp

package info (click to toggle)
intel-compute-runtime 25.35.35096.9-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,324 kB
  • sloc: cpp: 926,243; lisp: 3,433; sh: 715; makefile: 162; python: 21
file content (84 lines) | stat: -rw-r--r-- 2,343 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (C) 2021-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/utilities/wait_util.h"

#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/utilities/cpu_info.h"

namespace NEO {

namespace WaitUtils {

WaitpkgUse waitpkgUse = WaitpkgUse::uninitialized;

int64_t waitPkgThresholdInMicroSeconds = defaultWaitPkgThresholdInMicroSeconds;
uint64_t waitpkgCounterValue = defaultCounterValue;
uint32_t waitpkgControlValue = defaultControlValue;
uint32_t waitCount = defaultWaitCount;

#ifdef SUPPORTS_WAITPKG
bool waitpkgSupport = SUPPORTS_WAITPKG;
#else
bool waitpkgSupport = false;
#endif

void init(WaitpkgUse inputWaitpkgUse, const HardwareInfo &hwInfo) {
    if (debugManager.flags.WaitLoopCount.get() != -1) {
        waitCount = debugManager.flags.WaitLoopCount.get();
    }

    if (waitpkgUse > WaitpkgUse::noUse) {
        return;
    }

    if (!(waitpkgSupport && CpuInfo::getInstance().isFeatureSupported(CpuInfo::featureWaitPkg))) {
        waitpkgUse = WaitpkgUse::noUse;
        return;
    }

    if (debugManager.flags.EnableWaitpkg.get() != -1) {
        inputWaitpkgUse = static_cast<WaitpkgUse>(debugManager.flags.EnableWaitpkg.get());
    }

    waitpkgUse = inputWaitpkgUse;

    if (!hwInfo.capabilityTable.isIntegratedDevice) {
        waitPkgThresholdInMicroSeconds = WaitUtils::defaultWaitPkgThresholdForDiscreteInMicroSeconds;
    }

    if (waitpkgUse == WaitpkgUse::umonitorAndUmwait) {
        waitCount = 0u;
    }

    overrideWaitpkgParams();
}

void overrideWaitpkgParams() {
    if (debugManager.flags.WaitpkgCounterValue.get() != -1) {
        waitpkgCounterValue = debugManager.flags.WaitpkgCounterValue.get();
    }

    if (debugManager.flags.WaitpkgControlValue.get() != -1) {
        waitpkgControlValue = debugManager.flags.WaitpkgControlValue.get();
    }

    if (debugManager.flags.WaitpkgThreshold.get() != -1) {
        waitPkgThresholdInMicroSeconds = debugManager.flags.WaitpkgThreshold.get();
    }
}

void adjustWaitpkgParamsForUllsLight() {
    waitPkgThresholdInMicroSeconds = defaultWaitPkgThresholdForUllsLightInMicroSeconds;
    waitpkgCounterValue = defaultCounterValueForUllsLight;
    overrideWaitpkgParams();
}

} // namespace WaitUtils

} // namespace NEO