Giter VIP home page Giter VIP logo

geraldofojunior / llvm-loop-profiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iith-compilers/llvm-loop-profiler

0.0 0.0 0.0 61.66 MB

License: Other

Shell 0.05% JavaScript 0.02% C++ 70.27% Python 0.79% Perl 0.06% C 9.02% PHP 0.01% Emacs Lisp 0.01% Objective-C 2.88% OCaml 0.16% Fortran 0.01% Go 0.07% C# 0.01% Assembly 16.60% MATLAB 0.03% Rust 0.01% AppleScript 0.01% Forth 0.01% Logos 0.01% M 0.01%

llvm-loop-profiler's Introduction

LLVM-Loop-Profiler

LLVM Loop profiler works for LLVM-IR, which gives loop-based run-time information mainly execution time and iteration count for each individual loop of the input program.

image

Getting started

Install LLVM from source. We are using LLVM 7.0, not tested on the other versions.

  • git clone https://github.com/shalinijain58/LLVM-Loop-Profiler.git loop-profiler
  • mkdir build && cd build
  • cmake -DCMAKE_BUILD_TYPE=Release ../loop-profiler
  • make

Either do make install after make or export the path of llvm binaries.

How to run?

Once make is successful, execute loop profiler in build directory to run the code. For example, loop-profiler/ProfilerTestCases/1loop.cpp

  • ./bin/clang++ -S -g -emit-llvm ../loop-profiler/ProfilerTestCases/1loop.cpp -o ../loop-profiler/ProfilerTestCases/1loop.ll
  • ./bin/opt -load ./lib/LLVMLoopTimer.so -count-loops -insertstr -inserttimer -profile-loop=inner ../loop-profiler/ProfilerTestCases/1loop.ll | ./bin/llc -filetype=obj -o ../loop-profiler/ProfilerTestCases/1loop.o
  • ./bin/clang++ ../loop-profiler/ProfilerTestCases/1loop.o -o ../loop-profiler/ProfilerTestCases/1loop.out
  • ./../loop-profiler/ProfilerTestCases/1loop.out

First command: Converts .cpp file to .ll (LLVM-IR) through clang++. You can use clang for .c files.

Second command: Opt loads LLVMLoopTimer.so and then applies the profiler flags count-loops, insertstr and inserttimer. All these flags are mandatory and should in the same order. This transformation annotates loop in the IR with timers. Using llc we make object file.

We can choose to profile inner, outer or all loops by setting the flag profile-loop, which is optional and it defaults to all. You can apply other optimization flags as well based on requirement.

  • inner: This calculates profiling information for only inner-most loops.
  • outer: This calculates profiling information for only outer-most loops (loop-nest).
  • all: This calculates profiling information for all loops.

Third command: Converts object file to executable.

Fourth command: Runs the profiled version and produces run-time information along with program output.

88

Test Cases

Few sample test cases are provided in the directory ProfilerTestCases.

Profile Output

After execution it prints profiling information (for each of the loops based on the flag) just after the program output. There will be a line printed for each loop in the given format:

[loop-id] [source file location] [line no] [number of times loop executed] [total clock cycles]

  • [loop-id]: Unique id given to each profiled loop, starts from 0, goes till n-1.
  • [source file location]: Prints location of the source file. Useful for figuring out the original file in case of IR is made by linking multiple source files.
  • [line no]: Prints line number of the loop in the original source file.
  • [number of times loop executed]: The total number of times entire loop executed, it is not the iteration count of the loop.
  • [total clock cycles]: The total number of clock cycles a loop is taking during the execution of the whole program.

SPEC-CPU-2006:

hmmer and namd respectively

povray and xalancbmk respectively

SPEC-CPU-2017:

imagick and omnetpp respectively

partest and xalancbmk respectively

Contributers: Shalini Jain, Pankaj Kukreja, Kamlesh Bhalui

llvm-loop-profiler's People

Contributors

shalinijain58 avatar proton0001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.