-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
check-sse4_2.sh
executable file
·59 lines (48 loc) · 1.73 KB
/
check-sse4_2.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
#!/bin/bash
#
# This script makes sure that the tikv-server executables in the target
# directory enables intel® sse4.2 extensions. It is suitable to run as part of
# CI.
dirs="./target/debug ./target/release"
errors=0
# These need to check sse4.2.
targets="tikv-server tikv-importer"
if [[ "`uname`" != "Linux" ]]; then
echo "skipping sse4.2 check - not on Linux"
exit 0
fi
echo "checking bins for sse4.2"
for dir in $dirs; do
for file in $targets; do
dirfile="$dir/$file"
if [[ -x "$dirfile" && ! -d "$dirfile" ]]; then
echo "checking binary $dirfile for sse4.2"
# RocksDB uses sse4.2 in the `Fast_CRC32` function
fast_crc32=$(nm "$dirfile" | grep -o " _.*Fast_CRC32.*")
if [[ ! $fast_crc32 ]]; then
echo "error: $dirfile does not contain rocksdb::crc32c::Fast_CRC32 function"
errors=1
continue
fi
# Make sure the `Fast_CRC32` uses the sse4.2 instruction `crc32`
# f2.*0f 38 is the opcode of `crc32`, see Intel® SSE4 Programming Reference
found=0
for sym in $fast_crc32; do
echo $sym
if [[ `gdb -batch -ex "disass/r $sym" $dirfile 2> /dev/null | grep ">:.*f2.*0f 38.*crc32"` ]]; then
found=1
break
fi
done
if [[ "$found" -ne 1 ]]; then
echo "error: $dirfile does not enable sse4.2"
errors=1
fi
fi
done
done
if [[ "$errors" -ne 0 ]]; then
echo "some binaries do not enable sse4.2"
echo "fix this by building tikv with ROCKSDB_SYS_SSE=1"
exit 1
fi