File: compiler_product_helper.h

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 (168 lines) | stat: -rw-r--r-- 8,687 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Copyright (C) 2021-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include "shared/source/helpers/hw_mapper.h"
#include "shared/source/helpers/product_config_helper.h"
#include "shared/source/utilities/stackvec.h"

#include "neo_igfxfmid.h"
#include "ocl_igc_interface/code_type.h"

#include <memory>

namespace NEO {

class CompilerProductHelper;
struct HardwareInfo;
class ReleaseHelper;

struct OclCVersion {
    unsigned short major = 0;
    unsigned short minor = 0;
};

constexpr bool operator>(OclCVersion lhs, OclCVersion rhs) {
    return (lhs.major > rhs.major) || ((lhs.major == rhs.major) && (lhs.minor >= rhs.minor));
}

constexpr bool operator==(OclCVersion lhs, OclCVersion rhs) {
    return (lhs.major == rhs.major) && (lhs.minor == rhs.minor);
}

constexpr bool operator>=(OclCVersion lhs, OclCVersion rhs) {
    return (lhs > rhs) || (lhs == rhs);
}

using CompilerProductHelperCreateFunctionType = std::unique_ptr<CompilerProductHelper> (*)();
extern CompilerProductHelperCreateFunctionType compilerProductHelperFactory[IGFX_MAX_PRODUCT];

class CompilerProductHelper {
  public:
    static std::unique_ptr<CompilerProductHelper> create(PRODUCT_FAMILY product) {
        auto createFunction = compilerProductHelperFactory[product];
        if (createFunction == nullptr) {
            return nullptr;
        }
        auto compilerProductHelper = createFunction();
        return compilerProductHelper;
    }

    virtual bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const = 0;
    virtual bool isForceEmuInt32DivRemSPRequired() const = 0;
    virtual bool isStatelessToStatefulBufferOffsetSupported() const = 0;
    virtual bool isMatrixMultiplyAccumulateSupported(const ReleaseHelper *releaseHelper) const = 0;
    virtual bool isMatrixMultiplyAccumulateTF32Supported(const HardwareInfo &hwInfo) const = 0;
    virtual bool isSplitMatrixMultiplyAccumulateSupported(const ReleaseHelper *releaseHelper) const = 0;
    virtual bool isBFloat16ConversionSupported(const ReleaseHelper *releaseHelper) const = 0;
    virtual bool isSubgroupLocalBlockIoSupported() const = 0;
    virtual bool isDotAccumulateSupported() const = 0;
    virtual bool isDotProductAccumulateSystolicSupported(const ReleaseHelper *releaseHelper) const = 0;
    virtual bool isCreateBufferWithPropertiesSupported() const = 0;
    virtual bool isSubgroupNamedBarrierSupported() const = 0;
    virtual bool isSubgroupExtendedBlockReadSupported() const = 0;
    virtual bool isSubgroup2DBlockIOSupported() const = 0;
    virtual bool isSubgroupBufferPrefetchSupported() const = 0;
    virtual bool isForceToStatelessRequired() const = 0;
    virtual bool failBuildProgramWithStatefulAccessPreference() const = 0;
    virtual bool isDotIntegerProductExtensionSupported() const = 0;
    virtual bool oclocEnforceZebinFormat() const = 0;
    virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, HardwareIpVersion config) const = 0;
    virtual const char *getCachingPolicyOptions(bool isDebuggerActive) const = 0;
    virtual uint64_t getHwInfoConfig(const HardwareInfo &hwInfo) const = 0;
    virtual uint32_t getDefaultHwIpVersion() const = 0;
    virtual uint32_t matchRevisionIdWithProductConfig(HardwareIpVersion ipVersion, uint32_t revisionID) const = 0;
    virtual std::string getDeviceExtensions(const HardwareInfo &hwInfo, const ReleaseHelper *releaseHelper) const = 0;
    virtual StackVec<OclCVersion, 5> getDeviceOpenCLCVersions(const HardwareInfo &hwInfo, OclCVersion max) const = 0;
    virtual void adjustHwInfoForIgc(HardwareInfo &hwInfo) const = 0;
    virtual bool isHeaplessModeEnabled(const HardwareInfo &hwInfo) const = 0;
    virtual bool isHeaplessStateInitEnabled(bool heaplessModeEnabled) const = 0;
    virtual void getKernelFp16AtomicCapabilities(const ReleaseHelper *releaseHelper, uint32_t &fp16Caps) const = 0;
    virtual void getKernelFp32AtomicCapabilities(uint32_t &fp32Caps) const = 0;
    virtual void getKernelFp64AtomicCapabilities(uint32_t &fp64Caps) const = 0;
    virtual void getKernelCapabilitiesExtra(const ReleaseHelper *releaseHelper, uint32_t &extraCaps) const = 0;
    virtual bool isBindlessAddressingDisabled(const ReleaseHelper *releaseHelper) const = 0;
    virtual bool isForceBindlessRequired(const HardwareInfo &hwInfo) const = 0;
    virtual const char *getCustomIgcLibraryName() const = 0;
    virtual const char *getFinalizerLibraryName() const = 0;
    virtual bool useIgcAsFcl() const = 0;
    virtual IGC::CodeType::CodeType_t getPreferredIntermediateRepresentation() const = 0;

    virtual ~CompilerProductHelper() = default;
    uint32_t getHwIpVersion(const HardwareInfo &hwInfo) const;

  protected:
    virtual uint32_t getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const = 0;
    CompilerProductHelper() = default;
};

template <PRODUCT_FAMILY gfxProduct>
class CompilerProductHelperHw : public CompilerProductHelper {
  public:
    static std::unique_ptr<CompilerProductHelper> create() {
        auto compilerProductHelper = std::unique_ptr<CompilerProductHelper>(new CompilerProductHelperHw());
        return compilerProductHelper;
    }

    bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const override;
    bool isForceEmuInt32DivRemSPRequired() const override;
    bool isStatelessToStatefulBufferOffsetSupported() const override;
    bool isMatrixMultiplyAccumulateSupported(const ReleaseHelper *releaseHelper) const override;
    bool isMatrixMultiplyAccumulateTF32Supported(const HardwareInfo &hwInfo) const override;
    bool isSplitMatrixMultiplyAccumulateSupported(const ReleaseHelper *releaseHelper) const override;
    bool isBFloat16ConversionSupported(const ReleaseHelper *releaseHelper) const override;
    bool isSubgroupLocalBlockIoSupported() const override;
    bool isDotAccumulateSupported() const override;
    bool isDotProductAccumulateSystolicSupported(const ReleaseHelper *releaseHelper) const override;
    bool isCreateBufferWithPropertiesSupported() const override;
    bool isSubgroupNamedBarrierSupported() const override;
    bool isSubgroupExtendedBlockReadSupported() const override;
    bool isSubgroup2DBlockIOSupported() const override;
    bool isSubgroupBufferPrefetchSupported() const override;
    bool isForceToStatelessRequired() const override;
    bool failBuildProgramWithStatefulAccessPreference() const override;
    bool isDotIntegerProductExtensionSupported() const override;
    bool oclocEnforceZebinFormat() const override;
    void setProductConfigForHwInfo(HardwareInfo &hwInfo, HardwareIpVersion config) const override;
    const char *getCachingPolicyOptions(bool isDebuggerActive) const override;
    uint64_t getHwInfoConfig(const HardwareInfo &hwInfo) const override;
    uint32_t getDefaultHwIpVersion() const override;
    uint32_t matchRevisionIdWithProductConfig(HardwareIpVersion ipVersion, uint32_t revisionID) const override;
    std::string getDeviceExtensions(const HardwareInfo &hwInfo, const ReleaseHelper *releaseHelper) const override;
    StackVec<OclCVersion, 5> getDeviceOpenCLCVersions(const HardwareInfo &hwInfo, OclCVersion max) const override;
    void adjustHwInfoForIgc(HardwareInfo &hwInfo) const override;
    bool isHeaplessModeEnabled(const HardwareInfo &hwInfo) const override;
    bool isHeaplessStateInitEnabled(bool heaplessModeEnabled) const override;
    void getKernelFp16AtomicCapabilities(const ReleaseHelper *releaseHelper, uint32_t &fp16Caps) const override;
    void getKernelFp32AtomicCapabilities(uint32_t &fp32Caps) const override;
    void getKernelFp64AtomicCapabilities(uint32_t &fp64Caps) const override;
    void getKernelCapabilitiesExtra(const ReleaseHelper *releaseHelper, uint32_t &extraCaps) const override;
    bool isBindlessAddressingDisabled(const ReleaseHelper *releaseHelper) const override;
    bool isForceBindlessRequired(const HardwareInfo &hwInfo) const override;
    const char *getCustomIgcLibraryName() const override;
    const char *getFinalizerLibraryName() const override;
    bool useIgcAsFcl() const override;
    IGC::CodeType::CodeType_t getPreferredIntermediateRepresentation() const override;

    ~CompilerProductHelperHw() override = default;

  protected:
    uint32_t getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const override;
    CompilerProductHelperHw();
};

template <PRODUCT_FAMILY gfxProduct>
struct EnableCompilerProductHelper {

    EnableCompilerProductHelper() {
        auto compilerProductHelperCreateFunction = CompilerProductHelperHw<gfxProduct>::create;
        compilerProductHelperFactory[gfxProduct] = compilerProductHelperCreateFunction;
    }
};

} // namespace NEO