Skip to content

Commit

Permalink
Add initial implementation of cecxx
Browse files Browse the repository at this point in the history
  • Loading branch information
ewarchul committed Jan 12, 2025
0 parents commit 9488d55
Show file tree
Hide file tree
Showing 131 changed files with 9,490 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 22312
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 2123
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never

396 changes: 396 additions & 0 deletions .clang-tidy

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Add: '-std=c++23'
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CXX="clang++-19"
CC="clang-19"
17 changes: 17 additions & 0 deletions .github/workflows/CMocka-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "CMocka-test"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: workflow/nix-shell-action@v1
with:
packages: cmake,cmocka
script: |
nix-shell --command "bash test.sh"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/*
dist/*
build-*/*
.cache/*
legacy/*
include/cecxx/benchmark/defaults.hpp
data/*
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "third-party/concurrentqueue"]
path = third-party/concurrentqueue
url = https://github.com/cameron314/concurrentqueue.git
[submodule "deps/concurrentqueue/include/concurrentqueue"]
path = deps/concurrentqueue/include/concurrentqueue
url = https://github.com/cameron314/concurrentqueue.git
83 changes: 83 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.19)
set(PROJECT_VER 0.2.1)

project(cecxx
VERSION ${PROJECT_VER}
DESCRIPTION "An implementation of CECs benchmarks in C++23"
LANGUAGES CXX
)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(Package)
include(ProjectConfig)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(ROOT_DIR ${CMAKE_SOURCE_DIR})
set(HEADER_DIR ${ROOT_DIR}/include)
set(SOURCE_DIR ${ROOT_DIR}/src)

file(
GLOB_RECURSE
HEADERS
CONFIGURE_DEPENDS
${HEADER_DIR}/*.hpp
${HEADER_DIR}/**/*.hpp
)

file(
GLOB_RECURSE
SOURCES
CONFIGURE_DEPENDS
${SOURCE_DIR}/*.cpp
${SOURCE_DIR}/**/*.cpp
${SOURCE_DIR}/*.hpp
${SOURCE_DIR}/**/*.hpp
)

if (BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

add_library(cecxx)
target_sources(cecxx PRIVATE ${SOURCES})
target_sources(cecxx PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${HEADERS})
target_compile_options(cecxx PRIVATE ${COMPILE_FLAGS})
target_compile_features(cecxx PRIVATE cxx_std_23)

message(STATUS "The cecxx library is going to be compiled with the following additional flags: ${COMPILE_FLAGS}")

configure_file(defaults.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/cecxx/benchmark/defaults.hpp)
generate_export_header(cecxx)

write_basic_package_version_file("${PROJECT_BINARY_DIR}/cecxxConfigVersion.cmake"
VERSION ${PROJECT_VER}
COMPATIBILITY AnyNewerVersion
)

# include(CPack)
#
# install(TARGETS cecxx EXPORT cecxxTargets FILE_SET HEADERS)
# install(EXPORT cecxxTargets NAMESPACE cecxx:: DESTINATION lib/cmake/cecxx)
# install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/ DESTINATION "${BENCHMARK_DATA_STORAGE}")

if (WITH_EXAMPLES)
add_subdirectory(example)
endif()

if (WITH_BENCHMARKS)
add_subdirectory(benchmark)
endif()

if (WITH_TESTS)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_subdirectory(test)
else()
message(WARNING "To build tests, use clang (>=19) compiler. Current CXX compiler: ${CMAKE_CXX_COMPILER}")
endif()
endif(WITH_TESTS)
51 changes: 51 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
set dotenv-load

alias i := init_build
alias b := build
alias p := package
alias e := exe
alias t := test
alias c := clean

cxx_compiler := "${CXX}"
c_compiler := "${CC}"
build_dir := "build-" + cxx_compiler
ncores := `nproc`


default:
@just --list

init_build: clean
mkdir -p {{build_dir}}
cd {{build_dir}} && CC={{c_compiler}} CXX={{cxx_compiler}} cmake -DWITH_TESTS=on -DWITH_EXAMPLES=on ..
ln -fs {{build_dir}}/compile_commands.json compile_commands.json

build:
cd {{build_dir}} && make -j {{ncores}}

exe:
./{{build_dir}}/example/evaluator/evaluator_example


test $fuzz_duration:
#!/usr/bin/env bash
set -euo pipefail
dimensions=(10 30 50 100)
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
for dim in ${dimensions[@]}; do
echo -e "${GREEN} Running compliance tests for dimension ${dim}. Duration: ${fuzz_duration} ${NO_COLOR}"
unzip -o "${PWD}/data/cec2017.zip" -d "${PWD}/data"
ASAN_OPTIONS=detect_leaks=0 ./{{build_dir}}/test/cecxx-fuzz --fuzz="Cec2017ComplianceTest.Cec2017D${dim}ImplsAreEquiv" --fuzz_for={{fuzz_duration}} || true
done
package:
cd {{build_dir}} && cpack

clean:
rm -rf {{build_dir}}

fmt:
find src -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
find include -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
Loading

0 comments on commit 9488d55

Please sign in to comment.