#!/bin/bash
#SBATCH --job-name=vtune_run_mpi    # Arbitrary name of Slurm job
#SBATCH --output=%x.%j.out          # Standard job output file
#SBATCH --error=%x.%j.err           # Standard job error file
#SBATCH --ntasks=4                  # Number of requested MPI processes
# /!\ Caution: In Slurm vocabulary, "multithread" (in following line) refers to hyperthreading.
#SBATCH --hint=nomultithread    # 1 MPI process per physical core (no hyperthreading)
#SBATCH --time=0:20:00              # Job time hh:mm:ss (0h20mn here)

## Choice of Intel environment having VTune
module load intel-all/19.0.4

## Echo of commands
set -x

## Execution in the SCRATCH
cd $SCRATCH

# Selection of a different directory at each run
export DIR_PROF=profiling.$SLURM_NTASKS.$SLURM_JOB_ID

# To not use the /tmp
export TMPDIR=$SCRATCH

## Hotspot type sampling of the ./my_bin_exe binary with 
## writing results in the $WORKDIR/$DIR_PROF directory
## and limiting the quantity of collected data (here 4000 MB)
srun amplxe-cl -q -collect hotspots -r $DIR_PROF -data-limit=4000 -- ./my_bin_exe