|
|
|
# Code profilers
|
|
|
|
|
|
|
|
In this Wiki, we will provide a methodology to install and run some code profilers. This has been tested on a specific
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
### Download:
|
|
|
|
|
|
|
|
- Score-P: https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/scorep-8.4/scorep-8.4.tar.gz
|
|
|
|
- Tau: http://tau.uoregon.edu/tau.tgz
|
|
|
|
- PDT: http://tau.uoregon.edu/pdt.tgz
|
|
|
|
- PAPI: https://icl.utk.edu/projects/papi/downloads/papi-7.2.0b2.tar.gz
|
|
|
|
|
|
|
|
### 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
|
|
|
|
```
|
|
|
|
|
|
|
|
Activate the environment:
|
|
|
|
|
|
|
|
```
|
|
|
|
conda activate profilers
|
|
|
|
```
|
|
|
|
|
|
|
|
Next, create some environment variables that will be used all along the compilation process:
|
|
|
|
|
|
|
|
```
|
|
|
|
export PROFILER_PATH=/home/BARRIER/Softwares/profilers/install
|
|
|
|
export CC=gcc
|
|
|
|
export FC=gfortran
|
|
|
|
export CXX=g++
|
|
|
|
export MPICC=mpicc
|
|
|
|
export MPICXX=mpic++
|
|
|
|
export MPIFORT=mpifort
|
|
|
|
export FCFLAGS="-ffree-form"
|
|
|
|
export PAPI_INC=$PROFILER_PATH/include
|
|
|
|
export PAPI_LIB=$PROFILER_PATH/lib
|
|
|
|
export LD_LIBRARY_PATH=$PROFILER_PATH/lib:$LD_LIBRARY_PATH
|
|
|
|
export PATH=$PROFILER_PATH/bin:$PATH
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation PDT
|
|
|
|
|
|
|
|
In the PDT folder, type:
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure -prefix=$PROFILER_PATH
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
**Warning: there is only one `-` before prefix!**
|
|
|
|
|
|
|
|
### Compilation PAPI
|
|
|
|
|
|
|
|
In the PAPI folder, type:
|
|
|
|
|
|
|
|
```
|
|
|
|
cd src
|
|
|
|
./configure --prefix=$PROFILER_PATH
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation Score-P
|
|
|
|
|
|
|
|
In 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 --with-pdt=$PROFILER_PATH/x86_64/bin/
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
### Compilation TAU
|
|
|
|
|
|
|
|
In the TAU folder, activate the `profilers` environment and type
|
|
|
|
|
|
|
|
```
|
|
|
|
./configure -prefix=$PROFILER_PATH/ -papi=$PROFILER_PATH/ -pdt=$PROFILER_PATH/ -mpi -c++=g++ -cc=gcc -fortran=gfortran
|
|
|
|
make install
|
|
|
|
```
|
|
|
|
|
|
|
|
**Warning**: In TAU, each set of compile options generate a specific Makefile. In the above, the generated Makefile will include PAPI, PDT, Score-P and MPI. To compile a non-MPI program, re-compile TAU without the `-mpi` option
|
|
|
|
|
|
|
|
**Important**: The `-scorep` options does not work due to a failure of shared library building of Score-P
|
|
|
|
|
|
|
|
## Profile
|
|
|
|
|
|
|
|
### Profile with TAU
|
|
|
|
|
|
|
|
To profile with TAU, first define the proper Makefile to use and eventually additional tau options:
|
|
|
|
|
|
|
|
```
|
|
|
|
export TAU_MAKEFILE=$PROFILER_PATH/x86_64/lib/Makefile.tau-papi-pdt
|
|
|
|
export TAU_OPTIONS='-optKeepFiles -optVerbose -optTauSelectFile="select.tau"'
|
|
|
|
```
|
|
|
|
|
|
|
|
In the above, the `-optKeepFiles` allows to keep intermediate files. The `-optTauSelectFile` specifies the file where additional profiling options are provided. These options are provided in a `select.tau` file, which may be as follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
BEGIN_INSTRUMENT_SECTION
|
|
|
|
loops routine="#"
|
|
|
|
END_INSTRUMENT_SECTION
|
|
|
|
```
|
|
|
|
|
|
|
|
Here, we specify that loops will be instrumented in all the functions of the program.
|
|
|
|
|
|
|
|
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`
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
```
|
|
|
|
tau_cxx.sh test_cpp.cpp -o test.exe
|
|
|
|
```
|
|
|
|
|
|
|
|
Next, execute your code as follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
./test.exe
|
|
|
|
```
|
|
|
|
|
|
|
|
A `profile.0.0.0` file containing the profile informations will appear.
|
|
|
|
|
|
|
|
The profile file can be opened by using the `paraprof` function:
|
|
|
|
|
|
|
|
```
|
|
|
|
paraprof profile.0.0.0 &
|
|
|
|
```
|
|
|
|
|
|
|
|
### Profile with Score-P
|
|
|
|
|
|
|
|
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`
|
|
|
|
|
|
|
|
For example
|
|
|
|
|
|
|
|
```
|
|
|
|
scorep-g++ test_cpp.cpp -o test.exe
|
|
|
|
```
|
|
|
|
|
|
|
|
The next step is to run your code:
|
|
|
|
|
|
|
|
```
|
|
|
|
./test.exe`
|
|
|
|
|
|
|
|
A `scorep-` folder will appear containing all the profiling informations. It can be opened by using the `paraprof` tool as follows:
|
|
|
|
|
|
|
|
```
|
|
|
|
paraprof paraprof scorep-20250310_1624_81500554863145/profile.cubex &
|
|
|
|
``` |
|
|
\ No newline at end of file |