Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makefile: check sse4.2 for tikv targets (#4314)
* Makefile: check sse4.2 for tikv targets Signed-off-by: Neil Shen <overvenus@gmail.com>
- Loading branch information
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |