Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4ca3338
Restructure, add benchmarks, migrate to CMake
DanieleDeSensi May 22, 2026
cfce9ff
[IMP] Refactoring, pretty print and README.
DanieleDeSensi May 26, 2026
4f2bac5
[ADD] More distributions for random bursts.
DanieleDeSensi May 26, 2026
883440c
Update README.md
DanieleDeSensi May 26, 2026
0d0cc34
[ADD] Logo.
DanieleDeSensi May 26, 2026
2ee941a
Merge branch 'dev' of github.com:DanieleDeSensi/blink into dev
DanieleDeSensi May 26, 2026
e7d734e
[ADD] Logo.
DanieleDeSensi May 26, 2026
397e83c
[ADD] Logo.ush
DanieleDeSensi May 26, 2026
2b29e0a
[ADD] Fixes and refactoring.
DanieleDeSensi Jun 5, 2026
ad45df4
[ADD] New tests.
DanieleDeSensi Jun 6, 2026
fa54055
Add GitHub Actions CI with ctest + gcovr/Codecov coverage
DanieleDeSensi Jun 6, 2026
c37f18c
docs: pin CI and coverage badges to the dev branch
DanieleDeSensi Jun 6, 2026
54be384
[ADD] Coverage.
DanieleDeSensi Jun 6, 2026
e065eb9
docs: point badges at the canonical hlc-lab/blink repo
DanieleDeSensi Jun 6, 2026
f93ee10
Add -plot: ASCII histogram of per-iteration latency distribution
DanieleDeSensi Jun 6, 2026
79c52ce
Refactor: share one histogram-row renderer between -plot and dist_test
DanieleDeSensi Jun 6, 2026
c606d8c
Add MIT LICENSE and CodeQL static-analysis workflow, with README badges
DanieleDeSensi Jun 6, 2026
e76e505
[FIX] Minor
DanieleDeSensi Jun 6, 2026
4abe76d
Remove unreachable post-malloc_align NULL checks (dead code)
DanieleDeSensi Jun 8, 2026
cd1e3a3
coverage: exercise burst sampling, checker, null_dummy; tune gcovr
DanieleDeSensi Jun 8, 2026
2e49ab7
Refactor: compile shared runtime once (common.h -> common.h + common.c)
DanieleDeSensi Jun 8, 2026
601e4bf
tests: cover randomised-burst/pause branches in every benchmark
DanieleDeSensi Jun 8, 2026
e3b3927
[FIX] Compilation.
DanieleDeSensi Jun 10, 2026
55bddc8
[FIX] Compilation.
DanieleDeSensi Jun 10, 2026
daa9c63
[FIX] Compilation.
DanieleDeSensi Jun 10, 2026
c80f31a
feat: add -h/--help to every benchmark (weak benchmark_help symbol)
DanieleDeSensi Jun 10, 2026
2fa08ac
fix: -blength/-bpause accept unit suffixes (s, ms, us, ns)
DanieleDeSensi Jun 10, 2026
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
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CI

# Run on every push and pull request so each commit is validated.
on:
push:
pull_request:

# Cancel an in-progress run if a newer commit is pushed to the same ref.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: build • test • coverage (OpenMPI)
runs-on: ubuntu-latest
timeout-minutes: 30
env:
# GitHub-hosted runners have fewer cores than the 8 ranks some suites
# launch, so allow MPI to oversubscribe. (rmaps_base for OpenMPI 4.x,
# the PRTE policy for OpenMPI 5.x — setting the unused one is harmless.)
OMPI_MCA_rmaps_base_oversubscribe: "1"
PRTE_MCA_rmaps_default_mapping_policy: ":oversubscribe"
steps:
- uses: actions/checkout@v4

- name: Install toolchain (CMake, OpenMPI, gcovr)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake build-essential openmpi-bin libopenmpi-dev gcovr

- name: Configure (tests + coverage)
run: cmake -B build -DBLINK_TESTS=ON -DBLINK_COVERAGE=ON

- name: Build
run: cmake --build build -j"$(nproc)"

- name: Run tests
run: ctest --test-dir build --output-on-failure --no-tests=error

# ---- coverage (best-effort: never flips the test verdict) ----
- name: Coverage report (gcovr)
if: always()
continue-on-error: true
run: |
gcovr --root . --filter 'src/' \
--exclude-unreachable-branches --exclude-throw-branches \
--exclude-lines-by-pattern '.*MPI_Abort.*' \
--xml-pretty -o coverage.xml \
--print-summary | tee coverage_summary.txt
{
echo '## Coverage (src/)'
echo '```'
cat coverage_summary.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload coverage to Codecov
if: always()
continue-on-error: true
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: false
env:
# Optional: set this repo secret to enable Codecov uploads/badge.
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.xml
coverage_summary.txt
if-no-files-found: ignore
46 changes: 46 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CodeQL

# Static analysis for C/C++. Runs on pushes/PRs to the main branches and
# weekly (to catch newly-published queries against unchanged code).
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
schedule:
- cron: '0 6 * * 1' # Mondays 06:00 UTC

jobs:
analyze:
name: Analyze (c-cpp)
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write # upload results to the Security tab
actions: read
contents: read
steps:
- uses: actions/checkout@v4

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake build-essential openmpi-bin libopenmpi-dev

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: c-cpp

# Manual build (more reliable than autobuild for a CMake+MPI project).
# Tests are off so CodeQL focuses on the benchmark sources, not GTest.
- name: Build
run: |
cmake -B build -DBLINK_TESTS=OFF
cmake --build build -j"$(nproc)"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:c-cpp"
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build/
build*/

# coverage artifacts (generated; uploaded to Codecov by CI, never committed)
coverage.xml
coverage*.html
*.gcda
*.gcno
*.gcov
113 changes: 113 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 3.16)
project(blink C CXX)

# On HPC systems where CC/CXX are already MPI wrappers (mpicc/mpicxx),
# FindMPI's link-test often fails because LD_LIBRARY_PATH isn't set up for
# CMake's subprocess. Pass -DBLINK_MPI_WRAPPER=ON to skip FindMPI and create
# stub INTERFACE targets instead — the wrapper already injects all flags.
option(BLINK_MPI_WRAPPER
"Assume CC/CXX are MPI compiler wrappers; skip find_package(MPI)" OFF)

if(BLINK_MPI_WRAPPER)
# Prefer $ENV{MPICC} (always correct on HPC modules) over CMAKE_C_COMPILER
# (which may be the underlying gcc if the CMake cache is stale).
if(DEFINED ENV{MPICC})
set(_mpi_cc "$ENV{MPICC}")
elseif(CMAKE_C_COMPILER MATCHES "mpi")
set(_mpi_cc "${CMAKE_C_COMPILER}")
else()
find_program(_mpi_cc NAMES mpicc DOC "MPI C compiler wrapper")
endif()
if(NOT _mpi_cc)
message(FATAL_ERROR
"BLINK_MPI_WRAPPER=ON but no MPI wrapper found.\n"
"Set the MPICC environment variable or put mpicc on PATH.")
endif()
message(STATUS "BLINK_MPI_WRAPPER=ON — querying '${_mpi_cc}' for MPI flags")
execute_process(COMMAND "${_mpi_cc}" --showme:incdirs
OUTPUT_VARIABLE _mpi_incdirs OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND "${_mpi_cc}" --showme:libdirs
OUTPUT_VARIABLE _mpi_libdirs OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND "${_mpi_cc}" --showme:libs
OUTPUT_VARIABLE _mpi_libs OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(NOT _mpi_incdirs OR NOT _mpi_libdirs)
message(FATAL_ERROR
"MPI wrapper '${_mpi_cc}' did not return include/lib dirs.\n"
"Check that it supports --showme:incdirs (OpenMPI wrapper required).")
endif()
string(REPLACE " " ";" _mpi_incdirs "${_mpi_incdirs}")
string(REPLACE " " ";" _mpi_libdirs "${_mpi_libdirs}")
string(REPLACE " " ";" _mpi_libs "${_mpi_libs}")
set(_mpi_lib_flags "")
foreach(_l ${_mpi_libs})
list(APPEND _mpi_lib_flags "-l${_l}")
endforeach()
message(STATUS " includes : ${_mpi_incdirs}")
message(STATUS " libdirs : ${_mpi_libdirs}")
message(STATUS " libs : ${_mpi_lib_flags}")
foreach(_tgt MPI::MPI_C MPI::MPI_CXX)
if(NOT TARGET ${_tgt})
add_library(${_tgt} INTERFACE IMPORTED)
endif()
set_target_properties(${_tgt} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_mpi_incdirs}"
INTERFACE_LINK_DIRECTORIES "${_mpi_libdirs}"
INTERFACE_LINK_LIBRARIES "${_mpi_lib_flags}")
endforeach()
else()
find_package(MPI REQUIRED COMPONENTS C CXX)
endif()

# All binaries land in <build>/bin/
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Default to Release so -O3 is active unless the user overrides
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()

option(BLINK_COVERAGE "Build with gcov coverage instrumentation (-O0 --coverage)" OFF)
if(BLINK_COVERAGE)
# -O0 for accurate line attribution; atomic counter updates so the multiple
# concurrent MPI ranks of a single benchmark binary don't corrupt the shared
# .gcda files when they dump coverage on exit.
add_compile_options(-O0 -g --coverage -fprofile-update=atomic)
add_link_options(--coverage)
else()
add_compile_options(-O3)
endif()
add_compile_definitions(_GNU_SOURCE)

add_subdirectory(src)

option(BLINK_TESTS "Build correctness tests (requires GTest)" ON)

if(BLINK_TESTS)
find_package(GTest QUIET)
if(NOT GTest_FOUND)
message(STATUS "GTest not found via find_package — fetching with FetchContent")
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
if(NOT TARGET GTest::GTest)
add_library(GTest::GTest ALIAS gtest)
add_library(GTest::Main ALIAS gtest_main)
endif()
set(GTest_FOUND TRUE)
endif()

if(GTest_FOUND)
enable_testing()
add_subdirectory(tests)
message(STATUS "GTest ready — correctness tests enabled (run: ctest --test-dir build)")
else()
message(WARNING "GTest unavailable — correctness tests skipped (pass -DBLINK_TESTS=OFF to silence)")
endif()
else()
message(STATUS "BLINK_TESTS=OFF — correctness tests skipped")
endif()
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-2026 HLC-Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 0 additions & 34 deletions Makefile

This file was deleted.

Loading
Loading