Skip to content

Profiler

Tommy McMichen edited this page Aug 26, 2022 · 3 revisions

Profiling code with NOELLE

NOELLE provides an easy to use wrapper for LLVM's profiler. The result is a bitcode with metadata embedded in it that NOELLE's hot profiler can read to provide dynamic profiling information in the middle-end.

Generating Profile

You can generate and embed the profile metadata with NOELLE's tools.

noelle-prof-coverage program.bc binary_to_profile
./binary_to_profile <program inputs>
noelle-meta-prof-embed default.profraw program.bc –o program_with_profile.bc

Fetching Profile

You can fetch the profiles through NOELLE's HotProfiler abstraction.

// Fetching NOELLE
llvm::noelle::Noelle &noelle  = getAnalysis<Noelle>();
llvm::noelle::Hot *hot = noelle.getProfiles();

// You can check that the profiles are available
hot->isAvailable();

Profiles

The profile provides information on the number of times X is executed, where X is an instruction, loop, function, basic block, or SCC. It also can provide information on how often a branch is taken. There are three ways to reference the profiles:

  • Static is the number of static instructions that compose X (e.g. the number of instructions in a basic block).
    • uint64_t value = hot->getStaticInstructions(&X);
  • Self is the number of dynamic instructions executed within X for the execution of the whole program, this does not count the instructions executed by callees.
    • uint64_t value = hot->getSelfInstructions(&X);
  • Total is the number of dynamic instructions executed within X for the execution of the whole program, this does count the instructions executed by callees.
    • uint64_t value = hot->getTotalInstructions(&X);
  • Invocations is the number of times X is invoked (i.e. called function, loop entered, etc.).
    • uint64_t value = hot->getInvocations(&X);

Coverage

NOELLE also provides coverage information at various granularities. The coverage, as defined by NOELLE, is the percentage of time that the program spends in X as a proportion of the total dynamic instructions the executed in the whole program.

double coverage = hot->getDynamicTotalInstructionCoverage(&X);

Loop Specific Profiles

NOELLE provides loop specific APIs to accelerate loop-centric analysis and transformations.

  • Average Total Instructions per Invocation provides the average number of instructions the loop runs per invocation.
    • double value = hot->getAverageTotalInstructionsPerInvocation(loop);
  • Average Loop Iterations per Invocation provides the average number of iterations the loop takes per invocation.
    • double value = hot->getAverageLoopIterationsPerInvocation(loop);
  • Average Total Instructions per Iteration provides the average number of instructions executed in each iteration of the loop.
    • double value = hot->getAverageTotalInstructionsPerIteration(loop);
  • Sort by Hotness sorts a list of Loops by their hotness (i.e. coverage).
    • noelle.sortByHotness(loops);
Clone this wiki locally