Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with SSE4 / AVX, fix build artifact generation #5651

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/actions/upload-linux/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
env:
BUILD_SLUG: ${{ inputs.build_slug }}
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 }}
51 changes: 37 additions & 14 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
43 changes: 41 additions & 2 deletions scripts/CMakeBuildPresetsCI.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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": {
Expand All @@ -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"
]
}
}
}
]
}
5 changes: 1 addition & 4 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
10 changes: 6 additions & 4 deletions scripts/package-release.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash
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/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"
Expand Down