-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockervars.sh
69 lines (66 loc) · 3.18 KB
/
dockervars.sh
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
#/bin/sh
#
# Load some alias to compile and run with the docker mpicc/mpif90/mpirun
#
# No posix portable way to find if script is sourced;
# use some uglyness found on stackoverflow to handle bash, zsh, ksh...
sourced=0
if [ -n "$ZSH_EVAL_CONTEXT" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac
elif [ -n "$KSH_VERSION" ]; then
[ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ] && sourced=1
else # All other shells: examine $0 for known shell binary filenames
# Detects `sh` and `dash`; add additional shell filenames as needed.
case ${0##*/} in bash|sh|dash) sourced=1;; esac
fi
if [ 0 -eq $sourced ]; then
echo "# This file needs to be sourced, not executed."
echo " source dockervars.sh load"
exit 2
fi
ulfm_image=abouteiller/mpi-ft-ulfm
case _$1 in
_|_load)
docker pull $ulfm_image
function make {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox $ulfm_image make $@
}
function ompi_info {
docker run --user $(id -u):$(id -g) --cap-drop=all $ulfm_image ompi_info $@
}
function mpirun {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox $ulfm_image mpirun --map-by :oversubscribe --mca btl tcp,self $@
}
function mpiexec {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox $ulfm_image mpiexec --map-by :oversubscribe --mca btl tcp,self $@
}
function mpiexec+gdb {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox --cap-add=SYS_PTRACE --security-opt seccomp=unconfined $ulfm_image mpiexec --map-by :oversubscribe --mca btl tcp,self $@
}
function mpicc {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox $ulfm_image mpicc $@
}
function mpif90 {
docker run --user $(id -u):$(id -g) --cap-drop=all --security-opt label:disabled -v $PWD:/sandbox $ulfm_image mpif90 $@
}
echo "# Function alias set for 'make', 'mpirun', 'mpiexec', 'mpicc', 'mpif90'."
echo "source dockervars.sh unload # remove these aliases."
echo "# These commands now run from the ULFM Docker image."
echo "# Use \`mpiexec --with-ft ulfm\` to turn ON fault tolerance."
mpirun --version
;;
_unload)
unset -f make
unset -f ompi_info
unset -f mpirun
unset -f mpiexec
unset -f mpicc
unset -f mpif90
echo "# Function alias unset for 'make', 'mpirun', 'mpiexec', 'mpicc', 'mpif90'."
;;
*)
echo "# This script is designed to load aliases for for 'make', 'mpirun', 'mpiexec', 'mpicc', 'mpif90'."
echo "# After this script is sourced in your local shell, these commands would run from the ULFM Docker image."
echo "source dockervars.sh load # alias make, mpirun, etc. in the current shell"
echo "source dockervars.sh unload # remove aliases from the current shell"
esac