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

Create gitaction from github default template: cmake-multi-platform.yml #18

Merged
merged 18 commits into from
Dec 12, 2023
Merged
84 changes: 84 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
paths-ignore:
- '**.md'
branches: [ "master" ]
pull_request:
paths-ignore:
- '**.md'
branches: [ "master" ]

env:
BUILD_TYPE: Release

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# 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.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
# 4. <OSX>
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release]
c_compiler: [gcc, clang]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: ubuntu-latest
c_compiler: clang
- os: macos-latest
c_compiler: gcc

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
# 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
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

# - name: Create Build Environment
# # Some projects don't allow in-source building, so create a separate build directory
# # We'll use this as our working directory for all subsequent commands
# run: cmake -E make_directory ${{github.workspace}}/build


- 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 }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# 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).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if ( NOT VERSION )
execute_process(COMMAND bash "-c" "git rev-list --branches HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()

message( STATUS "Compiler: ${CMAKE_C_COMPILER}")

set(MINOR_VERSION 1)
math(EXPR VERSION-BASE ${GIT_VERSION}/255)
math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255)
Expand All @@ -40,14 +42,18 @@ if(SYSTEM_INCLUDE)
endif()

# change to c++20 in version 2.0
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -std=c++14 -pthread -D_GLIBCXX_USE_NANOSLEEP")
else()
set(PLATFORM_LINK_LIBRIES rt)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -std=c++14 -pthread -lrt -D_GLIBCXX_USE_NANOSLEEP -D_GLIBCXX_USE_SCHED_YIELD")
if (MSVC)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -std=c++17 -pthread -D_GLIBCXX_USE_NANOSLEEP")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-stdlib=libc++")
#add_compile_options("-std=c++20")
endif()



file(GLOB SRC_FILES ${PROJECT_SRC}/g3log/*.h ${PROJECT_SRC}/q/*.hpp ${PROJECT_SRC}/*.cpp)
file(GLOB HEADER_FILES ${PROJECT_SRC}/q/*.hpp)

Expand Down
2 changes: 1 addition & 1 deletion examples/spsc_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void consumeMessages(ReceiverQ& receiver, std::atomic<bool>& keep_working) {


int main() {
// Create a flexible SPSC queue with a dynamic size, determined at runtime initialization
// Create a flexible SPSC queue with a dynamic size, determined at runtime initialization.
auto queue = queue_api::CreateQueue<spsc::flexible::circular_fifo<std::string>>(10);

// Get the sender and receiver endpoints of the queue
Expand Down
22 changes: 11 additions & 11 deletions test/test_performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TEST(Performance, MPMC_1_to_1_Smaller) {
RunSPSC(queue, kAmount);
}

TEST(Performance, SPSC_Flexible_20secRun_LargeData) {
TEST(Performance, DISABLED_SPSC_Flexible_20secRun_LargeData) {
using namespace std;
auto queue = queue_api::CreateQueue<spsc::flexible::circular_fifo<std::string>>(kSmallQueueSize);
const size_t large = 65000;
Expand All @@ -69,7 +69,7 @@ TEST(Performance, SPSC_Flexible_20secRun_LargeData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, SPSC_Fixed_20secRun_LargeData) {
TEST(Performance, DISABLED_SPSC_Fixed_20secRun_LargeData) {
using namespace std;
auto queue = queue_api::CreateQueue<spsc::fixed::circular_fifo<std::string, kSmallQueueSize>>();
const size_t large = 65000;
Expand All @@ -81,7 +81,7 @@ TEST(Performance, SPSC_Fixed_20secRun_LargeData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, MPMC_1_to_4_20secRun_LargeData) {
TEST(Performance, DISABLED_MPMC_1_to_4_20secRun_LargeData) {
using namespace std;
auto queue = queue_api::CreateQueue<mpmc::flexible_lock_queue<string>>(kSmallQueueSize);
const size_t large = 65000;
Expand All @@ -93,7 +93,7 @@ TEST(Performance, MPMC_1_to_4_20secRun_LargeData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, MPMC_1_to_4_20secRun_SmallData) {
TEST(Performance, DISABLED_MPMC_1_to_4_20secRun_SmallData) {
using namespace std;
auto queue = queue_api::CreateQueue<mpmc::flexible_lock_queue<string>>(kSmallQueueSize);
const size_t small = 10;
Expand All @@ -105,7 +105,7 @@ TEST(Performance, MPMC_1_to_4_20secRun_SmallData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, lock_free__SPMC_1_to_4_20secRun_LargeData) {
TEST(Performance, DISABLED_lock_free__SPMC_1_to_4_20secRun_LargeData) {
using namespace std;
using element = std::string;
using qtype = spsc::flexible::circular_fifo<element>;
Expand All @@ -122,7 +122,7 @@ TEST(Performance, lock_free__SPMC_1_to_4_20secRun_LargeData) {
RunSPMC<qtype, qtype_pair>(queues, payload, kTimeToRunSec);
}

TEST(Performance, lock_free__SPMC_1_to_4_20secRun_SmallData) {
TEST(Performance, DISABLED_lock_free__SPMC_1_to_4_20secRun_SmallData) {
using namespace std;
using element = std::string;
using qtype = spsc::flexible::circular_fifo<element>;
Expand All @@ -139,7 +139,7 @@ TEST(Performance, lock_free__SPMC_1_to_4_20secRun_SmallData) {
RunSPMC<qtype, qtype_pair>(queues, payload, kTimeToRunSec);
}

TEST(Performance, MPMC_4_to_1_20secRun_LargeData) {
TEST(Performance, DISABLED_MPMC_4_to_1_20secRun_LargeData) {
using namespace std;
auto queue = queue_api::CreateQueue<mpmc::flexible_lock_queue<string>>(kSmallQueueSize);
const size_t large = 65000;
Expand All @@ -151,7 +151,7 @@ TEST(Performance, MPMC_4_to_1_20secRun_LargeData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, MPMC_4_to_1_20secRun_SmallData) {
TEST(Performance, DISABLED_MPMC_4_to_1_20secRun_SmallData) {
using namespace std;
auto queue = queue_api::CreateQueue<mpmc::flexible_lock_queue<string>>(kSmallQueueSize);
const size_t small = 10;
Expand All @@ -163,7 +163,7 @@ TEST(Performance, MPMC_4_to_1_20secRun_SmallData) {
RunMPMC(queue, payload, numberOfProducers, numberOfConsumers, kTimeToRunSec);
}

TEST(Performance, lock_free__MPSC_4_to_1_20secRun_LargeData) {
TEST(Performance, DISABLED_lock_free__MPSC_4_to_1_20secRun_LargeData) {
using namespace std;
using element = std::string;
using qtype = spsc::flexible::circular_fifo<element>;
Expand All @@ -180,7 +180,7 @@ TEST(Performance, lock_free__MPSC_4_to_1_20secRun_LargeData) {
RunMPSC<qtype, qtype_pair>(queues, payload, kTimeToRunSec);
}

TEST(Performance, lock_free__MPSC_4_to_1_20secRun_SmallData) {
TEST(Performance, DISABLED_lock_free__MPSC_4_to_1_20secRun_SmallData) {
using namespace std;
using element = std::string;
using qtype = spsc::flexible::circular_fifo<element>;
Expand All @@ -197,7 +197,7 @@ TEST(Performance, lock_free__MPSC_4_to_1_20secRun_SmallData) {
RunMPSC<qtype, qtype_pair>(queues, payload, kTimeToRunSec);
}

TEST(Performance, MPMC_4_to_4_20secRun_LargeData) {
TEST(Performance, DISABLED_MPMC_4_to_4_20secRun_LargeData) {
using namespace std;
auto queue = queue_api::CreateQueue<mpmc::flexible_lock_queue<string>>(kSmallQueueSize);
const size_t large = 65000;
Expand Down