| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
PKG=plink2 |
| 4 |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 5 |
basename=$(basename "$0") |
| 6 |
BASE=$(realpath "${DIR}/../lib/$PKG/${basename}") |
| 7 |
|
| 8 |
function test_and_run () { |
| 9 |
if grep -q "$1" /proc/cpuinfo && [ -x "${BASE}-$1" ]; then |
| 10 |
cmd="${BASE}-$1" |
| 11 |
shift |
| 12 |
"${cmd}" "$@" |
| 13 |
exit |
| 14 |
fi |
| 15 |
} |
| 16 |
|
| 17 |
function test_and_run_avx2 () { |
| 18 |
if cat /proc/cpuinfo \ |
| 19 |
| grep avx2 \ |
| 20 |
| grep bmi \ |
| 21 |
| grep bmi2 \ |
| 22 |
| grep abm \ |
| 23 |
| grep fma \ |
| 24 |
> /dev/null \ |
| 25 |
&& [ -x "${BASE}-avx2" ]; then |
| 26 |
cmd="${BASE}-avx2" |
| 27 |
"${cmd}" "$@" |
| 28 |
exit |
| 29 |
fi |
| 30 |
} |
| 31 |
|
| 32 |
test_and_run_avx2 "$@" |
| 33 |
|
| 34 |
for SIMD in avx sse4.1 ssse3 sse3 sse2 sse mmx ; do test_and_run ${SIMD} "$@" ; done |
| 35 |
|
| 36 |
# fallback to plain option |
| 37 |
set -x |
| 38 |
"$BASE-plain" "$@" |