|
|
|
---
|
|
|
|
title: Profilage de Code
|
|
|
|
---
|
|
|
|
|
|
|
|
# Code profilers
|
|
|
|
|
|
|
|
In this Wiki, we will provide a methodology to install and run some code profilers. This has been tested on a specific Conda environment.
|
|
|
|
|
|
|
|
The tools that were tested are proposed:
|
|
|
|
|
|
|
|
- [Score-P](https://www.vi-hps.org/projects/score-p/)
|
|
|
|
- [TAU](https://www.cs.uoregon.edu/research/tau/home.php), which allows the profiling of `for` loops
|
|
|
|
- [Scalasca](https://www.scalasca.org/)
|
|
|
|
- [Salt](https://github.com/ParaToolsInc/salt)
|
|
|
|
- [Score-P](https://www.vi-hps.org/projects/score-p/)
|
|
|
|
- [TAU](https://www.cs.uoregon.edu/research/tau/home.php), which allows the profiling of `for` loops
|
|
|
|
- [Scalasca](https://www.scalasca.org/)
|
|
|
|
|
|
|
|
In order to be able to profile `for` loops, the [Salt](https://github.com/ParaToolsInc/salt) source instrumentation tool must be installed.
|
|
|
|
|
|
|
|
## Preparing the install
|
|
|
|
|
|
|
|
### Download:
|
|
|
|
|
|
|
|
- Salt: `git clone --recursive https://github.com/ParaToolsInc/salt.git`
|
|
|
|
- Score-P: https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/scorep-8.4/scorep-8.4.tar.gz
|
|
|
|
- Tau: `git clone https://github.com/UO-OACISS/tau2`
|
|
|
|
- Scalasca: https://apps.fz-juelich.de/scalasca/releases/scalasca/2.6/dist/scalasca-2.6.1.tar.gz
|
|
|
|
- Salt: `git clone --recursive https://github.com/ParaToolsInc/salt.git`
|
|
|
|
- Score-P: [https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/scorep-8.4/scorep-8.4.tar.gz](https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/scorep-8.4/scorep-8.4.tar.gz)
|
|
|
|
- Tau: `gh repo clone barriern/tau2`
|
|
|
|
- Scalasca: [https://apps.fz-juelich.de/scalasca/releases/scalasca/2.6/dist/scalasca-2.6.1.tar.gz](https://apps.fz-juelich.de/scalasca/releases/scalasca/2.6/dist/scalasca-2.6.1.tar.gz)
|
|
|
|
|
|
|
|
### Conda Environment
|
|
|
|
|
|
|
|
Create the Conda environment as follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
mamba create --name profilers python=3.10 sphinx mpich-mpifort mpich-mpicc mpich-mpicxx netcdf4 six c-compiler compilers cxx-compiler clangdev llvmdev cmake
|
|
|
|
mamba create --name profilers python=3.10 sphinx mpich-mpifort=3 mpich-mpicc=3 mpich-mpicxx=3 netcdf4 six c-compiler compilers cxx-compiler clangdev flang llvmdev cmake
|
|
|
|
```
|
|
|
|
|
|
|
|
Activate the environment:
|
| ... | ... | @@ -39,22 +36,30 @@ conda activate profilers |
|
|
|
Go to the `$CONDA_PREFIX/lib` folder and type:
|
|
|
|
|
|
|
|
```
|
|
|
|
mv libbfd.a save-libbfd.a
|
|
|
|
mkdir save
|
|
|
|
mv libbfd.a libsframe.a save
|
|
|
|
```
|
|
|
|
|
|
|
|
**This trick allows to avoid the use of the Conda `BFD` library and will force the use of the Score-P BFD library**
|
|
|
|
**This trick allows to avoid the use of the Conda `BFD` library and will force the use of the Score-P and Tau BFD downloaded libraries**
|
|
|
|
|
|
|
|
### Environment variables
|
|
|
|
## Compilation
|
|
|
|
|
|
|
|
Next, create an environment variable that provides the install path where profiling libraries and binaries will be stored:
|
|
|
|
### Compilation Score-P
|
|
|
|
|
|
|
|
```
|
|
|
|
export PROFILER_PATH=/home/BARRIER/Softwares/profilers/install
|
|
|
|
```
|
|
|
|
Compilation of Score-P only works with GNU compilers.
|
|
|
|
|
|
|
|
Next, create some environment variables that will be used all along the compilation process:
|
|
|
|
We will therefore need to define some environment variables:
|
|
|
|
|
|
|
|
```
|
|
|
|
# Install folder for Score-P
|
|
|
|
export PROFILER_PATH=/home/BARRIER/Softwares/profilers/install-scorep
|
|
|
|
|
|
|
|
# Change the compiler in MPICH wrappers:
|
|
|
|
export MPICH_CXX=g++
|
|
|
|
export MPICH_CC=gcc
|
|
|
|
export MPICH_FC=gfortran
|
|
|
|
|
|
|
|
# Define compiler variables
|
|
|
|
export CC=gcc
|
|
|
|
export FC=gfortran
|
|
|
|
export F77=gfortran
|
| ... | ... | @@ -63,56 +68,72 @@ export MPICC=mpicc |
|
|
|
export MPICXX=mpic++
|
|
|
|
export MPIFORT=mpifort
|
|
|
|
export FCFLAGS="-ffree-form"
|
|
|
|
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$PROFILER_PATH/lib
|
|
|
|
|
|
|
|
# Define library path and path
|
|
|
|
export LD_LIBRARY_PATH=$PROFILER_PATH/lib:$CONDA_PREFIX/lib
|
|
|
|
export PATH=$PROFILER_PATH/bin:$PATH
|
|
|
|
export PATH=$PROFILER_PATH/x86_64/bin/:$PATH
|
|
|
|
```
|
|
|
|
|
|
|
|
## Compilation
|
|
|
|
When the variables are defined, go the Score-P folder, activate the `profilers` environment and type:
|
|
|
|
|
|
|
|
### Compilation Salt
|
|
|
|
```
|
|
|
|
./configure --prefix=$PROFILER_PATH --without-shmem --with-libbfd=download --with-libunwind=download
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation Tau/Salt
|
|
|
|
|
|
|
|
Type the following:
|
|
|
|
To allow for source instrumentation using Tau, we need to use the clang compilers. Therefore, we will need do define some variables:
|
|
|
|
|
|
|
|
```
|
|
|
|
# Install folder for Tau
|
|
|
|
export PROFILER_PATH=/home/BARRIER/Softwares/profilers/install-tau
|
|
|
|
|
|
|
|
# Change the compiler in MPICH wrappers:
|
|
|
|
export MPICH_CXX=clang++
|
|
|
|
export MPICH_CC=clang
|
|
|
|
export MPICH_FC=gfortran
|
|
|
|
|
|
|
|
# Define compiler variables
|
|
|
|
export CC=clang
|
|
|
|
export FC=flang-new
|
|
|
|
export F77=flang-new
|
|
|
|
export CXX=clang++
|
|
|
|
# configure SALT and generate build system
|
|
|
|
cmake -Wdev -Wdeprecated -S . -B $PROFILER_PATH
|
|
|
|
cmake --build $PROFILER_PATH --parallel # Add --verbose to debug something going wrong
|
|
|
|
```
|
|
|
|
export MPICC=mpicc
|
|
|
|
export MPICXX=mpic++
|
|
|
|
export MPIFORT=mpifort
|
|
|
|
export FCFLAGS="-ffree-form"
|
|
|
|
|
|
|
|
### Compilation PDT
|
|
|
|
# Define library path and path
|
|
|
|
export LD_LIBRARY_PATH=$PROFILER_PATH/lib:$CONDA_PREFIX/lib
|
|
|
|
export PATH=$PROFILER_PATH/bin:$PATH
|
|
|
|
export PATH=$PROFILER_PATH/x86_64/bin/:$PATH
|
|
|
|
```
|
|
|
|
|
|
|
|
Go the PDT folder type:
|
|
|
|
When the variables are defined, go to the Tau folder and type:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure -prefix=$PROFILER_PATH
|
|
|
|
make
|
|
|
|
./configure -prefix=$PROFILER_PATH/ -c++=clang++ -cc=clang -fortran=flang-new -bfd=download -unwind=download
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation Score-P
|
|
|
|
|
|
|
|
Go the Score-P folder, activate the `profilers` environment and type:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure --prefix=$PROFILER_PATH --with-mpi=mpich4 --without-shmem --with-libbfd=download --with-libunwind=download --enable-shared
|
|
|
|
make
|
|
|
|
./configure -prefix=$PROFILER_PATH/ -c++=clang++ -cc=clang -fortran=flang-new -bfd=download -unwind=download -mpi
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation TAU
|
|
|
|
> **CAUTION** In TAU, each set of compile options generate a specific Makefile that will be used for the profiling. In the above, the generated Makefile will include PDT, Score-P and MPI. To compile a non-MPI program, re-compile TAU without the `-mpi` option
|
|
|
|
|
|
|
|
### Compilation Salt
|
|
|
|
|
|
|
|
In the TAU folder, activate the `profilers` environment and type
|
|
|
|
In order to install the Salt source instrumentation tool, go to the Salt folder and type the following:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure -prefix=$PROFILER_PATH/ -pdt=$PROFILER_PATH/ -scorep=$PROFILER_PATH -mpi -c++=g++ -cc=gcc -fortran=gfortran -bfd=$PROFILER_PATH/vendor/libbfd -unwind=$PROFILER_PATH/vendor/libunwind
|
|
|
|
make install
|
|
|
|
# configure SALT and generate build system
|
|
|
|
cmake -Wdev -Wdeprecated -S . -B $PROFILER_PATH -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
|
|
|
|
cmake --build $PROFILER_PATH --parallel # Add --verbose to debug something going wrong
|
|
|
|
```
|
|
|
|
|
|
|
|
> **CAUTION** In TAU, each set of compile options generate a specific Makefile that will be used for the profiling. In the above, the generated Makefile will include PDT, Score-P and MPI. To compile a non-MPI program, re-compile TAU without the `-mpi` option
|
|
|
|
|
|
|
|
### Compilation Scalasca
|
|
|
|
|
|
|
|
Go to your Scalasca folder and type:
|
| ... | ... | @@ -151,7 +172,7 @@ In the above, the `-optKeepFiles` allows to keep intermediate files. The `-optTa |
|
|
|
BEGIN_EXCLUDE_LIST
|
|
|
|
|
|
|
|
void quicksort(int *, int, int)
|
|
|
|
# The next line excludes all functions beginning with "sort_" and having
|
|
|
|
# The next line excludes all functions beginning with "sort_" and having
|
|
|
|
# arguments "int *"
|
|
|
|
void sort_#(int *)
|
|
|
|
void interchange(int *, int *)
|
| ... | ... | @@ -188,10 +209,10 @@ Here, we specify that loops will be instrumented in all the functions of the pro |
|
|
|
|
|
|
|
Now, to compile the program, replace the standard compile commands as follows:
|
|
|
|
|
|
|
|
- `gcc` -\> `tau_cc.sh`
|
|
|
|
- `g++` -\> `tau_cxx.sh`
|
|
|
|
- `gfortran` -\> `tau_f90.sh`
|
|
|
|
- `f77` -\> `tau_f70.sh`
|
|
|
|
- `gcc` -\> `tau_cc.sh`
|
|
|
|
- `g++` -\> `tau_cxx.sh`
|
|
|
|
- `gfortran` -\> `tau_f90.sh`
|
|
|
|
- `f77` -\> `tau_f70.sh`
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
| ... | ... | @@ -217,13 +238,13 @@ paraprof scorep-20250310_1624_81500554863145/profile.cubex & |
|
|
|
|
|
|
|
To allow profiling with Score-P, replace the standard compile commands as follows:
|
|
|
|
|
|
|
|
- `g++` -\> `scorep g++`
|
|
|
|
- `gfortran` -\> `scorep gfortran`
|
|
|
|
- `mpicxx` -\> `scorep mpicxx`
|
|
|
|
- `mpif90` -\> `scorep mpif90`
|
|
|
|
- `gcc` -\> `scorep gcc`
|
|
|
|
- `mpicc` -\> `scorep mpicc`
|
|
|
|
- `mpif77` -\> `scorep mpif77`
|
|
|
|
- `g++` -\> `scorep g++`
|
|
|
|
- `gfortran` -\> `scorep gfortran`
|
|
|
|
- `mpicxx` -\> `scorep mpicxx`
|
|
|
|
- `mpif90` -\> `scorep mpif90`
|
|
|
|
- `gcc` -\> `scorep gcc`
|
|
|
|
- `mpicc` -\> `scorep mpicc`
|
|
|
|
- `mpif77` -\> `scorep mpif77`
|
|
|
|
|
|
|
|
For example
|
|
|
|
|
| ... | ... | @@ -273,13 +294,13 @@ paraprof scorep-20250310_1624_81500554863145/profile.cubex & |
|
|
|
|
|
|
|
To profile a code with Scalasca, you need to compile the code by replacing:
|
|
|
|
|
|
|
|
- `g++` -\> `skin g++`
|
|
|
|
- `gfortran` -\> `skin gfortran`
|
|
|
|
- `mpicxx` -\> `skin mpicxx`
|
|
|
|
- `mpif90` -\> `skin mpif90`
|
|
|
|
- `gcc` -\> `skin gcc`
|
|
|
|
- `mpicc` -\> `skin mpicc`
|
|
|
|
- `mpif77` -\> `skin mpif77`
|
|
|
|
- `g++` -\> `skin g++`
|
|
|
|
- `gfortran` -\> `skin gfortran`
|
|
|
|
- `mpicxx` -\> `skin mpicxx`
|
|
|
|
- `mpif90` -\> `skin mpif90`
|
|
|
|
- `gcc` -\> `skin gcc`
|
|
|
|
- `mpicc` -\> `skin mpicc`
|
|
|
|
- `mpif77` -\> `skin mpif77`
|
|
|
|
|
|
|
|
Once your code has been compiled, you can execute it as follows:
|
|
|
|
|
| ... | ... | @@ -293,9 +314,9 @@ scan test.exe |
|
|
|
scan -t test.exe
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Resources:
|
|
|
|
|
|
|
|
- https://hpc.cea.fr/tgcc-public/en/html/toc/fulldoc/Profiling.html#
|
|
|
|
- https://www.vi-hps.org/projects/score-p/ |
|
|
\ No newline at end of file |
|
|
|
- https://hpc.cea.fr/tgcc-public/en/html/toc/fulldoc/Profiling.html#
|
|
|
|
- https://www.vi-hps.org/projects/score-p/ |
|
|
\ No newline at end of file |