Skip to content

Commit ee21c9a

Browse files
committed
Adding wrapper to select the correct bwa-mem2 pre-compiled binary for Intel and Zen4 AMD processors
1 parent 1a8a20b commit ee21c9a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# About: this script is a wrapper around bwa-mem2
4+
# that selects the correct Intel compiled binary
5+
# based on the CPU architecture of the host machine.
6+
# This is necessary because the Intel compiled binary
7+
# AVX-512 binary is NOT compatible with Zen4 AMD CPUs.
8+
# AVX-512 support was added in Zen4 and is not present
9+
# in Zen3. On Biowulf, the new AMD nodes are Zen4. If
10+
# a AMD node is detected, this script will use the
11+
# an AVX2 compiled binary instead, if left to bwa-mem2
12+
# it will select the axv-512bw binary and error out.
13+
# The difference in performance is minimal between
14+
# AVX-512 vs. AVX2 (may be around 20-30% faster), so
15+
# it's not a big deal to use the AVX2 binary on Zen4.
16+
17+
set -euo pipefail
18+
19+
# Functions
20+
function err() { cat <<< "$@" 1>&2; }
21+
function fatal() { cat <<< "$@" 1>&2; exit 1; }
22+
23+
# Select the best binary for Intel
24+
# versus AMD CPUs
25+
if grep -q GenuineIntel /proc/cpuinfo ; then
26+
# Let bwa-mem2 select the best
27+
# precompiled binary for Intel
28+
bwa-mem2 "$@"
29+
elif grep -q AuthenticAMD /proc/cpuinfo ; then
30+
# Use the AVX2 compiled binary,
31+
# this ensure compatibility with
32+
# Zen3 and Zen4 AMD CPUs.
33+
bwa-mem2.avx2 "$@"
34+
else
35+
err "Fatal error: failed to resolve CPU architecture, neither Intel nor AMD detected."
36+
err " ├── Are you trying to run bwa-mem2 on a non-x86 CPU (ARM-based) cpu?"
37+
fatal " └── Only Intel and AMD CPUs are supported, exiting now!"
38+
fi

0 commit comments

Comments
 (0)