Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
91ea078
initial roadmap for codes refactoring
caitlinross Jun 8, 2026
e6a2d9e
update refactor roadmap
caitlinross Jun 22, 2026
268170f
ci: add mac build
caitlinross Jun 22, 2026
5d9ef37
cmake: set c++17 and turn off compiler extensions for portability
caitlinross Jun 22, 2026
2c1b934
cmake: modernize find_package(mpi)
caitlinross Jun 22, 2026
94ecfd1
cmake: find_package(ROSS)
caitlinross Jun 22, 2026
466868b
cmake: make the codes build target-based
caitlinross Jun 22, 2026
303cb44
cmake: improve options for finding and using dependencies
caitlinross Jun 23, 2026
e3e5604
Move optional-feature flags into a namespaced codes_config.h
caitlinross Jun 23, 2026
d476cd1
cmake: drop damaris build support, keep inert c paths for now
caitlinross Jun 23, 2026
11a54d9
Export a codesConfig.cmake package with a codes::codes target
caitlinross Jun 23, 2026
c64953f
ci: mpich and openmpi builds
caitlinross Jun 23, 2026
50227d6
ci: add older ubuntu build
caitlinross Jun 23, 2026
42a31f5
ci: add clang build to linux build
caitlinross Jun 23, 2026
b34d279
cmake/ci: add codecov support for coverage testing
caitlinross Jun 23, 2026
4146dab
cmake fix
caitlinross Jun 25, 2026
ce51b22
cmake: link the zmqml requester PUBLIC on codes so all consumers reso…
caitlinross Jun 25, 2026
fe907d1
ci: add the full heavy-deps CODES build job
caitlinross Jun 25, 2026
147e3ca
rename .C sources to .cxx
caitlinross Jun 25, 2026
3230eec
cmake: build the zmqml requester + demo as CMake targets, drop the si…
caitlinross Jun 26, 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
330 changes: 304 additions & 26 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# when paths are passed explicitly (as `find ... -exec` does).
run: |
find src codes doc tests \
-type f \( -name "*.c" -o -name "*.h" -o -name "*.C" \
-type f \( -name "*.c" -o -name "*.h" \
-o -name "*.cpp" -o -name "*.hpp" -o -name "*.cxx" \) \
-not -path 'src/modelconfig/configlex.*' \
-not -path 'src/modelconfig/configparser.*' \
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
/maint/codes.pc
/test-driver
.deps
src/surrogate/zmqml/demozmqmlrequester
src/surrogate/zmqml/libzmqmlrequester.so

# make generated artifacts
.dirstamp
Expand Down
272 changes: 176 additions & 96 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,139 +6,219 @@ project(codes LANGUAGES C CXX VERSION 2.0)
include(CMakePrintHelpers)
cmake_print_variables(CMAKE_CURRENT_SOURCE_DIR)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/cmake/")
cmake_print_variables(CMAKE_MODULE_PATH)

set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}" CACHE PATH "Where to install CODES")

set(CMAKE_CXX_STANDARD 11)
# C++17 is the project-wide baseline (was previously only enabled when Torch
# was found). Required, no compiler extensions, so the build is portable
# across gcc/clang/AppleClang.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)

# Build CODES's own targets with -Wundef so the generated config-header feature
# macros (CODES_HAVE_<X>, always 0/1 — see codes_config.h.cmake.in) flag a
# forgotten `#include "codes_config.h"` or a typo'd name as a warning instead of
# a silently-disabled feature. Applies only to this project's compiles, not to
# consumers; ROSS/MPI headers arrive via -isystem and are exempt.
add_compile_options(-Wundef)

# Optional gcov/--coverage instrumentation, applied to the `codes` target (and
# propagated to the binaries/tests that link it) in src/CMakeLists.txt. Off by
# default; the coverage CI job turns it on. gcc/clang only.
option(CODES_ENABLE_COVERAGE "Instrument the codes library with --coverage (gcov)" OFF)

#prevent cmake from stripping the runtime path (important if shared libraries are imported)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(ROSS_PKG_CONFIG_PATH "" CACHE PATH "Where is ROSS PKG_CONFIG is installed?")
set(SWM_PKG_CONFIG_PATH "" CACHE PATH "Where is the SWM PKG_CONFIG installed?")
set(UNION_PKG_CONFIG_PATH "" CACHE PATH "Where is the Union PKG_CONFIG installed?")
set(ARGOBOTS_PKG_CONFIG_PATH "" CACHE PATH "Where is argobots PKG_COPNFIG installed? Necessary for SWM")
set(DAMARIS_PKG_CONFIG_PATH "" CACHE PATH "Where is the damaris PKG_CONFIG installed?")


# ROSS — modern CMake-config discovery. find_package(ROSS) resolves
# <prefix>/lib/cmake/ROSS/ROSSConfig.cmake; point CMAKE_PREFIX_PATH at the
# ROSS install prefix. The ROSS::ROSS imported target carries the include
# dirs, the MPI dependency, and link libraries (linked in src/CMakeLists.txt).
find_package(ROSS CONFIG REQUIRED)

# PkgConfig still discovers the optional SWM/UNION/ARGOBOTS deps below
# (modernized to imported targets in a later step); their *_PKG_CONFIG_PATH
# cache vars feed PKG_CONFIG_PATH here.
find_package(PkgConfig REQUIRED)
set(ENV{PKG_CONFIG_PATH} "${ROSS_PKG_CONFIG_PATH}:${SWM_PKG_CONFIG_PATH}:${UNION_PKG_CONFIG_PATH}:${ARGOBOTS_PKG_CONFIG_PATH}")
pkg_check_modules(ROSS REQUIRED IMPORTED_TARGET ross)

# MPI
include(SetupMPI)
if(MPI_C_FOUND)
include_directories(${MPI_C_INCLUDE_PATH})
list(APPEND CODES_EXTERNAL_LIBS ${MPI_C_LIBRARIES})
else(MPI_C_FOUND)
message("WARNING: Could not find MPI!")
message(" Either add an MPI compiler to your path (using modules)")
message(" Or force CMake to build using the correct compiler (`export CC=mpicc`)")
endif(MPI_C_FOUND)


## DUMPI
set(ENV{PKG_CONFIG_PATH} "${SWM_PKG_CONFIG_PATH}:${UNION_PKG_CONFIG_PATH}:${ARGOBOTS_PKG_CONFIG_PATH}")

# MPI — modern imported-target discovery. find_package(MPI) provides the
# MPI::MPI_C / MPI::MPI_CXX imported targets, which carry the include dirs,
# compile flags, and link libraries; targets link them directly (see
# src/CMakeLists.txt). No need to set CC=mpicc — FindMPI locates the wrapper
# compiler automatically and derives the flags from it.
find_package(MPI REQUIRED)


# ============================================================================
# Optional dependencies — tri-state CODES_USE_<X> (AUTO / ON / OFF)
# ----------------------------------------------------------------------------
# AUTO : probe; enable if found, disable quietly if not.
# ON : probe; hard error if not found.
# OFF : don't probe; feature disabled.
# Each resolves to an internal USE_<X> bool (names unchanged) consumed by
# src/CMakeLists.txt and the C sources' #if sites.
# ============================================================================

set(DUMPI_BUILD_PATH "" CACHE PATH "Directory where dumpi include and lib are installed")
find_library(DUMPI_LIB undumpi PATHS ${DUMPI_BUILD_PATH}/lib)
if(NOT DUMPI_LIB)
message(STATUS "Undumpi library not found, DUMPI trace workloads disabled")
unset(USE_DUMPI)
else(DUMPI_LIB)
message(STATUS "Undumpi library found ${DUMPI_LIB}")
set(DUMPI_INCLUDE "${DUMPI_BUILD_PATH}/include" CACHE PATH "Dumpi library include")
set(DUMPI_CFLAGS "-I${DUMPI_INCLUDE}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DUMPI_CFLAGS}")
add_definitions(-DUSE_DUMPI=1)
set(USE_DUMPI true)
endif()

# SWM and UNION (both require ARGOBOTS to function)
pkg_check_modules(SWM IMPORTED_TARGET swm)
if(NOT SWM_FOUND)
message(STATUS "SWM Library Not Found, Online workloads disabled")
set(CODES_USE_DUMPI AUTO CACHE STRING "DUMPI trace workloads (AUTO/ON/OFF)")
set(CODES_USE_SWM AUTO CACHE STRING "SWM online workloads; requires argobots (AUTO/ON/OFF)")
set(CODES_USE_UNION AUTO CACHE STRING "UNION online workloads; implies SWM (AUTO/ON/OFF)")
set(CODES_USE_RECORDER AUTO CACHE STRING "Recorder I/O workload, no external dep (AUTO/ON/OFF)")
set(CODES_USE_TORCH AUTO CACHE STRING "Torch ML models (AUTO/ON/OFF)")
set(CODES_USE_DARSHAN OFF CACHE STRING "Darshan I/O workload — not yet wired (AUTO/ON/OFF)")
set(CODES_USE_ZEROMQ AUTO CACHE STRING "ZeroMQ director-client/zmqml surrogate; needs libzmq + zmq.hpp + rapidjson (AUTO/ON/OFF)")
foreach(_dep DUMPI SWM UNION RECORDER TORCH DARSHAN ZEROMQ)
set_property(CACHE CODES_USE_${_dep} PROPERTY STRINGS AUTO ON OFF)
endforeach()

# Back-compat: the pre-rename option names map onto CODES_USE_* for one
# deprecation cycle. Remove once downstream invocations have migrated.
foreach(_old TORCH RECORDER)
if(DEFINED USE_${_old})
message(WARNING "USE_${_old} is deprecated; use CODES_USE_${_old} (AUTO/ON/OFF).")
if(USE_${_old})
set(CODES_USE_${_old} ON CACHE STRING "" FORCE)
else()
set(CODES_USE_${_old} OFF CACHE STRING "" FORCE)
endif()
endif()
endforeach()

# Resolve a tri-state CODES_USE_<name> against a probe result (found = a path,
# a *_FOUND var, or a bool). Sets the internal ${out_var} bool in the caller.
function(codes_resolve_dep name found out_var)
if(CODES_USE_${name} STREQUAL "OFF")
set(${out_var} FALSE PARENT_SCOPE)
elseif(found)
set(${out_var} TRUE PARENT_SCOPE)
elseif(CODES_USE_${name} STREQUAL "ON")
message(FATAL_ERROR "CODES_USE_${name}=ON but ${name} could not be found/enabled.")
else()
set(${out_var} FALSE PARENT_SCOPE)
endif()
endfunction()


else(SWM_FOUND)
message(STATUS "SWM Library Found: ${SWM_LIBRARIES}")
pkg_check_modules(ARGOBOTS REQUIRED IMPORTED_TARGET argobots)
if(NOT ARGOBOTS_FOUND)
message(STATUS "Argobots Library Not Found, Online workloads disabled")
## DUMPI — trace workloads
if(NOT CODES_USE_DUMPI STREQUAL "OFF")
find_library(DUMPI_LIB undumpi PATHS ${DUMPI_BUILD_PATH}/lib)
endif()
codes_resolve_dep(DUMPI "${DUMPI_LIB}" USE_DUMPI)
if(USE_DUMPI)
message(STATUS "DUMPI trace workloads enabled (${DUMPI_LIB})")
set(DUMPI_INCLUDE "${DUMPI_BUILD_PATH}/include" CACHE PATH "Dumpi library include")
else()
message(STATUS "DUMPI trace workloads disabled")
endif()

else(ARGOBOTS_FOUND)
message(STATUS "Argobots Library Found: ${ARGOBOTS_LIBRARIES}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGOBOTS_CFLAGS} -I${ARGOBOTS_INCLUDE}")

pkg_get_variable(SWM_DATAROOTDIR swm datarootdir)
cmake_print_variables(SWM_DATAROOTDIR)
## SWM / UNION — online workloads (UNION ⇒ SWM ⇒ argobots)
set(_swm_ok FALSE)
if(NOT CODES_USE_SWM STREQUAL "OFF")
pkg_check_modules(SWM IMPORTED_TARGET swm)
if(SWM_FOUND)
pkg_check_modules(ARGOBOTS IMPORTED_TARGET argobots)
if(ARGOBOTS_FOUND)
set(_swm_ok TRUE)
endif()
endif()
endif()
codes_resolve_dep(SWM "${_swm_ok}" USE_ONLINE)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SWM_CFLAGS} -I${SWM_INCLUDE}")
add_definitions(-DUSE_ONLINE=1)
set(USE_ONLINE true)
if(USE_ONLINE)
message(STATUS "SWM online workloads enabled (${SWM_LIBRARIES})")
pkg_get_variable(SWM_DATAROOTDIR swm datarootdir)

set(_union_found FALSE)
if(NOT CODES_USE_UNION STREQUAL "OFF")
pkg_check_modules(UNION IMPORTED_TARGET union)
if(NOT UNION_FOUND)
message(STATUS "UNION Library Not Found, SWM-only online workloads enabled")
add_definitions(-DUSE_SWM=1)
set(USE_SWM true)
else(UNION_FOUND)
message(STATUS "UNION Library Found: ${UNION_LIBRARIES}")
pkg_get_variable(UNION_DATAROOTDIR union datarootdir)
cmake_print_variables(UNION_DATAROOTDIR)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${UNION_INCLUDE}")
foreach(INCLUDE_OPT ${UNION_CFLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_OPT}")
endforeach()

add_definitions(-DUSE_UNION=1)
set(USE_UNION true)
endif()
set(_union_found ${UNION_FOUND})
endif()
codes_resolve_dep(UNION "${_union_found}" USE_UNION)
if(USE_UNION)
message(STATUS "UNION online workloads enabled (${UNION_LIBRARIES})")
pkg_get_variable(UNION_DATAROOTDIR union datarootdir)
else()
set(USE_SWM TRUE)
endif()
else()
message(STATUS "SWM/UNION online workloads disabled")
if(CODES_USE_UNION STREQUAL "ON")
message(FATAL_ERROR "CODES_USE_UNION=ON requires SWM/online (set CODES_USE_SWM and provide SWM+argobots).")
endif()
endif()


## RECORDER
option(USE_RECORDER "use recorder io workload" ON)
if(USE_RECORDER)
add_definitions(-DUSE_RECORDER=1)
## RECORDER — built-in I/O workload, no external dependency
codes_resolve_dep(RECORDER TRUE USE_RECORDER)


## DARSHAN — stub: the probe + the commented darshan source in src/ aren't
## wired up yet, so this resolves OFF today (CODES_USE_DARSHAN=ON errors).
codes_resolve_dep(DARSHAN FALSE USE_DARSHAN)


## TORCH — ML models
if(NOT CODES_USE_TORCH STREQUAL "OFF")
find_package(Torch QUIET)
endif()
codes_resolve_dep(TORCH "${Torch_FOUND}" USE_TORCH)
if(USE_TORCH)
message(STATUS "Torch ML models enabled")
else()
message(STATUS "Torch ML models disabled")
endif()

## DARSHAN


## DAMARIS
# pkg_check_modules(DAMARIS IMPORTED_TARGET)
# if(NOT DAMARIS_FOUND)
# message(STATUS "DAMARIS Library not found, Damaris disabled")
# else(DAMARIS_FOUND)
# set(USE_DAMARIS true)
# endif()

## TORCH loading ML models
if((NOT DEFINED USE_TORCH) OR USE_TORCH)
find_package(Torch)
if(Torch_FOUND)
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DUSE_TORCH)
set(USE_TORCH true)
message(STATUS "Loading TORCH models enabled.")
else()
set(USE_TORCH false)
message(STATUS "Torch library not found. Loading TORCH models disabled.")

## ZeroMQ — director-client / zmqml surrogate (the CLIENT half; the ML server is
## a separate process reached over a socket). The requester needs the libzmq C++
## binding (zmq.hpp) and the header-only rapidjson, both build-time only. AUTO-
## probed like the other optional deps; the requester target + linkage live in
## src/surrogate/zmqml + src/CMakeLists.txt, gated on the internal USE_ZEROMQ bool.
set(_zeromq_found FALSE)
if(NOT CODES_USE_ZEROMQ STREQUAL "OFF")
pkg_check_modules(ZeroMQ IMPORTED_TARGET libzmq)
# zmq.hpp (cppzmq) ships with libzmq-dev on some distros, separately on others.
find_path(ZMQ_CPP_INCLUDE_DIR zmq.hpp HINTS ${ZeroMQ_INCLUDE_DIRS})
find_path(RapidJSON_INCLUDE_DIR rapidjson/document.h)
if(ZeroMQ_FOUND AND ZMQ_CPP_INCLUDE_DIR AND RapidJSON_INCLUDE_DIR)
set(_zeromq_found TRUE)
endif()
endif()
codes_resolve_dep(ZEROMQ "${_zeromq_found}" USE_ZEROMQ)
if(USE_ZEROMQ)
message(STATUS "ZeroMQ director-client/zmqml surrogate enabled "
"(${ZeroMQ_LIBRARIES}; rapidjson at ${RapidJSON_INCLUDE_DIR})")
else()
message(STATUS "Loading TORCH models NOT enabled.")
message(STATUS "ZeroMQ director-client/zmqml surrogate disabled")
endif()

cmake_print_variables(CMAKE_C_FLAGS)
add_subdirectory(src)


# Feature-availability macros consumed by codes_config.h.cmake.in. CODES_HAVE_<X>
# mirrors the resolved USE_<X> bool; #cmakedefine emits the #define only when set.
# This replaces the old -DUSE_<X> command-line defines: feature state now lives in
# the namespaced, installed codes_config.h instead of leaking onto compile lines.
set(CODES_HAVE_DUMPI ${USE_DUMPI})
set(CODES_HAVE_ONLINE ${USE_ONLINE})
set(CODES_HAVE_SWM ${USE_SWM})
set(CODES_HAVE_UNION ${USE_UNION})
set(CODES_HAVE_RECORDER ${USE_RECORDER})
set(CODES_HAVE_TORCH ${USE_TORCH})
set(CODES_HAVE_ZEROMQ ${USE_ZEROMQ})
set(CODES_HAVE_DARSHAN ${USE_DARSHAN})

configure_file(codes_config.h.cmake.in codes_config.h)

add_subdirectory(doc/example)
Expand Down
Loading
Loading