Skip to content

Commit

Permalink
Merge pull request #363 from Chia-Network/develop
Browse files Browse the repository at this point in the history
Bring compressed plotting/farming into master
  • Loading branch information
wallentx authored Aug 4, 2023
2 parents c669876 + 1952440 commit 02a8e68
Show file tree
Hide file tree
Showing 283 changed files with 85,291 additions and 3,974 deletions.
54 changes: 39 additions & 15 deletions .github/actions/build-asset-unix.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
#! /usr/bin/env bash
# NOTE: This is meant to be run from the repo root dir
#
# Expects env variables:
# - BB_ARTIFACT_NAME
# - BB_VERSION
#

set -eo pipefail

compile_cuda=0
artifact_name=bladebit
version=v1.0

while true; do
case $1 in
--cuda)
compile_cuda=1 || exit 1
;;
--artifact)
shift && artifact_name=$1 || exit 1
;;
--version)
shift && version=$1 || exit 1
;;
esac
shift || break
done


thread_count=2

if [[ $OSTYPE == 'darwin'* ]]; then
Expand All @@ -19,11 +35,19 @@ fi
echo "System: $(uname -s)"
gcc --version

mkdir build && cd build
cmake ..
exe_name=bladebit
target=bladebit
if [[ compile_cuda -eq 1 ]]; then
target=bladebit_cuda
exe_name=bladebit_cuda
fi

set -x
mkdir build-${target} && cd build-${target}
cmake .. -DCMAKE_BUILD_TYPE=Release
bash -eo pipefail ../embed-version.sh
cmake --build . --target bladebit --config Release -j $thread_count
chmod +x ./bladebit
cmake --build . --config Release --target $target -j $thread_count
chmod +x ./${exe_name}

if [[ $OSTYPE == 'msys'* ]] || [[ $OSTYPE == 'cygwin'* ]]; then
ls -la Release
Expand All @@ -32,16 +56,16 @@ else
fi

# Ensure bladebit version matches expected version
bb_version="$(./bladebit --version | xargs)"
bb_version="$(./${exe_name} --version | xargs)"

if [[ "$bb_version" != "$BB_VERSION" ]]; then
>&2 echo "Incorrect bladebit version. Got '$bb_version' but expected '$BB_VERSION'."
if [[ "$bb_version" != "$version" ]]; then
>&2 echo "Incorrect bladebit version. Got '$bb_version' but expected '$version'."
exit 1
fi

tar --version
tar -czvf $BB_ARTIFACT_NAME bladebit
mkdir ../bin
mv $BB_ARTIFACT_NAME ../bin/
tar -czvf $artifact_name $exe_name
mkdir -p ../bin
mv $artifact_name ../bin/
ls -la ../bin

113 changes: 113 additions & 0 deletions .github/actions/build-harvester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env bash
set -eo pipefail
if [[ $RUNNER_DEBUG = 1 ]]; then
set -x
fi

host_os=$(uname -a)
case "${host_os}" in
Linux*) host_os="linux";;
Darwin*) host_os="macos";;
CYGWIN*) host_os="windows";;
MINGW*) host_os="windows";;
*Msys) host_os="windows";;
esac

if [[ "$host_os" == "windows" ]]; then
ext="zip"
else
ext="tar.gz"
fi

if [[ "$host_os" == "macos" ]]; then
procs=$(sysctl -n hw.logicalcpu)
sha_sum="shasum -a 256"
else
procs=$(nproc --all)
sha_sum="sha256sum"
fi

artifact_name=green_reaper.$ext

while true; do
case $1 in
--artifact)
shift && artifact_name=$1 || exit 1
;;
esac
shift || break
done

echo "Harvester artifact: ${artifact_name}"
echo 'cmake --version'
cmake --version

mkdir -p build-harvester
pushd build-harvester
cmake .. -DCMAKE_BUILD_TYPE=Release -DBB_HARVESTER_ONLY=ON

cmake --build . --config Release --target bladebit_harvester

if [[ "$host_os" == "windows" ]]; then
OBJDUMP=$("${CUDA_PATH}"\\bin\\cuobjdump Release\\bladebit_harvester.dll)
elif [[ "$host_os" == "linux" ]]; then
OBJDUMP=$(/usr/local/cuda/bin/cuobjdump libbladebit_harvester.so)
fi

cmake --install . --prefix harvester_dist
pushd harvester_dist/green_reaper

if [[ "$host_os" == "windows" ]]; then
mkdir -p lib
cp -vn ../../*/*.dll lib/
cp -vn ../../*/*.lib lib/
fi

artifact_files=($(find . -type f -name '*.*' | cut -c3-))

# shellcheck disable=SC2068
$sha_sum ${artifact_files[@]} > sha256checksum

artifact_files+=("sha256checksum")

if [[ "$host_os" == "windows" ]]; then
7z.exe a -tzip "${artifact_name}" "${artifact_files[@]}"
else
# shellcheck disable=SC2068
tar -czvf "${artifact_name}" ${artifact_files[@]}
fi

popd
mv "harvester_dist/green_reaper/${artifact_name}" ./
$sha_sum "${artifact_name}" > "${artifact_name}.sha256.txt"
ls -la
cat "${artifact_name}.sha256.txt"

if [[ "$CI" == "true" ]]; then
if [[ "$host_os" == "windows" ]] || [[ "$host_os" == "linux" ]]; then
while IFS= read -r line; do
echo -e "$(echo ${line#* } | tr -d '*')\n###### <sup>${line%% *}</sup>\n"
done <"${artifact_name}.sha256.txt" >> "$GITHUB_STEP_SUMMARY"
echo "| Arch | Code Version | Host | Compile Size |" >> "$GITHUB_STEP_SUMMARY"
echo "| --- | --- | --- | --- |" >> "$GITHUB_STEP_SUMMARY"
echo "$OBJDUMP" | awk -v RS= -v FS='\n' -v OFS=' | ' '{
for (i=1; i<=NF; i++) {
if (index($i, "=")) {
gsub(/.* = /, "", $i);
}
}
print $3, $4, $5, $6;
}' | sed 's/^/| /; s/$/ |/; s/ | | / | /g' >> "$GITHUB_STEP_SUMMARY"
fi

if [[ "$host_os" == "windows" ]]; then
harvester_artifact_path="$(cygpath -m "$(pwd)/${artifact_name}")*"
else
harvester_artifact_path="$(pwd)/${artifact_name}*"
fi
echo "harvester_artifact_path=$harvester_artifact_path"
echo "harvester_artifact_path=$harvester_artifact_path" >> "$GITHUB_ENV"
fi

popd
ls -la
6 changes: 4 additions & 2 deletions .github/actions/get-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if [[ "$os" == "windows" ]]; then
ext="zip"
fi

echo "::set-output name=BB_VERSION::$version"
echo "::set-output name=BB_ARTIFACT_NAME::bladebit-v${version}-${os}-${arch}.${ext}"
echo "BB_VERSION=$version" >> $GITHUB_ENV
echo "BB_ARTIFACT_NAME=bladebit-v${version}-${os}-${arch}.${ext}" >> $GITHUB_ENV
echo "BB_ARTIFACT_NAME_CUDA=bladebit-cuda-v${version}-${os}-${arch}.${ext}" >> $GITHUB_ENV


33 changes: 33 additions & 0 deletions .github/actions/install-cmake-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eo pipefail
ref_cmake_sha256='39e1c2eccda989b0d000dc5f4ee2cb031bdda799163780d855acc0bd9eda9d92'
cmake_name='cmake-3.23.3-linux-x86_64'

curl -L https://github.com/Kitware/CMake/releases/download/v3.23.3/cmake-3.23.3-linux-x86_64.tar.gz > cmake.tar.gz

cmake_sh_sha256=$(sha256sum cmake.tar.gz | cut -f1 -d' ')
if [[ "${ref_cmake_sha256}" != "${cmake_sh_sha256}" ]]; then
2>&1 echo "sha256 mismatch!: "
2>&1 echo "Got : '${cmake_sh_sha256}'"
2>&1 echo "Expected: '${ref_cmake_sha256}'"
exit 1
fi

rm -f /usr/bin/cmake && rm -f /usr/local/bin/cmake
mkdir -p /usr/local/bin
mkdir -p /usr/local/share

cmake_prefix=$(pwd)/${cmake_name}
tar -xzvf cmake.tar.gz
ls -la
ls -la ${cmake_prefix}

cp -r ${cmake_prefix}/bin/* /usr/local/bin/
cp -r ${cmake_prefix}/share/* /usr/local/share/

echo 'Cmake Info:'
which cmake
cmake --version

echo 'Done.'
exit 0
13 changes: 10 additions & 3 deletions .github/workflows/attach-release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ jobs:
bladebit-v${BB_VERSION}-ubuntu-arm64.tar.gz
bladebit-v${BB_VERSION}-centos-arm64.tar.gz
bladebit-v${BB_VERSION}-windows-x86-64.zip
bladebit-v${BB_VERSION}-macos-arm64.tar.gz
bladebit-v${BB_VERSION}-macos-x86-64.tar.gz
bladebit-cuda-v${BB_VERSION}-ubuntu-x86-64.tar.gz
bladebit-cuda-v${BB_VERSION}-centos-x86-64.tar.gz
bladebit-cuda-v${BB_VERSION}-ubuntu-arm64.tar.gz
bladebit-cuda-v${BB_VERSION}-windows-x86-64.zip
green_reaper-v${BB_VERSION}-linux-x86-64.tar.gz
green_reaper-v${BB_VERSION}-linux-ARM64.tar.gz
green_reaper-v${BB_VERSION}-macos-x86-64.tar.gz
green_reaper-v${BB_VERSION}-macos-arm64.tar.gz
green_reaper-v${BB_VERSION}-windows-x86-64.zip
)
mkdir -p bin
Expand All @@ -59,4 +66,4 @@ jobs:
echo "Uploading release asset '${artifact_name}'"
node .github/actions/artifacts.mjs upload-release-asset $BB_VERSION $artifact_name bin/$artifact_name
done
Loading

0 comments on commit 02a8e68

Please sign in to comment.