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
146 lines
5.3 KiB
C++
146 lines
5.3 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#include <rocRoller/GPUArchitecture/GPUInstructionInfo.hpp>
|
|
#include <rocRoller/Scheduling/Observers/WaitState/MFMA/XDLWrite94x.hpp>
|
|
|
|
namespace rocRoller
|
|
{
|
|
namespace Scheduling
|
|
{
|
|
int XDLWrite94x::getMaxNops(Instruction const& inst) const
|
|
{
|
|
auto const& architecture = m_context.lock()->targetArchitecture();
|
|
int passes = architecture.GetInstructionInfo(inst.getOpCode()).getLatency();
|
|
bool is950 = architecture.target().isCDNA4GPU();
|
|
|
|
AssertFatal(m_latencyAndNops.contains(passes),
|
|
"Unexpected number of passes",
|
|
ShowValue(architecture.target().toString()),
|
|
ShowValue(inst.getOpCode()),
|
|
ShowValue(passes));
|
|
|
|
int adjustFor950 = (is950 && passes > 2) ? 1 : 0;
|
|
|
|
return m_latencyAndNops.at(passes) + adjustFor950;
|
|
}
|
|
|
|
bool XDLWrite94x::trigger(Instruction const& inst) const
|
|
{
|
|
bool excluded
|
|
= std::find(m_excludedOpCodes.begin(), m_excludedOpCodes.end(), inst.getOpCode())
|
|
!= m_excludedOpCodes.end();
|
|
return GPUInstructionInfo::isMFMA(inst.getOpCode()) && !excluded;
|
|
};
|
|
|
|
int XDLWrite94x::getNops(Instruction const& inst) const
|
|
{
|
|
int decrement = 0;
|
|
|
|
if(GPUInstructionInfo::isSGEMM(inst.getOpCode()))
|
|
{
|
|
decrement = 1;
|
|
}
|
|
|
|
if(GPUInstructionInfo::isMFMA(inst.getOpCode()))
|
|
{
|
|
std::optional<int> value;
|
|
|
|
auto const& srcs = inst.getSrcs();
|
|
|
|
// SrcC RAW
|
|
{
|
|
bool mismatched = false;
|
|
bool overlap = false;
|
|
int requiredNops = 0;
|
|
|
|
AssertFatal(srcs.at(2) != nullptr, "Empty SrcC");
|
|
for(auto const& srcId : srcs.at(2)->getRegisterIds())
|
|
{
|
|
if(m_hazardMap->contains(srcId))
|
|
{
|
|
for(auto const& hazard : m_hazardMap->at(srcId))
|
|
{
|
|
if(hazard.regWasWritten())
|
|
{
|
|
decrement = 2;
|
|
if(GPUInstructionInfo::isDGEMM(inst.getOpCode()))
|
|
{
|
|
decrement = 2;
|
|
}
|
|
else if(GPUInstructionInfo::isSGEMM(inst.getOpCode()))
|
|
{
|
|
decrement = 3;
|
|
}
|
|
overlap = true;
|
|
requiredNops = hazard.getRequiredNops() - decrement;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mismatched = true;
|
|
}
|
|
}
|
|
if(overlap)
|
|
{
|
|
auto const& architecture = m_context.lock()->targetArchitecture();
|
|
int passes = architecture.GetInstructionInfo(inst.getOpCode()).getLatency();
|
|
bool is950 = architecture.target().isCDNA4GPU();
|
|
|
|
if(mismatched)
|
|
{
|
|
int adjustFor950 = (is950 && passes == 2) ? 1 : 0;
|
|
return requiredNops + adjustFor950;
|
|
}
|
|
else
|
|
{
|
|
// Assumes MFMA trigger instruction and this current instruction have same number of passes
|
|
return passes > 2 ? 0 : 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
// SrcA RAW
|
|
AssertFatal(srcs.at(0) != nullptr, "Empty SrcA");
|
|
if((value = checkRegister(srcs.at(0))))
|
|
{
|
|
return *value - decrement;
|
|
}
|
|
|
|
// SrcB RAW
|
|
AssertFatal(srcs.at(1) != nullptr, "Empty SrcB");
|
|
if((value = checkRegister(srcs.at(1))))
|
|
{
|
|
return *value - decrement;
|
|
}
|
|
}
|
|
else if(GPUInstructionInfo::isVMEM(inst.getOpCode())
|
|
|| GPUInstructionInfo::isLDS(inst.getOpCode())
|
|
|| GPUInstructionInfo::isFlat(inst.getOpCode()))
|
|
{
|
|
std::optional<int> value = checkSrcs(inst);
|
|
if(value)
|
|
return *value - decrement;
|
|
}
|
|
else if(GPUInstructionInfo::isVALU(inst.getOpCode()))
|
|
{
|
|
std::optional<int> value;
|
|
|
|
// VALU RAW
|
|
if((value = checkSrcs(inst)))
|
|
{
|
|
return *value - decrement;
|
|
}
|
|
|
|
// VALU WAW
|
|
if((value = checkDsts(inst)))
|
|
{
|
|
return *value - decrement;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
}
|