File: addressing_mode_helper.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 (67 lines) | stat: -rw-r--r-- 2,395 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (C) 2022-2024 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/helpers/addressing_mode_helper.h"

#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/compiler_product_helper.h"
#include "shared/source/program/kernel_info.h"

namespace NEO::AddressingModeHelper {

bool failBuildProgramWithStatefulAccess(const RootDeviceEnvironment &rootDeviceEnvironment) {
    const auto &compilerProductHelper = rootDeviceEnvironment.getHelper<CompilerProductHelper>();

    auto failBuildProgram = compilerProductHelper.failBuildProgramWithStatefulAccessPreference();
    if (NEO::debugManager.flags.FailBuildProgramWithStatefulAccess.get() != -1) {
        failBuildProgram = static_cast<bool>(NEO::debugManager.flags.FailBuildProgramWithStatefulAccess.get());
    }

    auto forceToStatelessRequired = compilerProductHelper.isForceToStatelessRequired();

    return failBuildProgram && forceToStatelessRequired;
}

inline bool argPointerIsStateful(const ArgDescriptor &arg) {
    return arg.is<NEO::ArgDescriptor::argTPointer>() &&
           (NEO::isValidOffset(arg.as<NEO::ArgDescPointer>().bindless) ||
            NEO::isValidOffset(arg.as<NEO::ArgDescPointer>().bindful));
}

bool containsStatefulAccess(const KernelDescriptor &kernelDescriptor, bool skipLastExplicitArg) {
    auto size = static_cast<int32_t>(kernelDescriptor.payloadMappings.explicitArgs.size());
    if (skipLastExplicitArg) {
        size--;
    }
    for (auto i = 0; i < size; i++) {
        if (argPointerIsStateful(kernelDescriptor.payloadMappings.explicitArgs[i])) {
            return true;
        }
    }
    return false;
}

bool containsStatefulAccess(const std::vector<KernelInfo *> &kernelInfos, bool skipLastExplicitArg) {
    for (const auto &kernelInfo : kernelInfos) {
        if (containsStatefulAccess(kernelInfo->kernelDescriptor, skipLastExplicitArg)) {
            return true;
        }
    }
    return false;
}

bool containsBindlessKernel(const std::vector<KernelInfo *> &kernelInfos) {
    for (const auto &kernelInfo : kernelInfos) {
        if (NEO::KernelDescriptor::isBindlessAddressingKernel(kernelInfo->kernelDescriptor)) {
            return true;
        }
    }
    return false;
}

} // namespace NEO::AddressingModeHelper