hawk-utils-scripts/performance/extrae/share/trace_extrae.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

2023-08-01 11:59:43 +00:00
#!/bin/bash
# echo to rank 0 only
echo_rank0 () {
local msg=$1
# get rank from various MPI implementations
MPI_RANK=${MPI_RANK:=$PMI_RANK}
MPI_RANK=${MPI_RANK:=$PMIX_RANK}
MPI_RANK=${MPI_RANK:=$OMPI_COMM_WORLD_RANK}
MPI_RANK=${MPI_RANK:=$ALPS_APP_PE}
# test for rank 0
if [[ $MPI_RANK = 0 ]]; then
echo $msg
fi
# fallback if no rank at all, i.e. outside mpirun
if [[ $MPI_RANK = "" ]] ; then
echo $msg
fi
}
#default config file and tracing library
DEFAULT_CONFIG=$HLRS_EXTRAE_ROOT/../share/extrae_detail.xml
DEFAULT_LIB=$HLRS_EXTRAE_ROOT/lib/libmpitracecf.so
DEFAULT_NAME=$1"-"$(date +%Y-%m-%dT%H:%M:%S)
# set config file and tracing library
EXTRAE_CONFIG_FILE=${EXTRAE_CONFIG_FILE:-$DEFAULT_CONFIG}
EXTRAE_LIB=${EXTRAE_LIB:-$DEFAULT_LIB}
TRACE_NAME=${TRACE_NAME:-$DEFAULT_NAME}
echo_rank0 "### Extrae tracing"
echo_rank0 "# Config: $EXTRAE_CONFIG_FILE"
echo_rank0 "# Library: $EXTRAE_LIB"
echo_rank0 "# Trace: $TRACE_NAME"
export EXTRAE_CONFIG_FILE
# run application
env LD_PRELOAD=$EXTRAE_LIB $@
echo_rank0 "### Extrae tracing: "
echo_rank0 "# Execute the following command to merge traces:"
echo_rank0 "# mpi2prv -f TRACE.mpits -o $TRACE_NAME.prv"