Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

130 lines
3.9 KiB
C++

//===--------------------- PipelinePrinter.cpp ------------------*- 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
///
/// This file implements the PipelinePrinter interface.
///
//===----------------------------------------------------------------------===//
#include "PipelinePrinter.h"
#include "CodeRegion.h"
#include "Views/InstructionView.h"
namespace llvm {
namespace mca {
void PipelinePrinter::printRegionHeader(llvm::raw_ostream &OS) const {
StringRef RegionName;
if (!Region.getDescription().empty())
RegionName = Region.getDescription();
OS << "\n[" << RegionIdx << "] Code Region";
if (!RegionName.empty())
OS << " - " << RegionName;
OS << "\n\n";
}
json::Object PipelinePrinter::getJSONReportRegion() const {
json::Object JO;
StringRef RegionName = "";
if (!Region.getDescription().empty())
RegionName = Region.getDescription();
JO.try_emplace("Name", RegionName);
for (const auto &V : Views)
if (V->isSerializable())
JO.try_emplace(V->getNameAsString().str(), V->toJSON());
return JO;
}
json::Object PipelinePrinter::getJSONSimulationParameters() const {
json::Object SimParameters({{"-mcpu", STI.getCPU()},
{"-mtriple", STI.getTargetTriple().getTriple()},
{"-march", STI.getTargetTriple().getArchName()}});
const MCSchedModel &SM = STI.getSchedModel();
if (!SM.isOutOfOrder())
return SimParameters;
if (PO.RegisterFileSize)
SimParameters.try_emplace("-register-file-size", PO.RegisterFileSize);
if (!PO.AssumeNoAlias)
SimParameters.try_emplace("-noalias", PO.AssumeNoAlias);
if (PO.DecodersThroughput)
SimParameters.try_emplace("-decoder-throughput", PO.DecodersThroughput);
if (PO.MicroOpQueueSize)
SimParameters.try_emplace("-micro-op-queue-size", PO.MicroOpQueueSize);
if (PO.DispatchWidth)
SimParameters.try_emplace("-dispatch", PO.DispatchWidth);
if (PO.LoadQueueSize)
SimParameters.try_emplace("-lqueue", PO.LoadQueueSize);
if (PO.StoreQueueSize)
SimParameters.try_emplace("-squeue", PO.StoreQueueSize);
return SimParameters;
}
json::Object PipelinePrinter::getJSONTargetInfo() const {
json::Array Resources;
const MCSchedModel &SM = STI.getSchedModel();
StringRef MCPU = STI.getCPU();
for (unsigned I = 1, E = SM.getNumProcResourceKinds(); I < E; ++I) {
const MCProcResourceDesc &ProcResource = *SM.getProcResource(I);
unsigned NumUnits = ProcResource.NumUnits;
if (ProcResource.SubUnitsIdxBegin || !NumUnits)
continue;
for (unsigned J = 0; J < NumUnits; ++J) {
std::string ResourceName = ProcResource.Name;
if (NumUnits > 1) {
ResourceName += ".";
ResourceName += J;
}
Resources.push_back(ResourceName);
}
}
return json::Object({{"CPUName", MCPU}, {"Resources", std::move(Resources)}});
}
void PipelinePrinter::printReport(json::Object &JO) const {
if (!RegionIdx) {
JO.try_emplace("TargetInfo", getJSONTargetInfo());
JO.try_emplace("SimulationParameters", getJSONSimulationParameters());
// Construct an array of regions.
JO.try_emplace("CodeRegions", json::Array());
}
json::Array *Regions = JO.getArray("CodeRegions");
assert(Regions && "This array must exist!");
Regions->push_back(getJSONReportRegion());
}
void PipelinePrinter::printReport(llvm::raw_ostream &OS) const {
// Don't print the header of this region if it is the default region, and if
// it doesn't have an end location.
if (Region.startLoc().isValid() || Region.endLoc().isValid())
printRegionHeader(OS);
for (const auto &V : Views)
V->printView(OS);
}
} // namespace mca
} // namespace llvm