diff --git a/.github/actions/build-harvester.sh b/.github/actions/build-harvester.sh index 2460a279..08bdb992 100644 --- a/.github/actions/build-harvester.sh +++ b/.github/actions/build-harvester.sh @@ -42,19 +42,20 @@ 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 +./build-harvester.sh 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) + OBJDUMP=$(/usr/local/cuda/bin/cuobjdump "build-harvester/libbladebit_harvester.so") + + # Check for the right GNU_STACK flags + script_path=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) + # echo $script_path + ${script_path}/check-elf-gnu-stack-flags.sh "build-harvester/libbladebit_harvester.so" fi -cmake --install . --prefix harvester_dist +cmake --install "build-harvester" --prefix harvester_dist pushd harvester_dist/green_reaper if [[ "$host_os" == "windows" ]]; then @@ -109,5 +110,4 @@ if [[ "$CI" == "true" ]]; then echo "harvester_artifact_path=$harvester_artifact_path" >> "$GITHUB_ENV" fi -popd ls -la diff --git a/.github/actions/check-elf-gnu-stack-flags.sh b/.github/actions/check-elf-gnu-stack-flags.sh new file mode 100755 index 00000000..42e1172f --- /dev/null +++ b/.github/actions/check-elf-gnu-stack-flags.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail + +file_path=$1 +flag=$(readelf -e $file_path | grep GNU_STACK -A 1 | tail -n 1 | tr -s ' ' | cut -f4 -d' ') + +echo "Flag: GNU_STACK flag: $flag" + +if [[ $flag != "RW" ]]; then + >&2 echo "GNU_STACK flag is expected to be set to 'RW', but got '$flag'" + exit 1 +fi diff --git a/.github/workflows/attach-release-assets.yml b/.github/workflows/attach-release-assets.yml index 500e05b8..dbd7ea0d 100644 --- a/.github/workflows/attach-release-assets.yml +++ b/.github/workflows/attach-release-assets.yml @@ -7,7 +7,7 @@ on: jobs: upload-release-assets: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v4 @@ -16,7 +16,7 @@ jobs: # Setup Node - uses: actions/setup-node@v4 - with: { node-version: '16' } + with: { node-version: '20' } - run: cd .github/actions && npm install @octokit/action # Upload Artifacts as Release Assets @@ -30,20 +30,20 @@ jobs: echo "Release Version: $BB_VERSION" artifacts=( - bladebit-v${BB_VERSION}-ubuntu-x86-64.tar.gz - bladebit-v${BB_VERSION}-centos-x86-64.tar.gz - 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-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 + # bladebit-v${BB_VERSION}-ubuntu-x86-64.tar.gz + # bladebit-v${BB_VERSION}-rhl-x86-64.tar.gz + # bladebit-v${BB_VERSION}-ubuntu-arm64.tar.gz + # bladebit-v${BB_VERSION}-rhl-arm64.tar.gz + # bladebit-v${BB_VERSION}-windows-x86-64.zip + # bladebit-cuda-v${BB_VERSION}-ubuntu-x86-64.tar.gz + # bladebit-cuda-v${BB_VERSION}-rhl-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 + # 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 diff --git a/.github/workflows/build-harvester.yml b/.github/workflows/build-harvester.yml new file mode 100644 index 00000000..963c4af8 --- /dev/null +++ b/.github/workflows/build-harvester.yml @@ -0,0 +1,228 @@ +name: Build Harvester Release Assets +on: + push: + branches: ['*'] + workflow_dispatch: + +env: + CI_BLADEBIT: 1 # Our own CI, that is, not being built as a dependency + +jobs: + build-harvester-linux-x86-64: + runs-on: ubuntu-latest + container: + image: ghcr.io/chia-network/build-images/manylinux_cuda_x86_64:latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + id: version_number + shell: bash + run: ./.github/actions/get-version.sh ubuntu x86-64 + + - name: Install Prerequisites + shell: bash + run: | + set -eo pipefail + yum group install -y "Development Tools" + yum install -y sudo make git wget subscription-manager + + - name: Build Harvester + shell: bash + run: | + export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-x86-64.tar.gz" + echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" + # emits env.harvester_artifact_path + bash .github/actions/build-harvester.sh --artifact "${artifact_name}" + + - name: Upload Harvester Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.harvester_artifact_name }} + path: ${{ env.harvester_artifact_path }} + if-no-files-found: error + + # build-harvester-linux-arm64: + # runs-on: ubuntu-24.04-arm + # container: + # image: ghcr.io/chia-network/build-images/manylinux_cuda_aarch64:latest + # steps: + # - name: Checkout Repo + # uses: actions/checkout@v4 + + # - name: Set Env + # uses: Chia-Network/actions/setjobenv@main + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Cache DNF packages + # uses: actions/cache@v4 + # with: + # path: /var/cache/dnf + # key: ${{ runner.os }}-dnf-${{ hashFiles('**/your-build-file') }} + # restore-keys: | + # ${{ runner.os }}-dnf- + + # - name: Get Version Number + # id: version_number + # shell: bash + # run: ./.github/actions/get-version.sh rhl arm64 + + # - name: Install Prerequisites + # shell: bash + # run: | + # set -eo pipefail + # export module_platform_id=platform:el10 + # export MODULE_PLATFORM_ID=platform:el10 + # export PLATFORM_ID=platform:el10 + # uname -a + # cat /etc/os-release + # yum install -y dnf + # dnf install -y epel-release + # dnf install -y dnf-plugins-core + # dnf makecache + # dnf install -y kernel-headers.aarch64 kernel-devel.aarch64 tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms + # dnf install -y cmake + # dnf group install -y "Development Tools" + # dnf install -y gmp-devel numactl-devel make git wget sed + + # - name: Build Harvester + # shell: bash + # run: | + # export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-ARM64.tar.gz" + # echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" + # # emits env.harvester_artifact_path + # bash .github/actions/build-harvester.sh --artifact "${artifact_name}" + + # - name: Upload Harvester Artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.harvester_artifact_name }} + # path: ${{ env.harvester_artifact_path }} + # if-no-files-found: error + + # build-harvester-macos-arm64: + # runs-on: macos-latest + # steps: + # - name: Cleanup Environment + # uses: Chia-Network/actions/clean-workspace@main + + # - name: Checkout Repo + # uses: actions/checkout@v4 + + # - name: Set Env + # uses: Chia-Network/actions/setjobenv@main + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Get Version Number + # id: version_number + # run: bash -e .github/actions/get-version.sh macos arm64 + + # - name: Build Harvester + # shell: bash + # run: | + # export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-arm64.tar.gz" + # echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" + # # emits env.harvester_artifact_path + # bash .github/actions/build-harvester.sh --artifact "${artifact_name}" + + # - name: Upload Harvester Artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.harvester_artifact_name }} + # path: ${{ env.harvester_artifact_path }} + # if-no-files-found: error + + # build-harvester-macos-x86-64: + # runs-on: macOS-13 + # steps: + # - name: Cleanup Environment + # uses: Chia-Network/actions/clean-workspace@main + + # - name: Checkout Repo + # uses: actions/checkout@v4 + + # - name: Set Env + # uses: Chia-Network/actions/setjobenv@main + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Get Version Number + # id: version_number + # run: bash -e .github/actions/get-version.sh macos x86-64 + + # - name: Build Harvester + # shell: bash + # run: | + # export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-x86-64.tar.gz" + # echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" + # # emits env.harvester_artifact_path + # bash .github/actions/build-harvester.sh --artifact "${artifact_name}" + + # - name: Upload Harvester Artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.harvester_artifact_name }} + # path: ${{ env.harvester_artifact_path }} + # if-no-files-found: error + + # build-harvester-windows-x86-64: + # runs-on: windows-2022 + # steps: + # - name: Checkout Repo + # uses: actions/checkout@v4 + + # - name: Set Env + # uses: Chia-Network/actions/setjobenv@main + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Get Version Number + # id: version_number + # shell: bash + # run: ./.github/actions/get-version.sh windows x86-64 + + # - name: Install Prerequisites + # shell: powershell + # run: | + # choco install -y make + # choco install -y wget + # choco install -y sed + + # - name: Setup CUDA + # uses: Jimver/cuda-toolkit@v0.2.19 + # id: cuda-toolkit + # with: + # cuda: '12.6.2' + # method: network + + # - name: Verify CUDA + # shell: bash + # run: | + # echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}" + # echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" + # nvcc -V + + # - name: Build Harvester + # shell: bash + # run: | + # export artifact_name="green_reaper-v${{ env.BB_VERSION }}-windows-x86-64.zip" + # echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" + # # emits env.harvester_artifact_path + # bash .github/actions/build-harvester.sh --artifact "${artifact_name}" + # env: + # CUDA_PATH: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }} + + # - name: Upload Harvester Artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.harvester_artifact_name }} + # path: ${{ env.harvester_artifact_path }} + # if-no-files-found: error diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index 156b4a8d..00000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,545 +0,0 @@ -name: Build Release Assets -on: - push: - branches: ['*'] - workflow_dispatch: - -env: - CI_BLADEBIT: 1 # Our own CI, that is, not being built as a dependency - -jobs: - build-harvester-linux-x86-64: - runs-on: ubuntu-20.04 - container: - image: ghcr.io/chia-network/build-images/manylinux2014_cuda_x86_64:sha-1caf046d5ff19b7c743de2a106dd86928794032b - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - shell: bash - run: ./.github/actions/get-version.sh ubuntu x86-64 - - - name: Install Prerequisites - shell: bash - run: | - set -eo pipefail - yum group install -y "Development Tools" - yum install -y sudo make git wget subscription-manager - - - name: Build Harvester - shell: bash - run: | - export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-x86-64.tar.gz" - echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" - # emits env.harvester_artifact_path - bash .github/actions/build-harvester.sh --artifact "${artifact_name}" - - - name: Upload Harvester Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.harvester_artifact_name }} - path: ${{ env.harvester_artifact_path }} - if-no-files-found: error - - build-harvester-windows-x86-64: - runs-on: windows-2022 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - shell: bash - run: ./.github/actions/get-version.sh windows x86-64 - - - name: Install Prerequisites - shell: powershell - run: | - choco install -y make - choco install -y wget - choco install -y sed - - - name: Setup CUDA - uses: Jimver/cuda-toolkit@v0.2.15 - id: cuda-toolkit - with: - cuda: '12.1.0' - method: network - - - name: Verify CUDA - shell: bash - run: | - echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}" - echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" - nvcc -V - - - name: Build Harvester - shell: bash - run: | - export artifact_name="green_reaper-v${{ env.BB_VERSION }}-windows-x86-64.zip" - echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" - # emits env.harvester_artifact_path - bash .github/actions/build-harvester.sh --artifact "${artifact_name}" - env: - CUDA_PATH: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }} - - - name: Upload Harvester Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.harvester_artifact_name }} - path: ${{ env.harvester_artifact_path }} - if-no-files-found: error - - build-harvester-linux-arm64: - runs-on: [ARM64, Linux] - container: - image: ghcr.io/chia-network/build-images/manylinux2014_cuda_aarch64:sha-1caf046d5ff19b7c743de2a106dd86928794032b - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Cache DNF packages - uses: actions/cache@v4 - with: - path: /var/cache/dnf - key: ${{ runner.os }}-dnf-${{ hashFiles('**/your-build-file') }} - restore-keys: | - ${{ runner.os }}-dnf- - - - name: Get Version Number - id: version_number - shell: bash - run: ./.github/actions/get-version.sh centos arm64 - - - name: Install Prerequisites - shell: bash - run: | - set -eo pipefail - export module_platform_id=platform:el9 - export MODULE_PLATFORM_ID=platform:el9 - export PLATFORM_ID=platform:el9 - uname -a - cat /etc/os-release - yum install -y dnf - dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - dnf install -y dnf-plugins-core - dnf makecache - dnf install -y kernel-headers.aarch64 kernel-devel.aarch64 tar bzip2 make automake gcc gcc-c++ pciutils elfutils-libelf-devel libglvnd-opengl libglvnd-glx libglvnd-devel acpid pkgconfig dkms - dnf install -y cmake - dnf group install -y "Development Tools" - dnf install -y gmp-devel numactl-devel make git wget sed - - - name: Build Harvester - shell: bash - run: | - export artifact_name="green_reaper-v${{ env.BB_VERSION }}-linux-ARM64.tar.gz" - echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" - # emits env.harvester_artifact_path - bash .github/actions/build-harvester.sh --artifact "${artifact_name}" - - - name: Upload Harvester Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.harvester_artifact_name }} - path: ${{ env.harvester_artifact_path }} - if-no-files-found: error - - build-harvester-macos-arm64: - runs-on: [macos, arm64] - steps: - - name: Cleanup Environment - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: bash -e .github/actions/get-version.sh macos arm64 - - - name: Build Harvester - shell: bash - run: | - export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-arm64.tar.gz" - echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" - # emits env.harvester_artifact_path - bash .github/actions/build-harvester.sh --artifact "${artifact_name}" - - - name: Upload Harvester Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.harvester_artifact_name }} - path: ${{ env.harvester_artifact_path }} - if-no-files-found: error - - build-harvester-macos-x86-64: - runs-on: macOS-11 - steps: - - name: Cleanup Environment - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: bash -e .github/actions/get-version.sh macos x86-64 - - - name: Build Harvester - shell: bash - run: | - export artifact_name="green_reaper-v${{ env.BB_VERSION }}-macos-x86-64.tar.gz" - echo "harvester_artifact_name=${artifact_name}" >> "$GITHUB_ENV" - # emits env.harvester_artifact_path - bash .github/actions/build-harvester.sh --artifact "${artifact_name}" - - - name: Upload Harvester Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.harvester_artifact_name }} - path: ${{ env.harvester_artifact_path }} - if-no-files-found: error - - - build-bladebit-ubuntu-x86-64: - runs-on: ubuntu-20.04 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: .github/actions/get-version.sh ubuntu x86-64 - - - name: Install Prerequisites - run: | - sudo apt install -y libgmp-dev libnuma-dev - sudo bash .github/actions/install-cmake-linux.sh - - - name: Build Bladebit - run: .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{env.BB_VERSION}} - - - name: Setup CUDA - uses: Jimver/cuda-toolkit@v0.2.15 - id: cuda-toolkit - with: - cuda: '12.1.0' - method: network - linux-local-args: '["--toolkit"]' - - - name: Build Bladebit CUDA - run: .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{env.BB_VERSION}} - - - name: Upload Bladebit Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} - if-no-files-found: error - - - name: Upload Bladebit CUDA Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME_CUDA }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} - if-no-files-found: error - - build-bladebit-centos-x86-64: - runs-on: ubuntu-20.04 - container: - image: quay.io/centos/centos:stream8 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: .github/actions/get-version.sh centos x86-64 - - - name: Install Prerequisites - run: | - set -eo pipefail - dnf install -y gcc-toolset-9-gcc gcc-toolset-9-gcc-c++ \ - gmp-devel numactl-devel make git wget subscription-manager - bash .github/actions/install-cmake-linux.sh - - - name: Build Bladebit - run: | - source /opt/rh/gcc-toolset-9/enable - .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{ env.BB_VERSION }} - - - name: Install CUDA Prerequisites - run: | - distro=rhel8 - arch=x86_64 - dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm - dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-$distro.repo - dnf clean expire-cache - dnf module install -y nvidia-driver:latest-dkms - dnf install -y cuda - ls -la /usr/local/ - ls -la /usr/local/cuda/ - - - name: Build Bladebit CUDA - run: | - source /opt/rh/gcc-toolset-9/enable - .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{ env.BB_VERSION }} - - - name: Upload Bladebit Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} - if-no-files-found: error - - - name: Upload Bladebit CUDA Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME_CUDA }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} - if-no-files-found: error - - build-bladebit-centos-arm64: - runs-on: [ARM64, Linux] - container: - image: quay.io/centos/centos:stream8 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: .github/actions/get-version.sh centos arm64 - - - name: Install Prerequisites - run: | - dnf install -y gcc-toolset-9-gcc gcc-toolset-9-gcc-c++ \ - cmake gmp-devel numactl-devel make git - - - name: Build - run: | - source /opt/rh/gcc-toolset-9/enable - .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{ env.BB_VERSION }} - - - name: Upload Artifact CentOS ARM64 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} - if-no-files-found: error - - build-bladebit-cuda-linux-arm64: - runs-on: [ARM64, Linux] - container: - image: chianetwork/ubuntu-20.04-builder:latest - defaults: - run: - shell: bash - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - id: version_number - run: .github/actions/get-version.sh ubuntu arm64 - - - name: Install Prerequisites - run: | - export DEBIAN_FRONTEND=noninteractive - apt update - apt install -y build-essential git libgmp-dev libnuma-dev - - name: Setup CUDA - run: | - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/cuda-ubuntu2004.pin - mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 - wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-ubuntu2004-12-1-local_12.1.1-530.30.02-1_arm64.deb - dpkg -i cuda-repo-ubuntu2004-12-1-local_12.1.1-530.30.02-1_arm64.deb - cp /var/cuda-repo-ubuntu2004-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/ - apt-get update - DEBIAN_FRONTEND=noninteractive apt-get -y install cuda - - - name: Build - run: .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{env.BB_VERSION}} - - - name: Upload Artifact Ubuntu ARM64 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} - if-no-files-found: error - - - name: Build Bladebit CUDA - run: | - .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{ env.BB_VERSION }} - - name: Upload Bladebit CUDA Artifact - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME_CUDA }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} - if-no-files-found: error - - build-bladebit-windows-x86-64: - runs-on: windows-2019 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - shell: bash - id: version_number - run: .github/actions/get-version.sh windows x86-64 - - - name: Build Bladebit - shell: bash - env: - BB_ARTIFACT_NAME: ${{ env.BB_ARTIFACT_NAME }} - BB_VERSION: ${{env.BB_VERSION}} - run: | - mkdir build && cd build - cmake .. - bash -eo pipefail ../embed-version.sh - cat ../src/Version.h - cmake --build . --target bladebit --config Release - - # Ensure bladebit version matches expected version - bb_version="$(./Release/bladebit.exe --version | xargs)" - - if [[ "$bb_version" != "$BB_VERSION" ]]; then - >&2 echo "Incorrect bladebit version. Got but '$bb_version' expected '$BB_VERSION'." - exit 1 - fi - - mkdir ../bin - cd Release - ls -la - 7z.exe a -tzip ../../bin/${BB_ARTIFACT_NAME} bladebit.exe - ls -la ../../bin - - - name: Upload Bladebit Artifact Windows x86-64 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} - if-no-files-found: error - - build-bladebit-cuda-windows-x86-64: - runs-on: windows-2019 - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Version Number - shell: bash - id: version_number - run: .github/actions/get-version.sh windows x86-64 - - - name: Install Prerequisites - shell: powershell - run: | - choco install -y make - choco install -y wget - choco install -y sed - - - name: Setup CUDA - uses: Jimver/cuda-toolkit@v0.2.15 - id: cuda-toolkit - with: - cuda: '12.1.0' - method: network - - - name: Verify CUDA - shell: bash - run: | - echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}" - echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" - nvcc -V - - - name: Build Bladebit CUDA - shell: bash - env: - BB_ARTIFACT_NAME_CUDA: ${{ env.BB_ARTIFACT_NAME_CUDA }} - BB_VERSION: ${{env.BB_VERSION}} - run: | - mkdir build_cuda && cd build_cuda - cmake .. - bash -eo pipefail ../embed-version.sh - cat ../src/Version.h - cmake --build . --target bladebit_cuda --config Release - - # Ensure bladebit version matches expected version - bb_version="$(./Release/bladebit_cuda.exe --version | xargs)" - - if [[ "$bb_version" != "$BB_VERSION" ]]; then - >&2 echo "Incorrect bladebit version. Got but '$bb_version' expected '$BB_VERSION'." - exit 1 - fi - - mkdir ../bin - cd Release - ls -la - 7z.exe a -tzip ../../bin/${BB_ARTIFACT_NAME_CUDA} bladebit_cuda.exe - ls -la ../../bin - - - name: Upload Bladebit CUDA Artifact Windows x86-64 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.BB_ARTIFACT_NAME_CUDA }} - path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} - if-no-files-found: error diff --git a/.github/workflows/build-release.yml.disabled b/.github/workflows/build-release.yml.disabled new file mode 100644 index 00000000..e1b408e0 --- /dev/null +++ b/.github/workflows/build-release.yml.disabled @@ -0,0 +1,310 @@ +name: Build Bladebit Release Assets +on: + push: + branches: ['*'] + workflow_dispatch: + +env: + CI_BLADEBIT: 1 # Our own CI, that is, not being built as a dependency + +jobs: + build-bladebit-ubuntu-x86-64: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + id: version_number + run: .github/actions/get-version.sh ubuntu x86-64 + + - name: Install Prerequisites + run: | + sudo apt install -y libgmp-dev libnuma-dev cmake + + - name: Build Bladebit + run: .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{env.BB_VERSION}} + + - name: Setup CUDA + uses: Jimver/cuda-toolkit@v0.2.19 + id: cuda-toolkit + with: + cuda: '12.6.2' + method: network + linux-local-args: '["--toolkit"]' + + - name: Build Bladebit CUDA + run: .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{env.BB_VERSION}} + + - name: Upload Bladebit Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} + if-no-files-found: error + + - name: Upload Bladebit CUDA Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME_CUDA }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} + if-no-files-found: error + + build-bladebit-rhl-x86-64: + runs-on: ubuntu-latest + container: + image: ghcr.io/chia-network/build-images/manylinux_cuda_x86_64:latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + id: version_number + run: .github/actions/get-version.sh rhl x86-64 + + - name: Install Prerequisites + run: | + set -eo pipefail + dnf install -y gcc-toolset-14-gcc gcc-toolset-14-gcc-c++ \ + gmp-devel numactl-devel make cmake git wget subscription-manager + + + - name: Build Bladebit + run: | + source /opt/rh/gcc-toolset-14/enable + .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{ env.BB_VERSION }} + + - name: Build Bladebit CUDA + run: | + source /opt/rh/gcc-toolset-14/enable + .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{ env.BB_VERSION }} + + - name: Upload Bladebit Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} + if-no-files-found: error + + - name: Upload Bladebit CUDA Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME_CUDA }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} + if-no-files-found: error + + build-bladebit-rhl-arm64: + runs-on: ubuntu-24.04-arm + container: + image: ghcr.io/chia-network/build-images/manylinux_cuda_aarch64:latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + id: version_number + run: .github/actions/get-version.sh rhl arm64 + + - name: Install Prerequisites + run: | + dnf install -y gcc-toolset-14-gcc gcc-toolset-14-gcc-c++ \ + cmake gmp-devel numactl-devel make git + + - name: Build + run: | + source /opt/rh/gcc-toolset-14/enable + .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{ env.BB_VERSION }} + + - name: Upload Artifact AlmaLinux ARM64 + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} + if-no-files-found: error + + build-bladebit-cuda-linux-arm64: + runs-on: ubuntu-24.04-arm + container: + image: chianetwork/ubuntu-20.04-builder:latest + defaults: + run: + shell: bash + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + id: version_number + run: .github/actions/get-version.sh ubuntu arm64 + + - name: Install Prerequisites + run: | + export DEBIAN_FRONTEND=noninteractive + apt update + apt install -y build-essential git libgmp-dev libnuma-dev + - name: Setup CUDA + run: | + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/cuda-ubuntu2004.pin + mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 + wget https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda-repo-ubuntu2004-12-8-local_12.8.0-570.86.10-1_arm64.deb + dpkg -i cuda-repo-ubuntu2004-12-8-local_12.8.0-570.86.10-1_arm64.deb + cp /var/cuda-repo-ubuntu2004-12-8-local/cuda-*-keyring.gpg /usr/share/keyrings/ + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get -y install cuda + + - name: Build + run: .github/actions/build-asset-unix.sh --artifact ${{ env.BB_ARTIFACT_NAME }} --version ${{env.BB_VERSION}} + + - name: Upload Artifact Ubuntu ARM64 + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} + if-no-files-found: error + + - name: Build Bladebit CUDA + run: | + .github/actions/build-asset-unix.sh --cuda --artifact ${{ env.BB_ARTIFACT_NAME_CUDA }} --version ${{ env.BB_VERSION }} + - name: Upload Bladebit CUDA Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME_CUDA }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} + if-no-files-found: error + + build-bladebit-windows-x86-64: + runs-on: windows-2019 + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + shell: bash + id: version_number + run: .github/actions/get-version.sh windows x86-64 + + - name: Build Bladebit + shell: bash + env: + BB_ARTIFACT_NAME: ${{ env.BB_ARTIFACT_NAME }} + BB_VERSION: ${{env.BB_VERSION}} + run: | + mkdir build && cd build + cmake .. + cat ../src/Version.h + cmake --build . --target bladebit --config Release + + # Ensure bladebit version matches expected version + bb_version="$(./Release/bladebit.exe --version | xargs)" + + if [[ "$bb_version" != "$BB_VERSION" ]]; then + >&2 echo "Incorrect bladebit version. Got'$bb_version' but expected '$BB_VERSION'." + exit 1 + fi + + mkdir ../bin + cd Release + ls -la + 7z.exe a -tzip ../../bin/${BB_ARTIFACT_NAME} bladebit.exe + ls -la ../../bin + + - name: Upload Bladebit Artifact Windows x86-64 + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME }} + if-no-files-found: error + + build-bladebit-cuda-windows-x86-64: + runs-on: windows-2019 + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Version Number + shell: bash + id: version_number + run: .github/actions/get-version.sh windows x86-64 + + - name: Install Prerequisites + shell: powershell + run: | + choco install -y make + choco install -y wget + choco install -y sed + + - name: Setup CUDA + uses: Jimver/cuda-toolkit@v0.2.19 + id: cuda-toolkit + with: + cuda: '12.6.2' + method: network + + - name: Verify CUDA + shell: bash + run: | + echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}" + echo "Cuda install location: ${{ steps.cuda-toolkit.outputs.CUDA_PATH }}" + nvcc -V + + - name: Build Bladebit CUDA + shell: bash + env: + BB_ARTIFACT_NAME_CUDA: ${{ env.BB_ARTIFACT_NAME_CUDA }} + BB_VERSION: ${{env.BB_VERSION}} + run: | + mkdir build_cuda && cd build_cuda + cmake .. + cat ../src/Version.h + cmake --build . --target bladebit_cuda --config Release + + # Ensure bladebit version matches expected version + bb_version="$(./Release/bladebit_cuda.exe --version | xargs)" + + if [[ "$bb_version" != "$BB_VERSION" ]]; then + >&2 echo "Incorrect bladebit version. Got bb_version' but expected '$BB_VERSION'." + exit 1 + fi + + mkdir ../bin + cd Release + ls -la + 7z.exe a -tzip ../../bin/${BB_ARTIFACT_NAME_CUDA} bladebit_cuda.exe + ls -la ../../bin + + - name: Upload Bladebit CUDA Artifact Windows x86-64 + uses: actions/upload-artifact@v4 + with: + name: ${{ env.BB_ARTIFACT_NAME_CUDA }} + path: ${{ github.workspace }}/bin/${{ env.BB_ARTIFACT_NAME_CUDA }} + if-no-files-found: error diff --git a/.vscode/launch.json b/.vscode/launch.json index bb356736..0e8e671c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -137,7 +137,11 @@ // "--memo", "80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef207d52406afa2b6d7d92ea778f407205bd9dca40816c1b1cacfca2a6612b93eb", "args": - "-w -n 1 -z 1 -f ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef -p 80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8 -i c6b84729c23dc6d60c92f22c17083f47845c1179227c5509f07a5d2804a7b835 cudaplot --check 100 --check-threshold 2 /home/harold/plot", + + // List devices + "-w -n 1 -z 1 -f ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef -p 80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8 cudaplot -l", + + // "-w -n 1 -z 1 -f ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef -p 80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8 -i c6b84729c23dc6d60c92f22c17083f47845c1179227c5509f07a5d2804a7b835 cudaplot --check 100 --check-threshold 2 /home/harold/plot", // "-w -z 1 -f ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef -p 80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8 -i c6b84729c23dc6d60c92f22c17083f47845c1179227c5509f07a5d2804a7b835 cudaplot /home/harold/plot", // "-w -z 1 -f ade0cc43610ce7540ab96a524d0ab17f5df7866ef13d1221a7203e5d10ad2a4ae37f7b73f6cdfd6ddf4122e8a1c2f8ef -p 80a836a74b077cabaca7a76d1c3c9f269f7f3a8f2fa196a65ee8953eb81274eb8b7328d474982617af5a0fe71b47e9b8 -i c6b84729c23dc6d60c92f22c17083f47845c1179227c5509f07a5d2804a7b835 cudaplot --disk-128 -t1 /home/harold/plotdisk --no-direct-buffers /home/harold/plot", diff --git a/VERSION b/VERSION index 0c6173b5..1795fa29 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -3.1.0 +3.1.1 diff --git a/build-harvester.sh b/build-harvester.sh new file mode 100755 index 00000000..057b62cc --- /dev/null +++ b/build-harvester.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -e +_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +cd $_dir + +build_dir=build-harvester +mkdir -p ${build_dir} + +cmake -B ${build_dir} -DCMAKE_BUILD_TYPE=Release -DBB_HARVESTER_ONLY=ON +cmake --build ${build_dir} --target clean --config Release +cmake --build ${build_dir} --target bladebit_harvester --config Release -j32 diff --git a/cuda/CudaPlotter.cu b/cuda/CudaPlotter.cu index 80ba8b0e..95cd8fe4 100644 --- a/cuda/CudaPlotter.cu +++ b/cuda/CudaPlotter.cu @@ -47,6 +47,7 @@ static void UploadBucketToGpu( CudaK32PlotContext& context, TableId table, const static void LoadAndSortBucket( CudaK32PlotContext& cx, const uint32 bucket ); void CudaMatchBucketizedK32( CudaK32PlotContext& cx, const uint32* devY, cudaStream_t stream, cudaEvent_t event ); +[[noreturn]] static void ListCudaDevices( bool json ); // Defined in FxCuda.cu void GenFx( CudaK32PlotContext& cx, const uint32* devYIn, const uint32* devMetaIn, cudaStream_t stream ); @@ -59,6 +60,11 @@ GPU-based (CUDA) plotter -h, --help : Shows this help message and exits. -d, --device : Select the CUDA device index. (default=0) + -l, --list : List availabe CUDA devices, showing their indices. + + --json : Show output in json format. This is only valid for certain parameters: + --list + --disk-128 : Enable hybrid disk plotting for 128G system RAM. Requires a --temp1 and --temp2 to be set. @@ -95,6 +101,9 @@ void CudaK32Plotter::ParseCLI( const GlobalPlotConfig& gCfg, CliParser& cli ) CudaK32PlotConfig& cfg = _cfg; cfg.gCfg = &gCfg; + bool listDevices = false; + bool json = false; + while( cli.HasArgs() ) { if( cli.ReadU32( cfg.deviceIndex, "-d", "--device" ) ) @@ -127,6 +136,10 @@ void CudaK32Plotter::ParseCLI( const GlobalPlotConfig& gCfg, CliParser& cli ) continue; if( cli.ReadF64( cfg.plotCheckThreshhold, "--check-threshold" ) ) continue; + if( cli.ReadSwitch( json, "--json" ) ) + continue; + if( cli.ReadSwitch( listDevices, "-l", "--list" ) ) + continue; // if( cli.ReadSwitch( cfg.disableDirectDownloads, "--no-direct-buffers" ) ) // continue; if( cli.ArgMatch( "--help", "-h" ) ) @@ -139,6 +152,8 @@ void CudaK32Plotter::ParseCLI( const GlobalPlotConfig& gCfg, CliParser& cli ) } // The rest should be output directies, parsed by the global config parser. + if( listDevices ) + ListCudaDevices( json ); if( cfg.hybrid128Mode && gCfg.compressionLevel <= 0 ) { @@ -347,6 +362,64 @@ void CudaInit( CudaK32PlotContext& cx ) //FatalIf( supportsCoopLaunch != 1, "This CUDA device does not support cooperative kernel launches." ); } +//----------------------------------------------------------- +void ListCudaDevices( const bool json ) +{ + cudaError_t err = cudaSuccess; + int deviceCount = 0; + + #define CheckCudaSuccess( x ) if( (err = x) != cudaSuccess ) goto CUDA_ERROR_EXIT; + + { + CheckCudaSuccess( cudaGetDeviceCount( &deviceCount ) ); + + if( deviceCount < 1 ) + { + const char* e = "No CUDA devices available."; + if( json ) + Log::Line( R"({"error": "%s"})", e ); + else + Log::Line( e ); + exit(0); + } + + if( json ) + Log::Line("["); + + for( int i = 0; i < deviceCount; i++ ) + { + cudaDeviceProp cudaDevProps{}; + CheckCudaSuccess( cudaGetDeviceProperties( &cudaDevProps, i ) ); + + if( json ) + { + Log::Write( R"( {"id": %d, "name": "%s"})", i, cudaDevProps.name ); + if( i+1 < deviceCount ) + Log::Write( "," ); + + Log::NewLine(); + } + else + Log::Line( "%-2d: %s", i, cudaDevProps.name ); + } + + if( json ) + Log::Line("]"); + + exit(0); + } + + #undef CheckCudaSuccess + CUDA_ERROR_EXIT: + + if( json ) + Log::Error( R"({ "error": "Failed to list CUDA devices with error 0x%llx: '%s'"})", (llu)err, cudaGetErrorString( err ) ); + else + Log::Error( "Failed to list CUDA devices with error 0x%llx: '%s'.", (llu)err, cudaGetErrorString( err ) ); + + exit(1); +} + /// /// Plotting entry point diff --git a/src/b3/blake3_avx2_x86-64_unix.S b/src/b3/blake3_avx2_x86-64_unix.S index a9ea84e7..5fb418a9 100644 --- a/src/b3/blake3_avx2_x86-64_unix.S +++ b/src/b3/blake3_avx2_x86-64_unix.S @@ -1,3 +1,7 @@ +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +#endif + #ifdef __x86_64__ .intel_syntax noprefix .global _blake3_hash_many_avx2 diff --git a/src/b3/blake3_avx512_x86-64_unix.S b/src/b3/blake3_avx512_x86-64_unix.S index 1fd5bae5..060f1256 100644 --- a/src/b3/blake3_avx512_x86-64_unix.S +++ b/src/b3/blake3_avx512_x86-64_unix.S @@ -1,3 +1,7 @@ +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +#endif + #ifdef __x86_64__ .intel_syntax noprefix diff --git a/src/b3/blake3_sse41_x86-64_unix.S b/src/b3/blake3_sse41_x86-64_unix.S index 320a89fa..388a8826 100644 --- a/src/b3/blake3_sse41_x86-64_unix.S +++ b/src/b3/blake3_sse41_x86-64_unix.S @@ -1,3 +1,7 @@ +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +#endif + #ifdef __x86_64__ .intel_syntax noprefix .global blake3_hash_many_sse41 diff --git a/src/commands/CmdSimulator.cpp b/src/commands/CmdSimulator.cpp index e1c48251..e29089bd 100644 --- a/src/commands/CmdSimulator.cpp +++ b/src/commands/CmdSimulator.cpp @@ -92,6 +92,7 @@ void CmdSimulateMain( GlobalPlotConfig& gCfg, CliParser& cli ) else if( cli.ReadSize( cfg.farmSize, "-s", "--size" ) ) continue; else if( cli.ReadHexStrAsBytes( cfg.randomSeed, sizeof( cfg.randomSeed ), "--seed" ) ) continue; else if( cli.ReadSwitch( cfg.noCuda, "--no-cuda" ) ) continue; + else if( cli.ReadI32( cfg.cudaDevice, "-d", "--device" ) ) continue; else break; }