CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
121 lines
4.2 KiB
C++
121 lines
4.2 KiB
C++
//===- AMDGPUMCResourceInfo.h ----- MC Resource Info --------------*- C++ -*-=//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file
|
|
/// \brief MC infrastructure to propagate the function level resource usage
|
|
/// info.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
|
|
|
|
#include "AMDGPUResourceUsageAnalysis.h"
|
|
#include "MCTargetDesc/AMDGPUMCExpr.h"
|
|
|
|
namespace llvm {
|
|
|
|
class MCContext;
|
|
class MCSymbol;
|
|
class StringRef;
|
|
class MachineFunction;
|
|
|
|
class MCResourceInfo {
|
|
public:
|
|
enum ResourceInfoKind {
|
|
RIK_NumVGPR,
|
|
RIK_NumAGPR,
|
|
RIK_NumSGPR,
|
|
RIK_NumNamedBarrier,
|
|
RIK_PrivateSegSize,
|
|
RIK_UsesVCC,
|
|
RIK_UsesFlatScratch,
|
|
RIK_HasDynSizedStack,
|
|
RIK_HasRecursion,
|
|
RIK_HasIndirectCall
|
|
};
|
|
|
|
private:
|
|
int32_t MaxVGPR = 0;
|
|
int32_t MaxAGPR = 0;
|
|
int32_t MaxSGPR = 0;
|
|
int32_t MaxNamedBarrier = 0;
|
|
|
|
// Whether the MCResourceInfo has been finalized through finalize(MCContext
|
|
// &). Should only be called once, at the end of AsmPrinting to assign MaxXGPR
|
|
// symbols to their final value.
|
|
bool Finalized = false;
|
|
|
|
void assignResourceInfoExpr(int64_t localValue, ResourceInfoKind RIK,
|
|
AMDGPUMCExpr::VariantKind Kind,
|
|
const MachineFunction &MF,
|
|
const SmallVectorImpl<const Function *> &Callees,
|
|
MCContext &OutContext);
|
|
|
|
// Assigns expression for Max S/V/A-GPRs to the referenced symbols.
|
|
void assignMaxRegs(MCContext &OutContext);
|
|
|
|
// Take flattened max of cyclic function calls' knowns. For example, for
|
|
// a cycle A->B->C->D->A, take max(A, B, C, D) for A and have B, C, D have the
|
|
// propgated value from A.
|
|
const MCExpr *flattenedCycleMax(MCSymbol *RecSym, ResourceInfoKind RIK,
|
|
MCContext &OutContext);
|
|
|
|
public:
|
|
MCResourceInfo() = default;
|
|
void addMaxVGPRCandidate(int32_t candidate) {
|
|
MaxVGPR = std::max(MaxVGPR, candidate);
|
|
}
|
|
void addMaxAGPRCandidate(int32_t candidate) {
|
|
MaxAGPR = std::max(MaxAGPR, candidate);
|
|
}
|
|
void addMaxSGPRCandidate(int32_t candidate) {
|
|
MaxSGPR = std::max(MaxSGPR, candidate);
|
|
}
|
|
void addMaxNamedBarrierCandidate(int32_t candidate) {
|
|
MaxNamedBarrier = std::max(MaxNamedBarrier, candidate);
|
|
}
|
|
|
|
MCSymbol *getSymbol(StringRef FuncName, ResourceInfoKind RIK,
|
|
MCContext &OutContext);
|
|
const MCExpr *getSymRefExpr(StringRef FuncName, ResourceInfoKind RIK,
|
|
MCContext &Ctx);
|
|
|
|
void reset();
|
|
|
|
// Resolves the final symbols that requires the inter-function resource info
|
|
// to be resolved.
|
|
void finalize(MCContext &OutContext);
|
|
|
|
MCSymbol *getMaxVGPRSymbol(MCContext &OutContext);
|
|
MCSymbol *getMaxAGPRSymbol(MCContext &OutContext);
|
|
MCSymbol *getMaxSGPRSymbol(MCContext &OutContext);
|
|
MCSymbol *getMaxNamedBarrierSymbol(MCContext &OutContext);
|
|
|
|
/// AMDGPUResourceUsageAnalysis gathers resource usage on a per-function
|
|
/// granularity. However, some resource info has to be assigned the call
|
|
/// transitive maximum or accumulative. For example, if A calls B and B's VGPR
|
|
/// usage exceeds A's, A should be assigned B's VGPR usage. Furthermore,
|
|
/// functions with indirect calls should be assigned the module level maximum.
|
|
///
|
|
/// When link-time object linking is enabled, skip all call-transitive
|
|
/// propagation and emit concrete per-function values for every resource
|
|
/// symbol. Cross-TU aggregation is then the linker's responsibility.
|
|
void gatherResourceInfo(
|
|
const MachineFunction &MF,
|
|
const AMDGPUResourceUsageAnalysisWrapperPass::FunctionResourceInfo &FRI,
|
|
MCContext &OutContext);
|
|
|
|
const MCExpr *createTotalNumVGPRs(const MachineFunction &MF, MCContext &Ctx);
|
|
const MCExpr *createTotalNumSGPRs(const MachineFunction &MF, bool hasXnack,
|
|
MCContext &Ctx);
|
|
};
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMCRESOURCEINFO_H
|