File: simd-dispatch

package info (click to toggle)
examl 3.0.22-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,180 kB
  • sloc: ansic: 27,326; makefile: 74; sh: 48
file content (33 lines) | stat: -rwxr-xr-x 945 bytes parent folder | download
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
#!/bin/sh

EXAMLDIR=/usr/lib/examl/bin
EXE=${EXAMLDIR}/$(basename "$0")
NPROC=$(nproc)

if echo "$@" | grep -q -- -np ; then
  NP=$(echo "$@" | sed 's/^.* *-np *\([0-9]\+\) *.*/\1/')
  echo "Run MPI on $NP processors as requested"
  CMDARGS=$(echo "$@" | sed 's/\(^.* *\)-np *[0-9]\+\( *.*\)/\1\2/')
else
  NP=$((NPROC/2)) # leave 50% processors for other jobs - if you want to force more just use -np option
  if [ $NP -le 0 ] ; then
    NP=1
  fi
  echo "Run MPI on $NP of $NPROC available processors"
  CMDARGS="$@"
fi

test_and_run () {
        if grep -q "$1" /proc/cpuinfo && [ -x "${EXE}-$1" ]; then
		echo "Use ${EXE}-$1 and $NP processors"
                mpirun -np "$NP" "${EXE}-$1" ${CMDARGS}
                exit
        fi
}


for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 sse mmx ; do test_and_run ${SIMD} ; done

# fallback to plain option
echo "Use $EXE without SIMD support and $NP processors"
mpirun -np "$NP" "${EXE}" $CMDARGS