58 lines
2.9 KiB
CMake
58 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(pqc-bench C)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
# ── Compiler flags ──────────────────────────────────────────────────────────
|
|
# Release build with full optimization; override on the command line:
|
|
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -march=native")
|
|
|
|
# ── Algorithm root (submodule) ───────────────────────────────────────────────
|
|
# Each target below compiles a variant of test_speed.c against a specific
|
|
# algorithm build. Add algorithm libraries as submodule CMake subdirectories
|
|
# or via add_library() here as the project grows.
|
|
#
|
|
# Example layout once kyber submodule is added:
|
|
# algorithms/kyber/ref/ → static lib kyber512_ref, kyber768_ref, kyber1024_ref
|
|
# algorithms/kyber/avx2/ → static lib kyber512_avx2, ...
|
|
|
|
# ── Harness source ───────────────────────────────────────────────────────────
|
|
set(HARNESS_SRC src/test_speed.c)
|
|
|
|
# ── Build variants ───────────────────────────────────────────────────────────
|
|
# Uncomment and adjust as algorithm libraries become available.
|
|
#
|
|
# foreach(PARAM 512 768 1024)
|
|
# foreach(VARIANT ref refnv)
|
|
# set(TARGET "bench_mlkem${PARAM}_${VARIANT}")
|
|
# add_executable(${TARGET} ${HARNESS_SRC})
|
|
# target_include_directories(${TARGET} PRIVATE
|
|
# ${CMAKE_SOURCE_DIR}/../algorithms/kyber/${VARIANT})
|
|
# target_link_libraries(${TARGET} kyber${PARAM}_${VARIANT})
|
|
# target_compile_definitions(${TARGET} PRIVATE KYBER_K=${PARAM})
|
|
# endforeach()
|
|
# endforeach()
|
|
|
|
# ── PAPI (hardware performance counters) ─────────────────────────────────────
|
|
# Optional; enable with -DWITH_PAPI=ON
|
|
option(WITH_PAPI "Link against PAPI for hardware counter collection" OFF)
|
|
if(WITH_PAPI)
|
|
find_library(PAPI_LIB papi REQUIRED)
|
|
find_path(PAPI_INCLUDE papi.h REQUIRED)
|
|
# Targets that need PAPI:
|
|
# target_include_directories(<target> PRIVATE ${PAPI_INCLUDE})
|
|
# target_link_libraries(<target> ${PAPI_LIB})
|
|
endif()
|
|
|
|
# ── RAPL energy measurement ──────────────────────────────────────────────────
|
|
# Optional; enable with -DWITH_RAPL=ON (requires root or CAP_SYS_RAWIO)
|
|
option(WITH_RAPL "Enable Intel RAPL energy measurement" OFF)
|
|
if(WITH_RAPL)
|
|
# target_compile_definitions(<target> PRIVATE WITH_RAPL)
|
|
endif()
|