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
93 lines
4.0 KiB
C++
93 lines
4.0 KiB
C++
//=-- MemProfSummary.cpp - MemProf summary support ---------------=//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains MemProf summary support.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ProfileData/MemProfSummary.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::memprof;
|
|
|
|
void MemProfSummary::printSummaryYaml(raw_ostream &OS) const {
|
|
// For now emit as YAML comments, since they aren't read on input.
|
|
OS << "---\n";
|
|
OS << "# MemProfSummary:\n";
|
|
OS << "# Total contexts: " << NumContexts << "\n";
|
|
OS << "# Total cold contexts: " << NumColdContexts << "\n";
|
|
OS << "# Total hot contexts: " << NumHotContexts << "\n";
|
|
OS << "# Maximum cold context total size: " << MaxColdTotalSize << "\n";
|
|
OS << "# Maximum warm context total size: " << MaxWarmTotalSize << "\n";
|
|
OS << "# Maximum hot context total size: " << MaxHotTotalSize << "\n";
|
|
if (HasDataAccessProfile) {
|
|
OS << "# Num hot symbols and string literals: "
|
|
<< NumHotSymbolsAndStringLiterals << "\n";
|
|
OS << "# Num known cold symbols: " << NumKnownColdSymbols << "\n";
|
|
OS << "# Num known cold string literals: " << NumKnownColdStringLiterals
|
|
<< "\n";
|
|
}
|
|
}
|
|
|
|
void MemProfSummary::write(ProfOStream &OS) const {
|
|
// Write the current number of fields first, which helps enable backwards and
|
|
// forwards compatibility (see comment in header).
|
|
OS.write32(memprof::MemProfSummary::getNumSummaryFields());
|
|
auto StartPos = OS.tell();
|
|
(void)StartPos;
|
|
OS.write(NumContexts);
|
|
OS.write(NumColdContexts);
|
|
OS.write(NumHotContexts);
|
|
OS.write(MaxColdTotalSize);
|
|
OS.write(MaxWarmTotalSize);
|
|
OS.write(MaxHotTotalSize);
|
|
// Sanity check that the number of fields was kept in sync with actual fields.
|
|
assert((OS.tell() - StartPos) / 8 == MemProfSummary::getNumSummaryFields());
|
|
}
|
|
|
|
std::unique_ptr<MemProfSummary>
|
|
MemProfSummary::deserialize(const unsigned char *&Ptr) {
|
|
auto NumSummaryFields =
|
|
support::endian::readNext<uint32_t, llvm::endianness::little>(Ptr);
|
|
// The initial version of the summary contains 6 fields. To support backwards
|
|
// compatibility with older profiles, if new summary fields are added (until a
|
|
// version bump) this code will need to check NumSummaryFields against the
|
|
// current value of MemProfSummary::getNumSummaryFields(). If NumSummaryFields
|
|
// is lower then default values will need to be filled in for the newer fields
|
|
// instead of trying to read them from the profile.
|
|
//
|
|
// For now, assert that the profile contains at least as many fields as
|
|
// expected by the code.
|
|
assert(NumSummaryFields >= MemProfSummary::getNumSummaryFields());
|
|
|
|
auto MemProfSum = std::make_unique<MemProfSummary>(
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr),
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr + 8),
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr + 16),
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr + 24),
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr + 32),
|
|
support::endian::read<uint64_t, llvm::endianness::little>(Ptr + 40));
|
|
|
|
// Enable forwards compatibility by skipping past any additional fields in the
|
|
// profile's summary.
|
|
Ptr += NumSummaryFields * sizeof(uint64_t);
|
|
|
|
return MemProfSum;
|
|
}
|
|
|
|
// FIXME: Consider to serialize the data access summary fields, ideally
|
|
// batch this together with more substantial profile format change
|
|
// and bump version once.
|
|
void MemProfSummary::buildDataAccessSummary(
|
|
const DataAccessProfData &DataAccessProfile) {
|
|
HasDataAccessProfile = true;
|
|
NumHotSymbolsAndStringLiterals = DataAccessProfile.getRecords().size();
|
|
NumKnownColdSymbols = DataAccessProfile.getKnownColdSymbols().size();
|
|
NumKnownColdStringLiterals = DataAccessProfile.getKnownColdHashes().size();
|
|
}
|