Files
TheRock/compiler/amd-llvm/llvm/tools/llvm-exegesis/lib/Analysis.h
T
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

117 lines
3.9 KiB
C++

//===-- Analysis.h ----------------------------------------------*- 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
/// Analysis output for benchmark results.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_EXEGESIS_ANALYSIS_H
#define LLVM_TOOLS_LLVM_EXEGESIS_ANALYSIS_H
#include "Clustering.h"
#include "DisassemblerHelper.h"
#include "SchedClassResolution.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
namespace llvm {
namespace exegesis {
// A helper class to analyze benchmark results for a target.
class Analysis {
public:
Analysis(const LLVMState &State,
const BenchmarkClustering &Clustering,
double AnalysisInconsistencyEpsilon,
bool AnalysisDisplayUnstableOpcodes);
// Prints a csv of instructions for each cluster.
struct PrintClusters {};
// Find potential errors in the scheduling information given measurements.
struct PrintSchedClassInconsistencies {};
template <typename Pass> Error run(raw_ostream &OS) const;
private:
using ClusterId = BenchmarkClustering::ClusterId;
// Represents the intersection of a sched class and a cluster.
class SchedClassCluster {
public:
const BenchmarkClustering::ClusterId &id() const {
return ClusterId;
}
const std::vector<size_t> &getPointIds() const { return PointIds; }
void addPoint(size_t PointId,
const BenchmarkClustering &Clustering);
// Return the cluster centroid.
const SchedClassClusterCentroid &getCentroid() const { return Centroid; }
// Returns true if the cluster representative measurements match that of SC.
bool
measurementsMatch(const MCSubtargetInfo &STI, const ResolvedSchedClass &SC,
const BenchmarkClustering &Clustering,
const double AnalysisInconsistencyEpsilonSquared_) const;
private:
BenchmarkClustering::ClusterId ClusterId;
std::vector<size_t> PointIds;
// Measurement stats for the points in the SchedClassCluster.
SchedClassClusterCentroid Centroid;
};
void printInstructionRowCsv(size_t PointId, raw_ostream &OS) const;
void printClusterRawHtml(const BenchmarkClustering::ClusterId &Id,
StringRef display_name, raw_ostream &OS) const;
void printPointHtml(const Benchmark &Point, raw_ostream &OS) const;
void
printSchedClassClustersHtml(const std::vector<SchedClassCluster> &Clusters,
const ResolvedSchedClass &SC,
raw_ostream &OS) const;
void printSchedClassDescHtml(const ResolvedSchedClass &SC,
raw_ostream &OS) const;
// A pair of (Sched Class, indices of points that belong to the sched
// class).
struct ResolvedSchedClassAndPoints {
explicit ResolvedSchedClassAndPoints(ResolvedSchedClass &&RSC);
ResolvedSchedClass RSC;
std::vector<size_t> PointIds;
};
// Builds a list of ResolvedSchedClassAndPoints.
std::vector<ResolvedSchedClassAndPoints> makePointsPerSchedClass() const;
template <typename EscapeTag, EscapeTag Tag>
void writeSnippet(raw_ostream &OS, ArrayRef<uint8_t> Bytes,
const char *Separator) const;
const BenchmarkClustering &Clustering_;
const LLVMState &State_;
std::unique_ptr<DisassemblerHelper> DisasmHelper_;
const double AnalysisInconsistencyEpsilonSquared_;
const bool AnalysisDisplayUnstableOpcodes_;
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_CLUSTERING_H