遇见Google Abseil开源项目(三):bazel方式编译btree benchmark、mutex benchmark 和 hashtable

  1. 自动编译Abseil的btree benchmark 和 mutex benchmark,和编译hashtable源码
  2. 使用clang/llvm 编译器: CC=clang-9 BAZEL_COMPILER=llvm
  3. 添加如下编译参数:bazel build --cxxopt=-std=c++17 -c opt --cxxopt='-O3' --cxxopt='-fPIE' --cxxopt='-mpie-copy-relocations' --cxxopt='-fno-omit-frame-pointer' --cxxopt='-fno-strict-aliasing'
#!/bin/bash
sudo apt-get install clang-9
sudo apt-get install libboost-all-dev
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
sudo apt-get install libboost-all-dev
HOME_DIR=/home/yjiang2
TESTCASE_SRC_HOME=${HOME_DIR}/src
ABSL_HOME=${TESTCASE_SRC_HOME}/abseil-cpp
BAZEL_HOME=${TESTCASE_SRC_HOME}/bazel-3.0.0-dist

#
#1st thing is first, install bazel
#
ARCH=`uname -p`
BAZEL_BIN=${HOME_DIR}/bin/bazel
if [ ! -f ${BAZEL_BIN} ]; then
    if [[ "$ARCH" == "aarch64" ]];then
        #TX2
        wget -P ${TESTCASE_SRC_HOME} -c http://distfiles.macports.org/bazel/bazel-3.0.0-dist.zip
        unzip ${TESTCASE_SRC_HOME}/bazel-3.0.0-dist.zip -d ${BAZEL_HOME}
        cd ${BAZEL_HOME} && bash ./compile.sh
        source ${HOME_DIR}/.profile
    elif [[ "$ARCH" == "x86_64" ]]; then
        #Skylake 6148 or Rome
        wget -c https://github.com/bazelbuild/bazel/releases/download/3.0.0/bazel-3.0.0-installer-linux-x86_64.sh
        chmod +x bazel-3.0.0-installer-linux-x86_64.sh
       ./bazel-3.0.0-installer-linux-x86_64.sh --user
    fi
fi

ABSL_SCRIPT=${HOME_DIR}/bin/absl-run-multiple-config-of-socket-final-envset.sh
if [ ! -f ${ABSL_SCRIPT} ]; then
    echo "##############Downloading bin.tar.gz ...##############"
    sudo apt-get install  sshpass
    if [[ "$ARCH" == "aarch64" ]];then
        #Download running script bin/
        sshpass -p "yjiang2" scp yjiang2@saber-06:${HOME_DIR}/bin-TX2-0525.tar.gz  ${HOME_DIR}/
        tar xzf ${HOME_DIR}/bin-TX2-0525.tar.gz -C ${HOME_DIR}/
    elif [[ "$ARCH" == "x86_64" ]]; then
        #Download running script bin/
        sshpass -p yjiang2 scp yjiang2@sm6148-2s-02:${HOME_DIR}/bin-Skylake-0525.tar.gz  ${HOME_DIR}/
        tar xzf ${HOME_DIR}/bin-Skylake-0525.tar.gz -C ${HOME_DIR}/
    fi
    if [ -f ${ABSL_SCRIPT} ]; then
        echo "Completed for ${ARCH}"
    else
        echo "Not completed for ${ARCH} !!!"
    fi
    
fi


#
#Download source code of Abseil and compile it
#
if [ ! -d ${ABSL_HOME} ]; then
    git clone https://github.com/abseil/abseil-cpp ${ABSL_HOME}
else
    echo "Abseil has been installed on this platform !!!"
fi

HASHTABLE_BENCHMARK_HOME=${TESTCASE_SRC_HOME}/hashtable-benchmarks
if [ ! -d ${HASHTABLE_BENCHMARK_HOME} ]; then
    git clone https://github.com/google/hashtable-benchmarks ${HASHTABLE_BENCHMARK_HOME}
else
    echo "hashtable-benchmarks has been installed on this platform !!!"
fi

ABSL_MUTEX_BENCHMARK=${ABSL_HOME}/bazel-bin/absl/synchronization/mutex_benchmark
if [ ! -f ${ABSL_HOME} ]; then
    #build
    cd ${ABSL_HOME} && sudo CC=clang-9 BAZEL_COMPILER=llvm bazel build --cxxopt=-std=c++17 -c opt --cxxopt='-O3' --cxxopt='-fPIE' --cxxopt='-mpie-copy-relocations' --cxxopt='-fno-omit-frame-pointer' --cxxopt='-fno-strict-aliasing' //absl/synchronization:mutex_benchmark
fi

ABSL_BTREE_BENCHMARK=${ABSL_HOME}/bazel-bin/absl/container/btree_benchmark
if [ ! -f ${ABSL_BTREE_BENCHMARK} ]; then
    #build btree-benchmark
    cd ${ABSL_HOME} && sudo CC=clang-9 BAZEL_COMPILER=llvm bazel build --cxxopt='-std=c++17' -c opt --cxxopt='-O3' --cxxopt='-fPIE' --cxxopt='-mpie-copy-relocations' --cxxopt='-fno-omit-frame-pointer' --cxxopt='-fno-strict-aliasing' //absl/container:btree_benchmark
fi

HASHTABLE_BENCHMARK=${HASHTABLE_BENCHMARK_HOME}/bazel-bin/hashtable_benchmarks
if [ ! -f ${HASHTABLE_BENCHMARK} ]; then
    #build hashtable-benchmarks
    cd ${HASHTABLE_BENCHMARK_HOME} && sudo CC=clang-9 BAZEL_COMPILER=llvm bazel build --cxxopt='-std=c++17' -c opt --cxxopt='-O3' --cxxopt='-fPIE' --cxxopt='-mpie-copy-relocations' --cxxopt='-fno-omit-frame-pointer' --cxxopt='-fno-strict-aliasing' :hashtable_benchmarks
fi

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值