From 5683282c94537a07ff7d77a1a7b030f43d77bf3c Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 18 Jun 2019 08:24:41 -0700 Subject: [PATCH] Update to solana-perf-libs v0.14.0, with support for both CUDA 10.0 and 10.1 --- build-perf-libs.sh | 23 ---------------- ci/test-stable.sh | 6 ++--- core/build.rs | 19 +++++++++++--- fetch-perf-libs.sh | 65 ++++++++++++++++++++++++++++++++-------------- 4 files changed, 63 insertions(+), 50 deletions(-) delete mode 100755 build-perf-libs.sh diff --git a/build-perf-libs.sh b/build-perf-libs.sh deleted file mode 100755 index aee74dc27..000000000 --- a/build-perf-libs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# -# Builds perf-libs from the upstream source and installs them into the correct -# location in the tree -# -set -e -cd "$(dirname "$0")" - -if [[ -d target/perf-libs ]]; then - echo "target/perf-libs/ already exists, to continue run:" - echo "$ rm -rf target/perf-libs" - exit 1 -fi - -( - set -x - git clone git@github.com:solana-labs/solana-perf-libs.git target/perf-libs - cd target/perf-libs - make -j"$(nproc)" - make DESTDIR=. install -) - -./fetch-perf-libs.sh diff --git a/ci/test-stable.sh b/ci/test-stable.sh index eaf4e11e6..a3f780485 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -60,9 +60,7 @@ test-stable-perf) # Run root package tests with these features ROOT_FEATURES= - if [[ $(uname) = Darwin ]]; then - ./build-perf-libs.sh - else + if [[ $(uname) = Linux ]]; then # Enable persistence mode to keep the CUDA kernel driver loaded, avoiding a # lengthy and unexpected delay the first time CUDA is involved when the driver # is not yet loaded. @@ -72,7 +70,7 @@ test-stable-perf) ./fetch-perf-libs.sh # shellcheck source=/dev/null source ./target/perf-libs/env.sh - ROOT_FEATURES=$ROOT_FEATURES,cuda + ROOT_FEATURES=cuda fi # Run root package library tests diff --git a/core/build.rs b/core/build.rs index 2245d7838..433063dcd 100644 --- a/core/build.rs +++ b/core/build.rs @@ -12,7 +12,12 @@ fn main() { let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let mut path = Path::new(&manifest_dir); path = path.parent().unwrap(); - path.join(Path::new("target/perf-libs")) + let mut path = path.join(Path::new("target/perf-libs")); + path.push( + env::var("SOLANA_PERF_LIBS_CUDA") + .unwrap_or_else(|err| panic!("SOLANA_PERF_LIBS_CUDA not defined: {}", err)), + ); + path }; let perf_libs_dir = perf_libs_dir.to_str().unwrap(); @@ -26,8 +31,16 @@ fn main() { }); println!("cargo:rerun-if-changed={}", perf_libs_dir); println!("cargo:rustc-link-search=native={}", perf_libs_dir); - println!("cargo:rerun-if-changed={}/libcuda-crypt.a", perf_libs_dir); - println!("cargo:rustc-link-lib=static=cuda-crypt"); + if cfg!(windows) { + println!("cargo:rerun-if-changed={}/libcuda-crypt.dll", perf_libs_dir); + } else if cfg!(target_os = "macos") { + println!( + "cargo:rerun-if-changed={}/libcuda-crypt.dylib", + perf_libs_dir + ); + } else { + println!("cargo:rerun-if-changed={}/libcuda-crypt.so", perf_libs_dir); + } let cuda_home = match env::var("CUDA_HOME") { Ok(cuda_home) => cuda_home, diff --git a/fetch-perf-libs.sh b/fetch-perf-libs.sh index c28d2cd67..10d8234ea 100755 --- a/fetch-perf-libs.sh +++ b/fetch-perf-libs.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PERF_LIBS_VERSION=v0.13.2 +PERF_LIBS_VERSION=v0.14.0 set -e cd "$(dirname "$0")" @@ -20,37 +20,39 @@ if [[ ! -f target/perf-libs/.$PERF_LIBS_VERSION ]]; then ( set -x cd target/perf-libs - curl https://solana-perf.s3.amazonaws.com/$PERF_LIBS_VERSION/x86_64-unknown-linux-gnu/solana-perf.tgz | tar zxvf - + curl -L --retry 5 --retry-delay 2 --retry-connrefused -o solana-perf.tgz \ + https://github.com/solana-labs/solana-perf-libs/releases/download/$PERF_LIBS_VERSION/solana-perf.tgz + tar zxvf solana-perf.tgz + rm -f solana-perf.tgz touch .$PERF_LIBS_VERSION ) fi -cat > target/perf-libs/env.sh <<'EOF' + +write_env() { + rm -f target/perf-libs/env.sh + cat >> target/perf-libs/env.sh <> target/perf-libs/env.sh <<'EOF' SOLANA_PERF_LIBS="$(cd $(dirname "${BASH_SOURCE[0]}"); pwd)" echo "solana-perf-libs version: $(cat $SOLANA_PERF_LIBS/solana-perf-HEAD.txt)" - -if [[ -r "$SOLANA_PERF_LIBS"/solana-perf-CUDA_HOME.txt ]]; then - CUDA_HOME=$(cat "$SOLANA_PERF_LIBS"/solana-perf-CUDA_HOME.txt) -else - CUDA_HOME=/usr/local/cuda -fi - echo CUDA_HOME="$CUDA_HOME" -export CUDA_HOME="$CUDA_HOME" -echo LD_LIBRARY_PATH="$SOLANA_PERF_LIBS:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" -export LD_LIBRARY_PATH="$SOLANA_PERF_LIBS:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" +echo LD_LIBRARY_PATH="$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH="$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" -echo PATH="$SOLANA_PERF_LIBS:$CUDA_HOME/bin:$PATH" -export PATH="$SOLANA_PERF_LIBS:$CUDA_HOME/bin:$PATH" +echo PATH="$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA:$CUDA_HOME/bin:$PATH" +export PATH="$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA:$CUDA_HOME/bin:$PATH" -if [[ -r "$CUDA_HOME"/version.txt && -r $SOLANA_PERF_LIBS/cuda-version.txt ]]; then - if ! diff "$CUDA_HOME"/version.txt "$SOLANA_PERF_LIBS"/cuda-version.txt > /dev/null; then +if [[ -r "$CUDA_HOME"/version.txt && -r $SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA/cuda-version.txt ]]; then + if ! diff "$CUDA_HOME"/version.txt "$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA"/cuda-version.txt > /dev/null; then echo ============================================== echo "Warning: possible CUDA version mismatch with $CUDA_HOME" echo - echo "Expected version: $(cat "$SOLANA_PERF_LIBS"/cuda-version.txt)" + echo "Expected version: $(cat "$SOLANA_PERF_LIBS/$SOLANA_PERF_LIBS_CUDA"/cuda-version.txt)" echo "Detected version: $(cat "$CUDA_HOME"/version.txt)" echo ============================================== fi @@ -60,7 +62,30 @@ else echo ============================================== fi EOF + echo + echo "source $PWD/target/perf-libs/env.sh to setup environment" + exit 0 +} + + +for cuda in $(cd target/perf-libs; find . -maxdepth 1 -type d -regex './cuda-.*' | sort -r); do + cuda=$(basename "$cuda") + CUDA_HOME=/usr/local/$cuda + SOLANA_PERF_LIBS_CUDA=$cuda + [[ -d $CUDA_HOME ]] || { + echo "$cuda not detected: $CUDA_HOME directory does not exist" + continue + } + [[ -r $CUDA_HOME/version.txt ]] || { + echo "$cuda not detected: $CUDA_HOME/version.txt does not exist" + continue + } + echo + cat "$CUDA_HOME/version.txt" + echo "CUDA_HOME=$CUDA_HOME" + write_env +done echo -echo "source $PWD/target/perf-libs/env.sh to setup environment" -exit 0 +echo No supported CUDA versions detected +exit 1