-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmympi
executable file
·91 lines (80 loc) · 2.82 KB
/
mympi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# This scripts creates mpi_amdados.cpp file on the fly and compiles
# pure MPI version of Amdados application. Recall, we cannot create
# permanent *.cpp files for MPI version to avoid any interference
# with CMake building framework. Options:
# -d : debugging mode; -r : release mode; -l : launch applications
# after building.
# Blank lines.
for i in {1..5}; do echo ""; done
# Make build directory.
mkdir -p build
# Remove the old executable.
/bin/rm -f build/mpi_amdados
# Build Allscale version of Amdados application, if does not exist.
if [ ! -f build/app/amdados ]; then
bash ./standard.build.sh
fi
# Generate cpp file containing main() function.
CWD=$(pwd)
cat > build/mpi_amdados.cpp << EOF
#include "${CWD}/code/app/mpi_src/mpi_simulation.h"
int main(int argc, char ** argv) {
return mpi_main(&argc, &argv);
}
EOF
# By default we choose debugging mode and do not run the application.
LAUNCH=false
DEBUG=false;
# Parse the input arguments.
while getopts ":drl" opt; do
case $opt in
d) DEBUG=true ;;
r) DEBUG=false ;;
l) LAUNCH=true ;;
\?) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done
# Set up the mode-dependent settings.
if ${DEBUG} ; then
echo "Compiling (and running) the application in 'debug' mode"
CONF="-g3 -O0 -DDEBUG -D_DEBUG"
else
echo "Compiling (and running) the application in 'release' mode"
CONF="-O2 -DNDEBUG"
fi
# Compile.
mpicxx -DAMDADOS_PLAIN_MPI -std=c++14 -Wall -pedantic -Wextra -Wconversion \
${CONF} -o build/mpi_amdados build/mpi_amdados.cpp
# Run.
if ${LAUNCH} ; then
if [[ $(uname) == "Linux" ]]; then
# I have "mpich" on Linux blade, and mpich tolerates overcommit.
NUMPROC=$(getconf _NPROCESSORS_ONLN)
elif [[ $(uname) == "Darwin" ]]; then
# I have "open-mpi" on Mac OS, and open-mpi wants to know the exact
# number of cores (not processors!) - overcommit is not tolerated.
NUMPROC=$(system_profiler SPHardwareDataType | \
grep 'Total Number of Cores' | awk '{print $5}')
fi
if ${DEBUG} ; then
if [[ $(uname) == "Linux" ]]; then
# I have "mpich" on Linux blade.
mpirun -np ${NUMPROC} -f host_file xterm -e gdb build/mpi_amdados
elif [[ $(uname) == "Darwin" ]]; then
# I have "open-mpi" on Mac OS.
mpirun -np ${NUMPROC} --hostfile host_file \
xterm -e /usr/bin/lldb build/mpi_amdados
fi
else
if [[ $(uname) == "Linux" ]]; then
# I have "mpich" on Linux blade.
mpirun -np ${NUMPROC} -f host_file build/mpi_amdados
elif [[ $(uname) == "Darwin" ]]; then
# I have "open-mpi" on Mac OS.
mpirun -np ${NUMPROC} --hostfile host_file build/mpi_amdados
fi
fi
fi
# Blank lines.
for i in {1..3}; do echo ""; done