AN LLVM INSTRUMENTATION PLUG-IN FOR SCORE-P Performance: an old - - PowerPoint PPT Presentation

an llvm instrumentation plug in for score p performance
SMART_READER_LITE
LIVE PREVIEW

AN LLVM INSTRUMENTATION PLUG-IN FOR SCORE-P Performance: an old - - PowerPoint PPT Presentation

AN LLVM INSTRUMENTATION PLUG-IN FOR SCORE-P Performance: an old problem The most constant difficulty in contriving the engine has arisen from the desire to reduce Difference Engine the time in which the calculations were executed to the


slide-1
SLIDE 1

AN LLVM INSTRUMENTATION PLUG-IN FOR SCORE-P

slide-2
SLIDE 2

Performance: an old problem

An LLVM Instrumentation Plug-in for Score-P 2

“The most constant difficulty in contriving the engine has arisen from the desire to reduce the time in which the calculations were executed to the shortest which is possible.”

Charles Babbage 1791 – 1871

Difference Engine

November 13, 2017

slide-3
SLIDE 3
  • Monitoring infrastructures that capture performance relevant data

during application execution Performance Analysis

An LLVM Instrumentation Plug-in for Score-P 3 November 13, 2017

Monitor Application

slide-4
SLIDE 4

Agenda

An LLVM Instrumentation Plug-in for Score-P 4

  • Methodology
  • Implementation
  • Case Study
  • Conclusion

November 13, 2017

slide-5
SLIDE 5
  • Source code annotations (hooks)
  • Hooks invoke the monitor

Source Code Instrumentation Methodology

An LLVM Instrumentation Plug-in for Score-P 5 November 13, 2017

slide-6
SLIDE 6

Methodology

void func(int i) { if (i>0) { func(i-1); } } void func ( int i) { if (i>0) { func(i-1); } }

An LLVM Instrumentation Plug-in for Score-P 6

ENTER ("func"); EXIT ("func");

November 13, 2017

slide-7
SLIDE 7

Instrumentation techniques

  • Manual
  • Automatic
  • Compiler instrumentation (e.g., Clang option -finstrument-functions)
  • LLVM compiler pass

Methodology

An LLVM Instrumentation Plug-in for Score-P 7 November 13, 2017

slide-8
SLIDE 8

Requirements

  • Instrumentation of function enter and exit events
  • Independence from the programming language of the source code
  • Support of filtering options both at compile time and runtime
  • Support for user defined filter rules
  • Avoid interference with optimizations applied by the compiler
  • Internal handling of meta data
  • Exception-aware instrumentation

Methodology

An LLVM Instrumentation Plug-in for Score-P 8 November 13, 2017

slide-9
SLIDE 9
  • Implementation of a FunctionPass using

the LLVM Pass Framework

  • Invoked for each application function
  • Insert hooks into the LLVM

Intermediate Representation (IR)

  • Applying filtering techniques in order to

realize selective function instrumentation at compile-time Methodology

An LLVM Instrumentation Plug-in for Score-P 9

Portion of the LLVM IR relevant for this work

November 13, 2017

slide-10
SLIDE 10
  • LLVM pass implementation to ensure independence from the

programming language of the source code

  • Integration in the Score-P monitoring infrastructure

Implementation

An LLVM Instrumentation Plug-in for Score-P 10

Overview of the Score-P monitoring infrastructure and related analysis tools LLVM infrastructure overview

November 13, 2017

slide-11
SLIDE 11

Override virtual method runOnFunction(Function &F) which is called for each function in the processed IR

  • Collecting meta data
  • Deciding whether a function is instrumented
  • Default filtering rules
  • User defined filtering rule set
  • Adding calls to the monitoring infrastructure

Implementation

An LLVM Instrumentation Plug-in for Score-P 11 November 13, 2017

slide-12
SLIDE 12

FUNCTION : static uint32_t handle = INVALID_REGION ; if ( handle == INVALID_REGION ) register_region( &descr ); if ( handle != FILTERED_REGION ) enter_region( handle ); try { /* FUNCTION BODY */ } finally { if ( handle != FILTERED_REGION ) exit_region( handle ); } Implementation

An LLVM Instrumentation Plug-in for Score-P 12 November 13, 2017

slide-13
SLIDE 13

Instrumentation plug-in usage

  • Pass is built as a shared library
  • Compiler loads this shared library to enable instrumentation at

compile-time

  • LLVM pass registry manages registration and initialization of the pass

subsystem at compiler startup clang -Xclang –load -Xclang <instrumenation_pass_library.so>

  • c main.c

Implementation

An LLVM Instrumentation Plug-in for Score-P 13 November 13, 2017

slide-14
SLIDE 14

Comparison of event sequences

  • Instrumentation of a Jacobi solver application (MPI+OpenMP) with
  • Automatic compiler instrumentation
  • LLVM instrumentation plug-in

Case Study

An LLVM Instrumentation Plug-in for Score-P 14 November 13, 2017

slide-15
SLIDE 15

Case Study – Comparison of Event Sequences

An LLVM Instrumentation Plug-in for Score-P 15

Timeline visualization of the recorded event sequence in Vampir

November 13, 2017

Overview of all processes/ threads Call stack of an individual thread Detailed information about message transfer

slide-16
SLIDE 16
  • Number of user function invocations over all processing elements

Case Study – Comparison of Event Sequences

An LLVM Instrumentation Plug-in for Score-P 16

Number of user function invocations Optimization level Automatic compiler instrumentation Instrumentation via plug-in

  • O0

2014 2014

  • O1

2014 2014

  • O2

2014 2010

  • O3

2014 2008

November 13, 2017

slide-17
SLIDE 17

Case Study – Comparison of Event Sequences

An LLVM Instrumentation Plug-in for Score-P 17

Call stack visualization of the Jacobi application compiled with different optimization levels

November 13, 2017

Functions inlined in higher

  • ptimization

levels Functions inlined in higher

  • ptimization

levels

slide-18
SLIDE 18

Comparison of runtime overheads

  • Instrumentation of the miniFE application (OpenMP) with
  • Automatic compiler instrumentation
  • LLVM instrumentation plug-in

Case Study

An LLVM Instrumentation Plug-in for Score-P 18 November 13, 2017

slide-19
SLIDE 19

Experiment Runtime in seconds Uninstrumented 6 Automatic compiler instrumentation 800 Automatic compiler instrumentation, runtime filter 140 Instrumentation via plug-in 27 Instrumentation via plug-in, compile-time filter 7

Case Study - Comparison of Runtime Overheads

An LLVM Instrumentation Plug-in for Score-P 19

  • Runtime in seconds of the miniFE experiments
  • Each experiment was executed three times, the minimum of these

runs is shown

November 13, 2017

slide-20
SLIDE 20

Conclusion

An LLVM Instrumentation Plug-in for Score-P 20

  • LLVM plug-in supporting
  • Exception-aware instrumentation
  • Selective instrumentation of specific functions at compile-time
  • Runtime filtering
  • Feedback
  • Transferring additional information from the Front-End to the

Optimizer (source code location, demangled function names, mark internal functions)

November 13, 2017