Skip to content

Commit ebf3918

Browse files
committed
Added benchmark_suite miniapp demonstrating anomalies in an openMP threaded region
Added openmp build of Tau to ubuntu-18.04 Dockerfile
1 parent a209a49 commit ebf3918

6 files changed

Lines changed: 256 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
main: main.C
2+
tau_cxx.sh main.C -o main -g -fopenmp
3+
main_notau: main.C
4+
mpic++ main.C -o main -g -fopenmp
5+
clean:
6+
rm main
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#Note: This configuration file is sourced into the bash environment for Chimbuko startup scripts, thus the user must follow correct shell conventions
2+
#Please do not remove any of the variables!
3+
4+
#IMPORTANT NOTE: Variables that cannot be left as default are marked as <------------ ***SET ME***
5+
6+
service_node_iface=eth0 #network interface upon which communication to the service node is performed <------------ ***SET ME***
7+
8+
####################################
9+
#Options for visualization module
10+
####################################
11+
use_viz=0 #enable or disable the visualization
12+
viz_root=/opt/chimbuko/viz #the root directory of the visualization module <------------ ***SET ME (if using viz)***
13+
viz_worker_port=6379 #the port on which to run the redis server for the visualization backend
14+
viz_port=5002 #the port on which to run the webserver
15+
export C_FORCE_ROOT=1 #required only for docker runs, allows celery to execute properly as root user <----------------- *** SET ME (if using Docker)
16+
17+
############################################################
18+
#General options for Chimbuko backend (pserver, ad, provdb)
19+
############################################################
20+
backend_root="infer" #The root install directory of the PerformanceAnalysis libraries. If set to "infer" it will be inferred from the path of the executables
21+
chimbuko_services="infer" #The location of the Chimbuko service script. If set to "infer" it will be inferred from backend_root
22+
23+
####################################
24+
#Options for the provenance database
25+
####################################
26+
use_provdb=1 #enable or disable the provDB. If disabled the provenance data will be written as JSON ASCII into the ${provdb_writedir} set below
27+
provdb_extra_args="" #any extra command line arguments to pass
28+
provdb_nshards=4 #number of database shards
29+
provdb_engine="ofi+tcp;ofi_rxm" #the OFI libfabric provider used for the Mochi stack
30+
provdb_port=5000 #the port of the provenance database
31+
provdb_nthreads=4 #number of worker threads; should be >= the number of shards
32+
provdb_writedir=chimbuko/provdb #the directory in which the provenance database is written. Chimbuko creates chimbuko/provdb which can be used as a default
33+
provdb_commit_freq=10000 #frequency ms at which the provenance database is committed to disk. If set to 0 it will commit only at the end
34+
35+
#With "verbs" provider (used for infiniband, iWarp, etc) we need to also specify the domain, which can be found by running fi_info (on a compute node)
36+
provdb_domain=mlx5_0 #only needed for verbs provider <------------ ***SET ME (if using verbs)***
37+
38+
39+
####################################
40+
#Options for the parameter server
41+
####################################
42+
use_pserver=1 #enable or disable the pserver
43+
pserver_extra_args="" #any extra command line arguments to pass
44+
pserver_port=5559 #port for parameter server
45+
pserver_nt=2 #number of worker threads
46+
####################################
47+
#Options for the AD module
48+
####################################
49+
ad_extra_args="-perf_outputpath chimbuko/logs -perf_step 1" #any extra command line arguments to pass. Note: chimbuko/logs is automatically created by services script
50+
ad_win_size=5 #number of events around an anomaly to store; provDB entry size is proportional to this so keep it small!
51+
ad_alg="hbos" #the anomaly detection algorithm. Valid values are "hbos" and "sstd"
52+
ad_outlier_hbos_threshold=0.99 #the percentile of events outside of which are considered anomalies by the HBOS algorithm
53+
ad_outlier_sstd_sigma=12 #number of standard deviations that defines an outlier in the SSTD algorithm
54+
####################################
55+
#Options for TAU
56+
#Note: Only the TAU_ADIOS2_PATH, TAU_ADIOS2_FILE_PREFIX, EXE_NAME and TAU_ADIOS2_ENGINE variables are used by the Chimbuko services script and there only to generate the suggested
57+
# command to launch the AD (output to chimbuko/vars/chimbuko_ad_cmdline.var); they can be overridden by the run script if desired providing the appropriate modifications
58+
# are made to the AD launch command. The remainder of the variables are used only by TAU and can be freely overridden.
59+
####################################
60+
export TAU_ADIOS2_ENGINE=SST #online communication engine (alternative BP4 although this goes through the disk system and may be slower unless the BPfiles are stored on a burst disk)
61+
export TAU_ADIOS2_ONE_FILE=FALSE #a different connection file for each rank
62+
export TAU_ADIOS2_PERIODIC=1 #enable/disable ADIOS2 periodic output
63+
export TAU_ADIOS2_PERIOD=1000000 #period in us between ADIOS2 io steps
64+
export TAU_THREAD_PER_GPU_STREAM=1 #force GPU streams to appear as different TAU virtual threads
65+
export TAU_THROTTLE=0 #enable/disable throttling of short-running functions
66+
67+
export TAU_MAKEFILE=/opt/tau2/x86_64/lib/Makefile.tau-papi-mpi-pthread-pdt-openmp-adios2 #The TAU makefile to use <------------ ***SET ME***
68+
69+
#Note: the following 2 variables are not used by the service script but are included here for use from the user's run script allowing the application to be launched with either "${TAU_EXEC} <app>" or "${TAU_PYTHON} <app>"
70+
#Note: the "binding" -T ... is used by Tau to find the appropriate configuration. It can typically be inferred from the name of the Makefile. If using a non-MPI job the 'mpi' should be changed to 'serial' and a non-MPI build of
71+
# ADIOS2/TAU must exist
72+
#Suggestion: It is useful to test the command without Chimbuko first to ensure TAU picks up the correct binding; this can be done by 'export TAU_ADIOS2_ENGINE=BPFile' and then running the application with Tau but without Chimbuko.
73+
TAU_EXEC="tau_exec -T papi,mpi,pthread,pdt,openmp,adios2 -adios2_trace" #how to execute tau_exec; the -T arguments should mirror the makefile name <------------ ***SET ME***
74+
TAU_PYTHON="tau_python -T papi,mpi,pthread,pdt,adios2 -tau-python-interpreter=python3 -adios2_trace -tau-python-args=-u" #how to execute tau_python. Note that passing -u to python forces it to not buffer stdout so we can pipe it
75+
#to tee in realtime <--- SET ME (if !python3)
76+
77+
export EXE_NAME=main #the name of the executable (without path) <------------ ***SET ME***
78+
79+
TAU_ADIOS2_PATH=chimbuko/adios2 #path where the adios2 files are to be stored. Chimbuko services creates the directory chimbuko/adios2 in the working directory and this should be used by default
80+
TAU_ADIOS2_FILE_PREFIX=tau-metrics #the prefix of tau adios2 files; full filename is ${TAU_ADIOS2_PREFIX}-${EXE_NAME}-${RANK}.bp
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
###########################################################################
95+
# NON-USER VARIABLES BELOW = DON'T MODIFY THESE!!
96+
###########################################################################
97+
#Extra processing
98+
export TAU_ADIOS2_FILENAME="${TAU_ADIOS2_PATH}/${TAU_ADIOS2_FILE_PREFIX}"
99+
100+
if [[ ${backend_root} == "infer" ]]; then
101+
backend_root=$( readlink -f $(which provdb_admin | sed 's/provdb_admin//')/../ )
102+
fi
103+
104+
if [[ ${chimbuko_services} == "infer" ]]; then
105+
chimbuko_services="${backend_root}/scripts/launch/run_services.sh"
106+
if [ ! -f "${chimbuko_services}" ]; then
107+
echo "Could not infer service script location: service script does not exist at ${chimbuko_services}!"
108+
exit 1
109+
fi
110+
fi
111+

benchmark_suite/openmp_cpu/main.C

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//In this example a function is executed with a chosen number of distinct modes in a random pattern, and anomalies are inserted as points far away from these modes
2+
#include<chrono>
3+
#include<thread>
4+
#include<iostream>
5+
#include<sstream>
6+
#include<random>
7+
#include<mpi.h>
8+
#include<omp.h>
9+
#include <sys/select.h>
10+
11+
template<typename T>
12+
T strToAny(const std::string &s){
13+
T out;
14+
std::stringstream ss; ss << s; ss >> out;
15+
if(ss.fail()) throw std::runtime_error("Failed to parse \"" + s + "\"");
16+
return out;
17+
}
18+
19+
void sleep_100ms(){
20+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
21+
}
22+
23+
void the_function(const int sleep_ms){
24+
int nsleep = sleep_ms / 100;
25+
26+
for(int i=0;i<nsleep;i++)
27+
sleep_100ms();
28+
}
29+
30+
int main(int argc, char **argv){
31+
if(argc < 6){
32+
std::cout << "Usage: <binary> <ncycles> <mode times (comma separated)> <anom time> <anom freq> <threads>" << std::endl;
33+
std::cout << "Times are in *milliseconds* and will be rounded to the nearest 100ms" << std::endl;
34+
exit(0);
35+
}
36+
37+
MPI_Init(&argc, &argv);
38+
39+
int cycles = strToAny<int>(argv[1]);
40+
41+
std::stringstream ss;
42+
ss << argv[2];
43+
44+
std::cout << "Mode times: ";
45+
std::vector<int> mode_times;
46+
while(ss.good()) {
47+
std::string substr;
48+
getline(ss, substr, ','); //get first string delimited by comma
49+
mode_times.push_back(strToAny<int>(substr));
50+
std::cout << mode_times.back() << " ";
51+
}
52+
std::cout << std::endl;
53+
54+
int anom_time = strToAny<int>(argv[3]);
55+
int anom_freq = strToAny<int>(argv[4]);
56+
int threads = strToAny<int>(argv[5]);
57+
58+
//Round the times
59+
anom_time = ( (anom_time + 50) / 100 ) * 100;
60+
std::cout << "Anom time rounded to " << anom_time << " ms" << std::endl;
61+
for(int i=0;i<mode_times.size();i++){
62+
mode_times[i] = ( (mode_times[i] + 50) / 100 ) * 100;
63+
std::cout << "Mode " << i << " time rounded to " << mode_times[i] << " ms" << std::endl;
64+
}
65+
66+
67+
omp_set_num_threads(threads);
68+
69+
#pragma omp parallel
70+
{
71+
int me = omp_get_thread_num();
72+
73+
std::mt19937 gen(me*1234);
74+
std::uniform_int_distribution<> dist(0, mode_times.size()-1);
75+
76+
for(int i=0;i<cycles;i++){
77+
int time;
78+
if(i > 0 && i % anom_freq == 0) time = anom_time;
79+
else{
80+
int mode = dist(gen);
81+
time = mode_times[mode];
82+
}
83+
std::cout << "Thread " << me << " cycle " << i << " " << time << std::endl;
84+
the_function(time);
85+
}
86+
87+
}
88+
89+
MPI_Finalize();
90+
}

benchmark_suite/openmp_cpu/run.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -e
3+
4+
############## USER VARIABLES ####################
5+
ranks=1 #number of MPI ranks
6+
cycles=100 #number of loops in main program
7+
anom_freq=30 #how many loop cycles beween anomalies
8+
modetimes="200,500" #function execution times in ms for "normal executions" (each cycle randomly chosen over modes)
9+
anom_time=10000 #function execution time in ms for anomalous execution
10+
threads=3
11+
############## END OF USER VARIABLES #################
12+
13+
rm -rf chimbuko
14+
export CHIMBUKO_CONFIG=chimbuko_config.sh
15+
source ${CHIMBUKO_CONFIG}
16+
17+
if (( 1 )); then
18+
echo "Running services"
19+
${chimbuko_services} 2>&1 | tee services.log &
20+
echo "Waiting"
21+
while [ ! -f chimbuko/vars/chimbuko_ad_cmdline.var ]; do sleep 1; done
22+
ad_cmd=$(cat chimbuko/vars/chimbuko_ad_cmdline.var)
23+
fi
24+
25+
if (( 1 )); then
26+
echo "Instantiating AD"
27+
eval "mpirun --allow-run-as-root -n ${ranks} ${ad_cmd} &"
28+
sleep 2
29+
fi
30+
31+
#Run the main program
32+
if (( 1 )); then
33+
mkdir -p chimbuko/adios2 chimbuko/logs
34+
echo "Running main"
35+
mpirun --allow-run-as-root -n ${ranks} ${TAU_EXEC} ./main ${cycles} ${modetimes} ${anom_time} ${anom_freq} ${threads} 2>&1 | tee main.log
36+
fi
37+
38+
wait

docker/ubuntu18.04/openmpi4.0.4/Dockerfile.tau2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ WORKDIR /Downloads
3636
RUN echo "FORCE REDOWNLOAD 10_30_20_16_39" > /dev/null && git clone https://github.com/UO-OACISS/tau2.git
3737
WORKDIR /Downloads/tau2
3838

39+
#Use known working version of tau2
40+
RUN git checkout 6756ea1e2790dc83580f0e437a443a29039798fc
41+
3942
#pthread+mpi
4043
RUN ./configure -cc=mpicc -c++=mpic++ -fortran=gfortran -mpi \
4144
-pthread -bfd=download -unwind=download -pdt=/opt/pdt \
@@ -59,6 +62,13 @@ RUN ./configure -cc=gcc -c++=g++ -fortran=gfortran \
5962
-papi=/opt/papi \
6063
&& make -j$JOBS install
6164

65+
#openmp+mpi
66+
RUN ./configure -cc=mpicc -c++=mpic++ -fortran=gfortran -mpi \
67+
-openmp -bfd=download -unwind=download -pdt=/opt/pdt \
68+
-pdt_c++=g++ -prefix=/opt/tau2 -adios=/opt/adios2 \
69+
-papi=/opt/papi \
70+
&& make -j$JOBS install
71+
6272
RUN git log | head -1 > /opt/tau2/git_version
6373

6474
FROM chimbuko/adios2:ubuntu18.04

include/chimbuko/util/PerfStats.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <map>
77
#include "chimbuko/util/RunMetric.hpp"
88
#endif
9+
#include<string>
910

1011
namespace chimbuko{
1112

0 commit comments

Comments
 (0)