Skip to content

Commit e0e7a61

Browse files
committed
WIP.
1 parent 31aef3f commit e0e7a61

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed

.github/workflows/cmake-multi-platform.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
2-
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
31
name: Build and test on multiple platforms
42

53
on:
@@ -14,15 +12,8 @@ jobs:
1412
runs-on: ${{ matrix.os }}
1513

1614
strategy:
17-
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
1815
fail-fast: false
1916

20-
# Set up a matrix to run the following 3 configurations:
21-
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
22-
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
23-
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
24-
#
25-
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2617
matrix:
2718
os: [ubuntu-latest, windows-latest]
2819
build_type: [Debug]
@@ -61,15 +52,12 @@ jobs:
6152
git status
6253
6354
- name: Set reusable strings
64-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
6555
id: strings
6656
shell: bash
6757
run: |
6858
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
6959
7060
- name: Configure CMake
71-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
72-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
7361
run: >
7462
cmake -B ${{ steps.strings.outputs.build-output-dir }}
7563
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
@@ -79,11 +67,8 @@ jobs:
7967
-S ${{ github.workspace }}
8068
8169
- name: Build
82-
# 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).
8370
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
8471

8572
- name: Test
8673
working-directory: ${{ steps.strings.outputs.build-output-dir }}
87-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
88-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
89-
run: ctest --build-config ${{ matrix.build_type }}
74+
run: ctest --rerun-failed --output-on-failure --build-config ${{ matrix.build_type }}

include/xtxn/alignment.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2025 Vitaly Anasenko
2+
// Distributed under the MIT License, see accompanying file LICENSE.txt
3+
4+
#pragma once
5+
6+
#include <new>
7+
8+
namespace xtxn {
9+
#ifdef __cpp_lib_hardware_interference_size
10+
constexpr std::size_t queue_alignment { std::hardware_constructive_interference_size };
11+
#else
12+
constexpr std::size_t queue_alignment { 64 };
13+
#endif
14+
}

include/xtxn/fast_mpmc_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
#include <cassert>
77
#include <concepts>
8-
#include <new>
98
#include <atomic>
109
#include <array>
1110
#include "fast_queue_internal.hpp"
1211
#include "spinlock.hpp"
12+
#include "alignment.hpp"
1313

1414
namespace xtxn {
1515
enum class queue_growth_policy { call, round, step };
@@ -23,7 +23,7 @@ namespace xtxn {
2323
queue_growth_policy G = queue_growth_policy::round
2424
>
2525
requires ((S >= 4) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0) && (A <= queue_max_attempts))
26-
class alignas(std::hardware_constructive_interference_size) fast_mpmc_queue {
26+
class alignas(queue_alignment) fast_mpmc_queue {
2727
struct slot;
2828
struct block;
2929
using slot_completion = queue_slot_completion<C>;

include/xtxn/fastest_mpmc_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
#include <cassert>
77
#include <concepts>
8-
#include <new>
98
#include <atomic>
109
#include <array>
1110
#include "fast_queue_internal.hpp"
11+
#include "alignment.hpp"
1212

1313
namespace xtxn {
1414
template<
@@ -18,7 +18,7 @@ namespace xtxn {
1818
int32_t A = queue_default_attempts
1919
>
2020
requires ((S >= 4) && (S <= queue_max_capacity_limit) && (A > 0) && (A <= queue_max_attempts))
21-
class alignas(std::hardware_constructive_interference_size) fastest_mpmc_queue {
21+
class alignas(queue_alignment) fastest_mpmc_queue {
2222
struct slot;
2323
using slot_completion = queue_slot_completion<C>;
2424
// class base_accessor;

include/xtxn/mpmc_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
#include <cassert>
1212
#include <cstdint>
13-
#include <new>
1413
#include <atomic>
1514
#include <memory>
1615
#include <unordered_map>
1716
#include <algorithm>
1817
#include "spinlock.hpp"
18+
#include "alignment.hpp"
1919

2020
namespace xtxn {
2121
constexpr int64_t queue_default_purge_counter { 0x80 };
@@ -29,7 +29,7 @@ namespace xtxn {
2929
int S = queue_default_purge_skip_first
3030
>
3131
requires (C >= 4) && (S >= 4)
32-
class alignas(std::hardware_constructive_interference_size) mpmc_queue final {
32+
class alignas(queue_alignment) mpmc_queue final {
3333
struct node;
3434
using mo = std::memory_order;
3535
using epoch_type = uint_fast64_t;

include/xtxn/mpmcdd_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
#pragma once
99

10-
#include <new>
1110
#include <atomic>
1211
#include <memory>
1312
#include "color_barrier.hpp"
13+
#include "alignment.hpp"
1414

1515
namespace xtxn {
1616
template<typename T>
17-
class alignas(std::hardware_constructive_interference_size) mpmcdd_queue final {
17+
class alignas(queue_alignment) mpmcdd_queue final {
1818
struct node;
1919
using mo = std::memory_order;
2020

include/xtxn/mpmcsl_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
#pragma once
99

10-
#include <new>
1110
#include <atomic>
1211
#include <memory>
1312
#include "spinlock.hpp"
13+
#include "alignment.hpp"
1414

1515
namespace xtxn {
1616
template<typename T>
17-
class alignas(std::hardware_constructive_interference_size) mpmcsl_queue final {
17+
class alignas(queue_alignment) mpmcsl_queue final {
1818
struct node;
1919
using mo = std::memory_order;
2020

include/xtxn/mpsc_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
#pragma once
55

6-
#include <new>
76
#include <atomic>
87
#include <memory>
8+
#include "alignment.hpp"
99

1010
namespace xtxn {
1111
template<typename T>
12-
class alignas(std::hardware_constructive_interference_size) mpsc_queue final {
12+
class alignas(queue_alignment) mpsc_queue final {
1313
struct node;
1414
using mo = std::memory_order;
1515

0 commit comments

Comments
 (0)