From 7621a9912ce03b55d56e45c5201a52b4b9234836 Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Tue, 24 Oct 2023 01:33:18 -0400 Subject: [PATCH 1/2] Build with SSE4 / AVX, better build artifacts --- .github/actions/upload-linux/action.yml | 49 ++++++++++++++++++++++++ .github/workflows/build-ci.yml | 51 ++++++++++++++++++------- CMakeLists.txt | 18 +++++++++ scripts/CMakeBuildPresetsCI.json | 43 ++++++++++++++++++++- scripts/package-release.sh | 3 +- 5 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 .github/actions/upload-linux/action.yml diff --git a/.github/actions/upload-linux/action.yml b/.github/actions/upload-linux/action.yml new file mode 100644 index 00000000000..69a94c52af0 --- /dev/null +++ b/.github/actions/upload-linux/action.yml @@ -0,0 +1,49 @@ +name: "Upload Linux Artifacts" +description: "Manage generating and uploading release artifacts for linux builds" + +inputs: + artifact_name: + description: "Name of generated artifact" + required: true + build_slug: + description: "platform-arch-build-flags" + required: true + token: + description: "access token for uploading to releases" + default: "" + upload_release: + description: "should the binary be uploaded to a tagged release?" + default: false + +runs: + using: "composite" + steps: + - name: Install + shell: bash + run: cmake --build ./build --target install + + - name: Package Artifact + shell: bash + env: + BUILD_SLUG: ${{ inputs.build_slug }} + run: | + cd out/install/ + tar -czf "pioneer-$BUILD_SLUG-$(date +%Y%m%d).tar.gz" "pioneer-$BUILD_SLUG" + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifact_name }} + path: ${{ format('out/install/pioneer-{0}-*.tar.gz', inputs.build_slug) }} + + - name: Build Release + shell: bash + run: ./scripts/package-release.sh + + - name: Upload Release Files + uses: softprops/action-gh-release@v1 + if: ${{ github.event_name == 'release' && inputs.upload_release }} + with: + files: release/pioneer-linux-x64-*.tar.gz + env: + GITHUB_TOKEN: ${{ inputs.token }} diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 35748d95a21..5299cac4c1a 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -111,24 +111,47 @@ jobs: - name: Run Tests run: ./build/unittest - - name: Build Release + - name: Generate Artifacts + uses: ./.github/actions/upload-linux + with: + artifact_name: Linux 64-bit + build_slug: linux-x64-release + token: ${{ secrets.GITHUB_TOKEN }} + upload_release: true + + build-gcc-avx: + runs-on: ubuntu-20.04 + + steps: + # Checkout the repository as $GITHUB_WORKSPACE + - uses: actions/checkout@v3 + + - name: Install Dependencies run: | - cmake --build ./build --target install - ./scripts/package-release.sh + sudo apt-fast update + sudo apt-fast install -y ${{ env.packages }} - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: Linux-Artifacts - path: release/pioneer-linux-x64-release-*.tar.gz + - name: Setup CMake + run: | + cp scripts/CMakeBuildPresetsCI.json CMakeUserPresets.json + cmake --preset linux-x64-release-avx - - name: Upload Release Files - uses: softprops/action-gh-release@v1 - if: ${{ github.event_name == 'release' }} + - name: Build GCC + run: cmake --build ./build --target all + + - name: Build Pioneer Data + run: cmake --build ./build --target build-data + + - name: Run Tests + run: ./build/unittest + + - name: Generate Artifacts + uses: ./.github/actions/upload-linux with: - files: release/pioneer-linux-x64-release-*.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + artifact_name: Linux 64-bit (AVX2 enabled) + build_slug: linux-x64-release-avx + token: ${{ secrets.GITHUB_TOKEN }} + upload_release: true build-clang: runs-on: ubuntu-20.04 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8684079840d..a70c188b1e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,24 @@ if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu") endif(APPLE) +option(USE_SSE42 "Compile for SSE4.2 compatible microarchitectures (enables optimizations)" ON) + +if (USE_SSE42) + if (NOT MSVC) + add_compile_options("-msse4.2" "-mlzcnt" "-mpopcnt") + endif() +endif (USE_SSE42) + +option(USE_AVX2 "Compile for AVX2 compatible microarchitectures (Haswell and newer)" OFF) + +if (USE_AVX2) + if (MSVC) + add_compile_options("/arch:AVX2") + else() + add_compile_options("-mavx2") + endif() +endif(USE_AVX2) + option(USE_LLD_LINKER "Use the LLVM lld linker instead of gcc's linker" OFF) if (CMAKE_COMPILER_IS_GNUCXX) add_compile_options( diff --git a/scripts/CMakeBuildPresetsCI.json b/scripts/CMakeBuildPresetsCI.json index 48a7e9b6741..aab1be38bc2 100644 --- a/scripts/CMakeBuildPresetsCI.json +++ b/scripts/CMakeBuildPresetsCI.json @@ -8,7 +8,7 @@ "binaryDir": "${sourceDir}/build/", "generator": "Unix Makefiles", "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/pioneer-${presetName}", "PIONEER_INSTALL_INPLACE": "1", "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, @@ -27,7 +27,7 @@ "binaryDir": "${sourceDir}/build/", "generator": "Unix Makefiles", "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/pioneer-${presetName}", "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, "vendor": { @@ -37,6 +37,45 @@ ] } } + }, + { + "name": "linux-x64-release-avx", + "displayName": "Linux x64 Release", + "description": "in-place installation target; Opt=yes; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/pioneer-${presetName}", + "PIONEER_INSTALL_INPLACE": "1", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "USE_AVX2": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } + }, + { + "name": "linux-x64-release-global-avx", + "displayName": "Linux x64 Release", + "description": "global installation target; Opt=yes; Profiler=no", + "binaryDir": "${sourceDir}/build/", + "generator": "Unix Makefiles", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/pioneer-${presetName}", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "USE_AVX2": true + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Linux" + ] + } + } } ] } diff --git a/scripts/package-release.sh b/scripts/package-release.sh index cbb0a952ce7..f34a0f9dfc0 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # Package a build and prepare it for upload to Github. @@ -9,7 +10,7 @@ fi mkdir release -mv out/install/linux-x64-release "release/pioneer-linux-x64-$TAG_NAME" +mv out/install/pioneer-linux-x64-release "release/pioneer-linux-x64-$TAG_NAME" cd release tar -czf "pioneer-linux-x64-$TAG_NAME.tar.gz" "pioneer-linux-x64-$TAG_NAME" From 937697bdcfa978171f33aac79e856f24a5e58fda Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Mon, 20 Nov 2023 18:49:30 -0500 Subject: [PATCH 2/2] CI: don't error when describing a build tag --- .github/actions/upload-linux/action.yml | 2 ++ scripts/build-release.sh | 5 +---- scripts/package-release.sh | 9 +++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/upload-linux/action.yml b/.github/actions/upload-linux/action.yml index 69a94c52af0..5beff549dbd 100644 --- a/.github/actions/upload-linux/action.yml +++ b/.github/actions/upload-linux/action.yml @@ -38,6 +38,8 @@ runs: - name: Build Release shell: bash + env: + BUILD_SLUG: ${{ inputs.build_slug }} run: ./scripts/package-release.sh - name: Upload Release Files diff --git a/scripts/build-release.sh b/scripts/build-release.sh index d67a80e3368..95823e9df3f 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -54,10 +54,7 @@ mkdir -p release/zip echo "Bundling output..." -TAG_NAME=$(git describe HEAD) -if [ -z "$TAG_NAME" ]; then - TAG_NAME=$(date +%Y%m%d) -fi +TAG_NAME=$(git describe --tags --exact-match HEAD || date +%Y%m%d) if [ "$BUILD_TYPE" == "mxe" ]; then zip -r "release/zip/pioneer-$TAG_NAME-mxe.zip" release/* -x *release/zip* diff --git a/scripts/package-release.sh b/scripts/package-release.sh index f34a0f9dfc0..c75fed43dc5 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -3,14 +3,15 @@ set -e # Package a build and prepare it for upload to Github. -TAG_NAME=$(git describe HEAD) -if [ -z "$TAG_NAME" ]; then - TAG_NAME=$(date +%Y%m%d) +TAG_NAME=$(git describe --tags --exact-match HEAD || date +%Y%m%d) + +if [ -z "$BUILD_SLUG" ]; then + BUILD_SLUG=linux-x64-release fi mkdir release -mv out/install/pioneer-linux-x64-release "release/pioneer-linux-x64-$TAG_NAME" +mv out/install/pioneer-$BUILD_SLUG "release/pioneer-linux-x64-$TAG_NAME" cd release tar -czf "pioneer-linux-x64-$TAG_NAME.tar.gz" "pioneer-linux-x64-$TAG_NAME"