Tau clang plugin: Difference between revisions

From OACISS Systems Wiki
Jump to navigation Jump to search
(Added misc issue/solution for building LLVM 7 on Aarch64 machines)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Use =
The aim of this plugin is to facilitate the use of TAU. Parsing a function-listing file, the TAU plugin runs a function pass on each function from the original source, adding them to be instrumented if the function-listing file specifies it.
= Compilation and installation =
= Compilation and installation =
As TAU relies on LLVM's Intermediate Representation, the TAU plugin is built upon an LLVM installation. That means an LLVM install is needed, as well as a TAU install.
Note: LLVM and the TAU plugin must be compiled using the same compilers.
== TAU installation ==
TAU installation is done by following these commands:
<code>
git clone https://github.com/UO-OACISS/tau2.git
cd tau2
./installtau -cc=clang -c++=clang++ -dwarf=download -bfd=download -iowrapper -iowrapper -otf=download
</code>
TAU records all configurations used to install it in the <code> .allconfigs </code> file. The last used configuration is stored in the <code> .lastconfig </code> file.
== LLVM installation ==
LLVM's installation can be done by following these commands:
<code>
git clone https://github.com/llvm/llvm-project.git
cd llvm-project/llvm
mkdir build; cd build
cmake ../../llvm -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../install  -DLLVM_ENABLE_PROJECTS="clang;mlir;polly;flang;libcxx;libcxxabi"
make -j install
</code>
<h4>Miscellaneous issues and solutions</h4>
* On x86 architectures, LLVM 8 needs the following lines to be added to <code> llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h </code> :
<code>
&#x23;include <cstdint>
&#x23;include <string>
</code>
* On PowerPC architectures, all LLVM versions prior to LLVM 9 (included) need to update the file <code>llvm-project/clang/lib/Lex/Lex.cpp</code> from <code>!vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes))</code> to <code> !vec_any_eq(*(const __vector unsigned char*)CurPtr, Slashes)) </code>
* On Aarch64 architectures, to build LLVM 7, it is needed to replace <code>&#x23;ifdef __FLT16_MANT_DIG__</code> by <code>&#x23;ifdef __STDC_WANT_IEC_60559_TYPES_EXT__</code> in the the following files:  <code>llvm-project/libcxx/include/type_traits</code> and <code>llvm-project/libcxx/test/libcxx/type_traits/is_floating_point.pass.cpp</code>
==  Plugin installation ==
With LLVM installed, the plugin can be built upon it:
<code>
git clone https://github.com/coti/tau-llvm-plugin.git
cd tau-llvm-plugin
mkdir build; cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install -DLLVM_ROOT=/PATH/TO/LLVM/INSTALLATION/install
make -j install
</code>


= Running it =
= Running it =
The TAU plugin is a function pass, meaning it takes effect during the compilation of the executable to be instrumented. To do so, the compiling command resembles this:
<code>
/PATH/TO/LLVM/INSTALLATION/install/bin/clang -fplugin=/PATH/TO/PLUGIN/INSTALLATION/install/lib/TAU_Profiling.so -mllvm -tau-input-file=/PATH/TO/FUNCTION/LISTING/FILE/select.tau -ldl -L/PATH/TO/TAU/lib/SPECIFIC_TAU_INSTALLATION -lTAU -Wl,-rpath,/PATH/TO/TAU/lib/SPECIFIC_TAU_INSTALLATION -lm [project files]
</code>
That being done, execute the code by calling:
<code>
tau_exec -T clang,serial ./a.out
</code>
Then, to access the instrumentation results, call:
<code>
pprof
</code>


= Packaging =
= Packaging =

Latest revision as of 00:31, 24 February 2021

Use

The aim of this plugin is to facilitate the use of TAU. Parsing a function-listing file, the TAU plugin runs a function pass on each function from the original source, adding them to be instrumented if the function-listing file specifies it.

Compilation and installation

As TAU relies on LLVM's Intermediate Representation, the TAU plugin is built upon an LLVM installation. That means an LLVM install is needed, as well as a TAU install.

Note: LLVM and the TAU plugin must be compiled using the same compilers.

TAU installation

TAU installation is done by following these commands:

git clone https://github.com/UO-OACISS/tau2.git

cd tau2

./installtau -cc=clang -c++=clang++ -dwarf=download -bfd=download -iowrapper -iowrapper -otf=download

TAU records all configurations used to install it in the .allconfigs file. The last used configuration is stored in the .lastconfig file.

LLVM installation

LLVM's installation can be done by following these commands:

git clone https://github.com/llvm/llvm-project.git

cd llvm-project/llvm

mkdir build; cd build

cmake ../../llvm -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/../install -DLLVM_ENABLE_PROJECTS="clang;mlir;polly;flang;libcxx;libcxxabi"

make -j install

Miscellaneous issues and solutions

  • On x86 architectures, LLVM 8 needs the following lines to be added to llvm-project/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h  :

#include <cstdint>

#include <string>

  • On PowerPC architectures, all LLVM versions prior to LLVM 9 (included) need to update the file llvm-project/clang/lib/Lex/Lex.cpp from !vec_any_eq(*(const vector unsigned char*)CurPtr, Slashes)) to !vec_any_eq(*(const __vector unsigned char*)CurPtr, Slashes))
  • On Aarch64 architectures, to build LLVM 7, it is needed to replace #ifdef __FLT16_MANT_DIG__ by #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ in the the following files: llvm-project/libcxx/include/type_traits and llvm-project/libcxx/test/libcxx/type_traits/is_floating_point.pass.cpp

Plugin installation

With LLVM installed, the plugin can be built upon it:

git clone https://github.com/coti/tau-llvm-plugin.git

cd tau-llvm-plugin

mkdir build; cd build

cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install -DLLVM_ROOT=/PATH/TO/LLVM/INSTALLATION/install

make -j install

Running it

The TAU plugin is a function pass, meaning it takes effect during the compilation of the executable to be instrumented. To do so, the compiling command resembles this:

/PATH/TO/LLVM/INSTALLATION/install/bin/clang -fplugin=/PATH/TO/PLUGIN/INSTALLATION/install/lib/TAU_Profiling.so -mllvm -tau-input-file=/PATH/TO/FUNCTION/LISTING/FILE/select.tau -ldl -L/PATH/TO/TAU/lib/SPECIFIC_TAU_INSTALLATION -lTAU -Wl,-rpath,/PATH/TO/TAU/lib/SPECIFIC_TAU_INSTALLATION -lm [project files]

That being done, execute the code by calling:

tau_exec -T clang,serial ./a.out

Then, to access the instrumentation results, call:

pprof

Packaging

Linux

Mac OS

brew install --build-from-source llvm