Skip to content
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: 46 additions & 5 deletions .github/workflows/cmake-gcc-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,30 @@ jobs:
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm] # windows-latest
build_type: [Release]
compiler:
- { c: gcc, cpp: g++ }
- { c: clang, cpp: clang++ }
include:
# --- Linux x64 ---
# We define 'compiler' as a dictionary (object) here
- os: ubuntu-latest
build_type: Release
compiler: { c: gcc, cpp: g++ }

- os: ubuntu-latest
build_type: Release
compiler: { c: clang, cpp: clang++ }

# --- Linux ARM ---
- os: ubuntu-24.04-arm
build_type: Release
compiler: { c: gcc, cpp: g++ }

- os: ubuntu-24.04-arm
build_type: Release
compiler: { c: clang, cpp: clang++ }

# --- Windows ---
- os: windows-latest
build_type: Release
compiler: { c: cl, cpp: cl }

steps:
- uses: actions/checkout@v5
Expand All @@ -56,6 +75,19 @@ jobs:
run: |
sudo apt-get install --yes -qq libboost-all-dev

- name: Install Boost via vcpkg (Windows)
if: startsWith(matrix.os, 'windows')
run: |
# 1. Install Boost using the Microsoft Package Manager
# windows-latest has vcpkg pre-installed at C:\vcpkg
vcpkg install boost-test:x64-windows

# 2. Inform CMake where to find it
echo "BOOST_ROOT=$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows" >> $env:GITHUB_ENV

# 3. Add vcpkg DLL path to CI before running tests
echo "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" >> $env:GITHUB_PATH

- name: Configure CMake Ubuntu
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand All @@ -69,6 +101,15 @@ jobs:
-DATOMIC_QUEUE_BUILD_EXAMPLES=ON
-S ${{ github.workspace }}

- name: Configure CMake Windows - MSVC
if: startsWith(matrix.os, 'windows') && matrix.compiler.cpp == 'cl'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DATOMIC_QUEUE_BUILD_TESTS=ON
-DATOMIC_QUEUE_BUILD_EXAMPLES=ON
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
Expand Down
2 changes: 1 addition & 1 deletion src/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main() {
// Start the producers.
std::thread producers[PRODUCERS];
for(int i = 0; i < PRODUCERS; ++i)
producers[i] = std::thread([&q]() {
producers[i] = std::thread([&q, N = N]() {
// Each producer pushes range [1, N] elements into the queue.
// Ascending order [1, N] requires comparing with N at each loop iteration. Ascending order isn't necessary here.
// Push elements in descending order, range [N, 1] with step -1, so that CPU decrement instruction sets zero/equal flag
Expand Down
2 changes: 1 addition & 1 deletion src/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void stress() {
uint64_t results[CONSUMERS];
std::thread consumers[CONSUMERS];
for(unsigned i = 0; i < CONSUMERS; ++i)
consumers[i] = std::thread([&q, &barrier, &r = results[i]]() {
consumers[i] = std::thread([&q, &barrier, &r = results[i], STOP = STOP]() {
barrier.wait();
uint64_t result = 0;
for(T n; (n = q.pop()) != STOP;)
Expand Down