From 443dbf696b15e06c0b2e16862a1e53de47673d00 Mon Sep 17 00:00:00 2001 From: kox13 Date: Wed, 8 Apr 2026 19:50:17 +0200 Subject: [PATCH 1/8] chore: updated gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 086cdb0..5a4f128 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ bin/ .cache/ compile_commands.json +source/server/generated +*.code-workspace + +.clang-format \ No newline at end of file From 43ebe9907d7569591ccb6abacae8eb1fe69dc626 Mon Sep 17 00:00:00 2001 From: kox13 Date: Wed, 8 Apr 2026 20:27:44 +0200 Subject: [PATCH 2/8] refactor: refactored project structure --- .gitignore | 2 +- CMakeLists.txt | 79 ----------- source/agent/CMakeLists.txt | 59 -------- sources/agent/CMakeLists.txt | 126 ++++++++++++++++++ .../agent/CMakePresets.json | 2 +- {source => sources}/agent/README.md | 0 agent.conf => sources/agent/agent.conf | 0 .../agent/libs}/include/nvidia/nvml.h | 0 .../agent/libs}/stubs/nvml_stub.cc | 0 .../agent/src/collectors/collector.h | 0 .../agent/src/collectors/nvml_collector.cc | 0 .../agent/src/collectors/nvml_collector.h | 0 .../src/collectors/proc_stat_collector.cc | 0 .../src/collectors/proc_stat_collector.h | 0 .../agent/src/collectors/ram_collector.cc | 0 .../agent/src/collectors/ram_collector.h | 0 {source => sources}/agent/src/config/config.h | 0 .../agent/src/config/config_loader.cc | 0 .../agent/src/config/config_loader.h | 0 {source => sources}/agent/src/main.cc | 0 {source => sources}/agent/src/metric.h | 0 .../agent/src/platform/cpu_info.h | 0 .../agent/src/platform/gpu_info.h | 0 .../agent/src/platform/hardware_info.h | 0 .../agent/src/platform/platform_detector.cc | 0 .../agent/src/platform/platform_detector.h | 0 {source => sources}/agent/src/scheduler.cc | 0 {source => sources}/agent/src/scheduler.h | 0 {source => sources}/agent/src/utils/utils.cc | 0 {source => sources}/agent/src/utils/utils.h | 0 vcpkg.json => sources/agent/vcpkg.json | 0 {source => sources}/dashboard/README.md | 0 {libs => sources}/proto/volta.proto | 0 {source => sources}/server/README.md | 0 34 files changed, 128 insertions(+), 140 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 source/agent/CMakeLists.txt create mode 100644 sources/agent/CMakeLists.txt rename CMakePresets.json => sources/agent/CMakePresets.json (99%) rename {source => sources}/agent/README.md (100%) rename agent.conf => sources/agent/agent.conf (100%) rename {libs => sources/agent/libs}/include/nvidia/nvml.h (100%) rename {libs => sources/agent/libs}/stubs/nvml_stub.cc (100%) rename {source => sources}/agent/src/collectors/collector.h (100%) rename {source => sources}/agent/src/collectors/nvml_collector.cc (100%) rename {source => sources}/agent/src/collectors/nvml_collector.h (100%) rename {source => sources}/agent/src/collectors/proc_stat_collector.cc (100%) rename {source => sources}/agent/src/collectors/proc_stat_collector.h (100%) rename {source => sources}/agent/src/collectors/ram_collector.cc (100%) rename {source => sources}/agent/src/collectors/ram_collector.h (100%) rename {source => sources}/agent/src/config/config.h (100%) rename {source => sources}/agent/src/config/config_loader.cc (100%) rename {source => sources}/agent/src/config/config_loader.h (100%) rename {source => sources}/agent/src/main.cc (100%) rename {source => sources}/agent/src/metric.h (100%) rename {source => sources}/agent/src/platform/cpu_info.h (100%) rename {source => sources}/agent/src/platform/gpu_info.h (100%) rename {source => sources}/agent/src/platform/hardware_info.h (100%) rename {source => sources}/agent/src/platform/platform_detector.cc (100%) rename {source => sources}/agent/src/platform/platform_detector.h (100%) rename {source => sources}/agent/src/scheduler.cc (100%) rename {source => sources}/agent/src/scheduler.h (100%) rename {source => sources}/agent/src/utils/utils.cc (100%) rename {source => sources}/agent/src/utils/utils.h (100%) rename vcpkg.json => sources/agent/vcpkg.json (100%) rename {source => sources}/dashboard/README.md (100%) rename {libs => sources}/proto/volta.proto (100%) rename {source => sources}/server/README.md (100%) diff --git a/.gitignore b/.gitignore index 5a4f128..ecbbd54 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ bin/ .cache/ compile_commands.json -source/server/generated +sources/server/generated/ *.code-workspace .clang-format \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 9fc5327..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(volta LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -find_package(protobuf CONFIG REQUIRED) -find_package(gRPC CONFIG REQUIRED) -find_package(fmt CONFIG REQUIRED) -find_package(tomlplusplus CONFIG REQUIRED) - -set(PROTO_DIR ${CMAKE_SOURCE_DIR}/libs/proto) -set(PROTO_FILE ${PROTO_DIR}/volta.proto) -set(LOCAL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/libs/include") - -get_target_property(GRPC_CPP_PLUGIN gRPC::grpc_cpp_plugin LOCATION) - -set(PROTO_SRC "${CMAKE_CURRENT_BINARY_DIR}/volta.pb.cc") -set(PROTO_HDR "${CMAKE_CURRENT_BINARY_DIR}/volta.pb.h") -set(GRPC_SRC "${CMAKE_CURRENT_BINARY_DIR}/volta.grpc.pb.cc") -set(GRPC_HDR "${CMAKE_CURRENT_BINARY_DIR}/volta.grpc.pb.h") - -add_custom_command( - OUTPUT "${PROTO_SRC}" "${PROTO_HDR}" "${GRPC_SRC}" "${GRPC_HDR}" - - COMMAND protobuf::protoc - - ARGS --cpp_out="${CMAKE_CURRENT_BINARY_DIR}" - --grpc_out="${CMAKE_CURRENT_BINARY_DIR}" - --plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}" - -I "${PROTO_DIR}" - "${PROTO_FILE}" - - DEPENDS "${PROTO_FILE}" gRPC::grpc_cpp_plugin - COMMENT "Generating C++ code from volta.proto..." -) - -add_library(volta_proto ${PROTO_SRC} ${PROTO_HDR} ${GRPC_SRC} ${GRPC_HDR}) - -target_include_directories(volta_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) - -target_link_libraries(volta_proto PRIVATE - protobuf::libprotobuf - gRPC::grpc++ - gRPC::grpc++_reflection - fmt::fmt - tomlplusplus::tomlplusplus - ${CMAKE_DL_LIBS} -) - -include_directories("${LOCAL_INCLUDE_DIR}/nvidia") - -add_subdirectory(source/agent) -#add_subdirectory(source/server) - -# --- Custom Tools Targets --- -find_program(CLANG_FORMAT_EXE clang-format) - -if(CLANG_FORMAT_EXE) - # clang-format - add_custom_target(format - COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} -i -style=Google - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMENT "Running clang-format on source files..." - VERBATIM - ) - - # optional: check formatting - add_custom_target(check-format - COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror -style=Google - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMENT "Checking code formatting..." - VERBATIM - ) -else() - message(WARNING "clang-format not found! 'make format' will not be available.") -endif() diff --git a/source/agent/CMakeLists.txt b/source/agent/CMakeLists.txt deleted file mode 100644 index bb23533..0000000 --- a/source/agent/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -set(AGENT_NAME volta_agent) -add_executable(${AGENT_NAME}) - -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - message(STATUS "Debug build - adding DEBUG macro") - target_compile_definitions(${AGENT_NAME} PRIVATE DEBUG) -endif() - -file(GLOB_RECURSE AGENT_SOURCES "src/*.cc") -target_sources(${AGENT_NAME} PRIVATE ${AGENT_SOURCES}) - -target_include_directories(${AGENT_NAME} PRIVATE src) - -target_link_libraries(${AGENT_NAME} PRIVATE volta_proto) - -find_package(Threads REQUIRED) -find_package(Protobuf REQUIRED) -find_package(gRPC REQUIRED) -find_package(tomlplusplus REQUIRED) - -target_link_libraries(${AGENT_NAME} PRIVATE - Threads::Threads - gRPC::grpc++ - protobuf::libprotobuf - tomlplusplus::tomlplusplus -) - -find_path(NVML_INCLUDE_DIR nvml.h - PATHS ${CMAKE_SOURCE_DIR}/libs/include/nvidia - /usr/include - /usr/local/cuda/include -) - -find_library(NVML_LIBRARY NAMES nvidia-ml nvml - PATHS /usr/lib /usr/lib64 /usr/local/lib -) - -if(NVML_INCLUDE_DIR AND NVML_LIBRARY) - message(STATUS "Found Real NVML: ${NVML_LIBRARY}") - target_include_directories(${AGENT_NAME} PRIVATE ${NVML_INCLUDE_DIR}) - target_link_libraries(${AGENT_NAME} PRIVATE ${NVML_LIBRARY}) - target_compile_definitions(${AGENT_NAME} PRIVATE HAVE_NVML) -else() - message(STATUS "NVML library not found. Using STUB for compilation.") - add_library(nvml_stub STATIC ${CMAKE_SOURCE_DIR}/libs/stubs/nvml_stub.cc) - target_include_directories(nvml_stub PRIVATE ${CMAKE_SOURCE_DIR}/libs/include/nvidia) - target_link_libraries(${AGENT_NAME} PRIVATE nvml_stub) - target_compile_definitions(${AGENT_NAME} PRIVATE HAVE_NVML) - target_include_directories(${AGENT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/libs/include/nvidia) -endif() - -configure_file( - ${CMAKE_SOURCE_DIR}/agent.conf - ${CMAKE_CURRENT_BINARY_DIR}/agent.conf - COPYONLY -) - -# 5. TODO: find rocm_smi and oneapi level_zero -# 6. TODO: find PMU (libpfm) diff --git a/sources/agent/CMakeLists.txt b/sources/agent/CMakeLists.txt new file mode 100644 index 0000000..3cdf26c --- /dev/null +++ b/sources/agent/CMakeLists.txt @@ -0,0 +1,126 @@ +cmake_minimum_required(VERSION 3.16) + +project(volta_agent LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# --- Dependencies --- +find_package(protobuf CONFIG REQUIRED) +find_package(gRPC CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) +find_package(tomlplusplus CONFIG REQUIRED) +find_package(Threads REQUIRED) + +# --- Proto / gRPC code generation --- +set(PROTO_DIR ${CMAKE_SOURCE_DIR}/../proto) +set(PROTO_FILE ${PROTO_DIR}/volta.proto) + +get_target_property(GRPC_CPP_PLUGIN gRPC::grpc_cpp_plugin LOCATION) + +set(PROTO_SRC "${CMAKE_CURRENT_BINARY_DIR}/volta.pb.cc") +set(PROTO_HDR "${CMAKE_CURRENT_BINARY_DIR}/volta.pb.h") +set(GRPC_SRC "${CMAKE_CURRENT_BINARY_DIR}/volta.grpc.pb.cc") +set(GRPC_HDR "${CMAKE_CURRENT_BINARY_DIR}/volta.grpc.pb.h") + +add_custom_command( + OUTPUT "${PROTO_SRC}" "${PROTO_HDR}" "${GRPC_SRC}" "${GRPC_HDR}" + COMMAND protobuf::protoc + ARGS --cpp_out="${CMAKE_CURRENT_BINARY_DIR}" + --grpc_out="${CMAKE_CURRENT_BINARY_DIR}" + --plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}" + -I "${PROTO_DIR}" + "${PROTO_FILE}" + DEPENDS "${PROTO_FILE}" gRPC::grpc_cpp_plugin + COMMENT "Generating C++ code from volta.proto..." +) + +add_library(volta_proto STATIC ${PROTO_SRC} ${PROTO_HDR} ${GRPC_SRC} ${GRPC_HDR}) + +target_include_directories(volta_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(volta_proto PUBLIC + protobuf::libprotobuf + gRPC::grpc++ + gRPC::grpc++_reflection +) + +# --- Agent executable --- +add_executable(volta_agent) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + message(STATUS "Debug build - adding DEBUG macro") + target_compile_definitions(volta_agent PRIVATE DEBUG) +endif() + +file(GLOB_RECURSE AGENT_SOURCES "src/*.cc") +target_sources(volta_agent PRIVATE ${AGENT_SOURCES}) + +target_include_directories(volta_agent PRIVATE + src + ${CMAKE_SOURCE_DIR}/libs/include/nvidia +) + +target_link_libraries(volta_agent PRIVATE + volta_proto + Threads::Threads + fmt::fmt + tomlplusplus::tomlplusplus +) + +# --- NVML --- +find_path(NVML_INCLUDE_DIR nvml.h + PATHS + ${CMAKE_SOURCE_DIR}/libs/include/nvidia + /usr/include + /usr/local/cuda/include +) + +find_library(NVML_LIBRARY NAMES nvidia-ml nvml + PATHS /usr/lib /usr/lib64 /usr/local/lib +) + +if(NVML_INCLUDE_DIR AND NVML_LIBRARY) + message(STATUS "Found NVML: ${NVML_LIBRARY}") + target_include_directories(volta_agent PRIVATE ${NVML_INCLUDE_DIR}) + target_link_libraries(volta_agent PRIVATE ${NVML_LIBRARY}) +else() + message(STATUS "NVML not found - using stub") + add_library(nvml_stub STATIC ${CMAKE_SOURCE_DIR}/libs/stubs/nvml_stub.cc) + target_include_directories(nvml_stub PRIVATE ${CMAKE_SOURCE_DIR}/libs/include/nvidia) + target_link_libraries(volta_agent PRIVATE nvml_stub) + target_include_directories(volta_agent PRIVATE ${CMAKE_SOURCE_DIR}/libs/include/nvidia) +endif() + +target_compile_definitions(volta_agent PRIVATE HAVE_NVML) + +# --- Config file --- +configure_file( + ${CMAKE_SOURCE_DIR}/agent.conf + ${CMAKE_CURRENT_BINARY_DIR}/agent.conf + COPYONLY +) + +# --- Formatting --- +find_program(CLANG_FORMAT_EXE clang-format) + +if(CLANG_FORMAT_EXE) + add_custom_target(format + COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} -i -style=Google + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Running clang-format on agent sources..." + VERBATIM + ) + add_custom_target(check-format + COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror -style=Google + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Checking agent source formatting..." + VERBATIM + ) +else() + message(WARNING "clang-format not found - 'make format' unavailable") +endif() + +# TODO: find rocm_smi and oneapi level_zero +# TODO: find PMU (libpfm) \ No newline at end of file diff --git a/CMakePresets.json b/sources/agent/CMakePresets.json similarity index 99% rename from CMakePresets.json rename to sources/agent/CMakePresets.json index 1c408bf..c5fa5b1 100644 --- a/CMakePresets.json +++ b/sources/agent/CMakePresets.json @@ -16,4 +16,4 @@ "configurePreset": "default" } ] -} +} \ No newline at end of file diff --git a/source/agent/README.md b/sources/agent/README.md similarity index 100% rename from source/agent/README.md rename to sources/agent/README.md diff --git a/agent.conf b/sources/agent/agent.conf similarity index 100% rename from agent.conf rename to sources/agent/agent.conf diff --git a/libs/include/nvidia/nvml.h b/sources/agent/libs/include/nvidia/nvml.h similarity index 100% rename from libs/include/nvidia/nvml.h rename to sources/agent/libs/include/nvidia/nvml.h diff --git a/libs/stubs/nvml_stub.cc b/sources/agent/libs/stubs/nvml_stub.cc similarity index 100% rename from libs/stubs/nvml_stub.cc rename to sources/agent/libs/stubs/nvml_stub.cc diff --git a/source/agent/src/collectors/collector.h b/sources/agent/src/collectors/collector.h similarity index 100% rename from source/agent/src/collectors/collector.h rename to sources/agent/src/collectors/collector.h diff --git a/source/agent/src/collectors/nvml_collector.cc b/sources/agent/src/collectors/nvml_collector.cc similarity index 100% rename from source/agent/src/collectors/nvml_collector.cc rename to sources/agent/src/collectors/nvml_collector.cc diff --git a/source/agent/src/collectors/nvml_collector.h b/sources/agent/src/collectors/nvml_collector.h similarity index 100% rename from source/agent/src/collectors/nvml_collector.h rename to sources/agent/src/collectors/nvml_collector.h diff --git a/source/agent/src/collectors/proc_stat_collector.cc b/sources/agent/src/collectors/proc_stat_collector.cc similarity index 100% rename from source/agent/src/collectors/proc_stat_collector.cc rename to sources/agent/src/collectors/proc_stat_collector.cc diff --git a/source/agent/src/collectors/proc_stat_collector.h b/sources/agent/src/collectors/proc_stat_collector.h similarity index 100% rename from source/agent/src/collectors/proc_stat_collector.h rename to sources/agent/src/collectors/proc_stat_collector.h diff --git a/source/agent/src/collectors/ram_collector.cc b/sources/agent/src/collectors/ram_collector.cc similarity index 100% rename from source/agent/src/collectors/ram_collector.cc rename to sources/agent/src/collectors/ram_collector.cc diff --git a/source/agent/src/collectors/ram_collector.h b/sources/agent/src/collectors/ram_collector.h similarity index 100% rename from source/agent/src/collectors/ram_collector.h rename to sources/agent/src/collectors/ram_collector.h diff --git a/source/agent/src/config/config.h b/sources/agent/src/config/config.h similarity index 100% rename from source/agent/src/config/config.h rename to sources/agent/src/config/config.h diff --git a/source/agent/src/config/config_loader.cc b/sources/agent/src/config/config_loader.cc similarity index 100% rename from source/agent/src/config/config_loader.cc rename to sources/agent/src/config/config_loader.cc diff --git a/source/agent/src/config/config_loader.h b/sources/agent/src/config/config_loader.h similarity index 100% rename from source/agent/src/config/config_loader.h rename to sources/agent/src/config/config_loader.h diff --git a/source/agent/src/main.cc b/sources/agent/src/main.cc similarity index 100% rename from source/agent/src/main.cc rename to sources/agent/src/main.cc diff --git a/source/agent/src/metric.h b/sources/agent/src/metric.h similarity index 100% rename from source/agent/src/metric.h rename to sources/agent/src/metric.h diff --git a/source/agent/src/platform/cpu_info.h b/sources/agent/src/platform/cpu_info.h similarity index 100% rename from source/agent/src/platform/cpu_info.h rename to sources/agent/src/platform/cpu_info.h diff --git a/source/agent/src/platform/gpu_info.h b/sources/agent/src/platform/gpu_info.h similarity index 100% rename from source/agent/src/platform/gpu_info.h rename to sources/agent/src/platform/gpu_info.h diff --git a/source/agent/src/platform/hardware_info.h b/sources/agent/src/platform/hardware_info.h similarity index 100% rename from source/agent/src/platform/hardware_info.h rename to sources/agent/src/platform/hardware_info.h diff --git a/source/agent/src/platform/platform_detector.cc b/sources/agent/src/platform/platform_detector.cc similarity index 100% rename from source/agent/src/platform/platform_detector.cc rename to sources/agent/src/platform/platform_detector.cc diff --git a/source/agent/src/platform/platform_detector.h b/sources/agent/src/platform/platform_detector.h similarity index 100% rename from source/agent/src/platform/platform_detector.h rename to sources/agent/src/platform/platform_detector.h diff --git a/source/agent/src/scheduler.cc b/sources/agent/src/scheduler.cc similarity index 100% rename from source/agent/src/scheduler.cc rename to sources/agent/src/scheduler.cc diff --git a/source/agent/src/scheduler.h b/sources/agent/src/scheduler.h similarity index 100% rename from source/agent/src/scheduler.h rename to sources/agent/src/scheduler.h diff --git a/source/agent/src/utils/utils.cc b/sources/agent/src/utils/utils.cc similarity index 100% rename from source/agent/src/utils/utils.cc rename to sources/agent/src/utils/utils.cc diff --git a/source/agent/src/utils/utils.h b/sources/agent/src/utils/utils.h similarity index 100% rename from source/agent/src/utils/utils.h rename to sources/agent/src/utils/utils.h diff --git a/vcpkg.json b/sources/agent/vcpkg.json similarity index 100% rename from vcpkg.json rename to sources/agent/vcpkg.json diff --git a/source/dashboard/README.md b/sources/dashboard/README.md similarity index 100% rename from source/dashboard/README.md rename to sources/dashboard/README.md diff --git a/libs/proto/volta.proto b/sources/proto/volta.proto similarity index 100% rename from libs/proto/volta.proto rename to sources/proto/volta.proto diff --git a/source/server/README.md b/sources/server/README.md similarity index 100% rename from source/server/README.md rename to sources/server/README.md From 6b56d5f30a1b65608fd59ca16bf5d2e6fed24c74 Mon Sep 17 00:00:00 2001 From: kox13 Date: Wed, 8 Apr 2026 21:16:28 +0200 Subject: [PATCH 3/8] chore: agent ci with corrected paths --- .github/workflows/agent_ci.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/agent_ci.yml b/.github/workflows/agent_ci.yml index 15f282e..56a3604 100644 --- a/.github/workflows/agent_ci.yml +++ b/.github/workflows/agent_ci.yml @@ -4,20 +4,20 @@ on: push: branches: [ "main", "devel" ] paths: - - 'source/agent/**' - - 'libs/**' - - 'CMakeLists.txt' - - 'vcpkg.json' - - 'CMakePresets.json' + - 'sources/agent/src/**' + - 'sources/agent/libs/**' + - 'sources/agent/CMakeLists.txt' + - 'sources/agent/vcpkg.json' + - 'sources/agent/CMakePresets.json' - '.github/workflows/agent_ci.yml' pull_request: branches: [ "main", "devel" ] paths: - - 'source/agent/**' - - 'libs/**' - - 'CMakeLists.txt' - - 'vcpkg.json' - - 'CMakePresets.json' + - 'sources/agent/src/**' + - 'sources/agent/libs/**' + - 'sources/agent/CMakeLists.txt' + - 'sources/agent/vcpkg.json' + - 'sources/agent/CMakePresets.json' - '.github/workflows/agent_ci.yml' jobs: @@ -40,16 +40,18 @@ jobs: - name: Setup vcpkg uses: lukka/run-vcpkg@v11 with: - vcpkgJsonGlob: 'vcpkg.json' + vcpkgJsonGlob: 'sources/agent/vcpkg.json' - name: Check Code Formatting run: | - find source/agent -name "*.cc" -o -name "*.h" | xargs clang-format --dry-run --Werror -style=Google + find sources/agent -name "*.cc" -o -name "*.h" | xargs clang-format --dry-run --Werror -style=Google - name: CMake Configure + working-directory: sources/agent run: cmake --preset default - name: Build + working-directory: sources/agent run: cmake --build --preset default - name: Analyze Logic @@ -60,4 +62,4 @@ jobs: --inline-suppr \ --force \ -i build \ - source/agent + sources/agent From 24ec28389b29f66c7928d8db6f78902d8420c0d8 Mon Sep 17 00:00:00 2001 From: kox13 Date: Wed, 8 Apr 2026 21:22:23 +0200 Subject: [PATCH 4/8] chore: updated gitignore --- .gitignore | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ecbbd54..8d39e29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,13 @@ +# --- Shared --- .vscode/ +*.code-workspace +# --- Agent --- build/ -out/ -bin/ - .cache/ compile_commands.json +sources/agent/agent.conf +.clang-format -sources/server/generated/ -*.code-workspace - -.clang-format \ No newline at end of file +# --- Server --- +sources/server/generated/ \ No newline at end of file From 29080549577d04d47ee9efa5467c6fbcbc500ae9 Mon Sep 17 00:00:00 2001 From: kox13 Date: Wed, 8 Apr 2026 21:38:07 +0200 Subject: [PATCH 5/8] build: pre-commit hook for checking formatting, corrected paths on CMakeLists and automatic hook copying when building --- scripts/hooks/pre-commit | 23 +++++++++++++ sources/agent/CMakeLists.txt | 59 +++++++++++++++++++++++++++----- sources/agent/agent.example.conf | 1 + sources/agent/src/main.cc | 2 +- 4 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 scripts/hooks/pre-commit create mode 100644 sources/agent/agent.example.conf diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit new file mode 100644 index 0000000..dd496c6 --- /dev/null +++ b/scripts/hooks/pre-commit @@ -0,0 +1,23 @@ +#!/bin/bash + +REPO_ROOT=$(git rev-parse --show-toplevel) +BUILD_DIR="$REPO_ROOT/sources/agent/build" + +if [ ! -d "$BUILD_DIR" ]; then + echo "Build directory not found: $BUILD_DIR" + echo "Run cmake --preset debug in sources/agent first." + exit 1 +fi + +# Sprawdź tylko pliki staged do commita +STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cc|h)$') + +if [ -z "$STAGED" ]; then + exit 0 +fi + +cmake --build "$BUILD_DIR" --target check-format +if [ $? -ne 0 ]; then + echo "Formatting errors found. Run 'cmake --build $BUILD_DIR --target format' to fix." + exit 1 +fi \ No newline at end of file diff --git a/sources/agent/CMakeLists.txt b/sources/agent/CMakeLists.txt index 3cdf26c..2ead23e 100644 --- a/sources/agent/CMakeLists.txt +++ b/sources/agent/CMakeLists.txt @@ -6,9 +6,13 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13.0") + message(FATAL_ERROR "GCC 13+ required (found ${CMAKE_CXX_COMPILER_VERSION})") +endif() + # --- Dependencies --- -find_package(protobuf CONFIG REQUIRED) find_package(gRPC CONFIG REQUIRED) +find_package(protobuf CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(tomlplusplus CONFIG REQUIRED) find_package(Threads REQUIRED) @@ -49,6 +53,8 @@ target_link_libraries(volta_proto PUBLIC # --- Agent executable --- add_executable(volta_agent) +target_compile_options(volta_agent PRIVATE -std=c++20) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") message(STATUS "Debug build - adding DEBUG macro") target_compile_definitions(volta_agent PRIVATE DEBUG) @@ -96,24 +102,38 @@ endif() target_compile_definitions(volta_agent PRIVATE HAVE_NVML) # --- Config file --- -configure_file( - ${CMAKE_SOURCE_DIR}/agent.conf - ${CMAKE_CURRENT_BINARY_DIR}/agent.conf - COPYONLY -) +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/agent.conf) + if(EXISTS ${CMAKE_SOURCE_DIR}/agent.example.conf) + message(STATUS "agent.conf not found - copying from agent.example.conf") + file(COPY ${CMAKE_SOURCE_DIR}/agent.example.conf + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/agent.example.conf + ${CMAKE_CURRENT_BINARY_DIR}/agent.conf) + else() + message(WARNING "Neither agent.conf nor agent.example.conf found") + endif() +else() + add_custom_command( + TARGET volta_agent POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_SOURCE_DIR}/agent.conf + ${CMAKE_CURRENT_BINARY_DIR}/agent.conf + COMMENT "Copying agent.conf..." + ) +endif() # --- Formatting --- find_program(CLANG_FORMAT_EXE clang-format) if(CLANG_FORMAT_EXE) add_custom_target(format - COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} -i -style=Google + COMMAND find src -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} -i -style=Google WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Running clang-format on agent sources..." VERBATIM ) add_custom_target(check-format - COMMAND find source/agent -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror -style=Google + COMMAND find src -name "*.cc" -o -name "*.h" | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror -style=Google WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Checking agent source formatting..." VERBATIM @@ -123,4 +143,25 @@ else() endif() # TODO: find rocm_smi and oneapi level_zero -# TODO: find PMU (libpfm) \ No newline at end of file +# TODO: find PMU (libpfm) + +# --- Scripts --- +find_program(GIT_EXE git) +if(GIT_EXE) + execute_process( + COMMAND ${GIT_EXE} rev-parse --show-toplevel + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(EXISTS ${GIT_ROOT}/.git) + configure_file( + ${GIT_ROOT}/scripts/hooks/pre-commit + ${GIT_ROOT}/.git/hooks/pre-commit + COPYONLY + ) + file(CHMOD ${GIT_ROOT}/.git/hooks/pre-commit + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) + message(STATUS "Git pre-commit hook installed") + endif() +endif() \ No newline at end of file diff --git a/sources/agent/agent.example.conf b/sources/agent/agent.example.conf new file mode 100644 index 0000000..a80c3bc --- /dev/null +++ b/sources/agent/agent.example.conf @@ -0,0 +1 @@ +core_affinity = [2, "3-10"] diff --git a/sources/agent/src/main.cc b/sources/agent/src/main.cc index e44c31e..09b6424 100644 --- a/sources/agent/src/main.cc +++ b/sources/agent/src/main.cc @@ -44,7 +44,7 @@ int main() { scheduler.Run(); } catch (const std::exception& e) { - std::cerr << "CRITICAL ERROR: " << e.what() << std::endl; + // std::cerr << "CRITICAL ERROR: " << e.what() << std::endl; return 1; } return 0; From a8d0abbb6ca4b9dfe6e65f358cd6506e5ef669ef Mon Sep 17 00:00:00 2001 From: kox13 Date: Thu, 9 Apr 2026 14:43:36 +0200 Subject: [PATCH 6/8] chore: delete agent.conf file from the repository --- sources/agent/agent.conf | 1 - 1 file changed, 1 deletion(-) delete mode 100644 sources/agent/agent.conf diff --git a/sources/agent/agent.conf b/sources/agent/agent.conf deleted file mode 100644 index a80c3bc..0000000 --- a/sources/agent/agent.conf +++ /dev/null @@ -1 +0,0 @@ -core_affinity = [2, "3-10"] From 96a3b62aa8cb3d042eba3f44b930925c1b2d9b76 Mon Sep 17 00:00:00 2001 From: kox13 Date: Thu, 9 Apr 2026 16:15:26 +0200 Subject: [PATCH 7/8] ci: improved ci process with vcpkg cache and setup-cpp image --- .github/workflows/agent_ci.yml | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/agent_ci.yml b/.github/workflows/agent_ci.yml index 56a3604..e06bc4f 100644 --- a/.github/workflows/agent_ci.yml +++ b/.github/workflows/agent_ci.yml @@ -2,22 +2,14 @@ name: Agent CI on: push: - branches: [ "main", "devel" ] + branches: [ "main", "devel", "test/workflow" ] paths: - - 'sources/agent/src/**' - - 'sources/agent/libs/**' - - 'sources/agent/CMakeLists.txt' - - 'sources/agent/vcpkg.json' - - 'sources/agent/CMakePresets.json' + - 'sources/agent/' - '.github/workflows/agent_ci.yml' pull_request: branches: [ "main", "devel" ] paths: - - 'sources/agent/src/**' - - 'sources/agent/libs/**' - - 'sources/agent/CMakeLists.txt' - - 'sources/agent/vcpkg.json' - - 'sources/agent/CMakePresets.json' + - 'sources/agent/' - '.github/workflows/agent_ci.yml' jobs: @@ -31,11 +23,19 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup C++ tools + uses: aminya/setup-cpp@v1 + with: + clang-format: true + cppcheck: true - - name: Install build tools - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake clang-format cppcheck + - name: Cache vcpkg + uses: actions/cache@v4 + with: + path: | + ~/.cache/vcpkg + sources/agent/build/vcpkg_installed + key: vcpkg-${{ runner.os }}-${{ hashFiles('sources/agent/vcpkg.json') }} - name: Setup vcpkg uses: lukka/run-vcpkg@v11 @@ -44,15 +44,15 @@ jobs: - name: Check Code Formatting run: | - find sources/agent -name "*.cc" -o -name "*.h" | xargs clang-format --dry-run --Werror -style=Google + find sources/agent/src -name "*.cc" -o -name "*.h" | xargs clang-format --dry-run --Werror -style=Google - name: CMake Configure working-directory: sources/agent - run: cmake --preset default + run: cmake --preset default -DCMAKE_BUILD_TYPE=Release - name: Build working-directory: sources/agent - run: cmake --build --preset default + run: cmake --build --preset default -j$(nproc) - name: Analyze Logic run: | @@ -61,5 +61,5 @@ jobs: --suppress=missingIncludeSystem \ --inline-suppr \ --force \ - -i build \ - sources/agent + -i sources/agent/build \ + sources/agent \ No newline at end of file From 57f823c40f846d9f1cd48eb51689eecabb95287f Mon Sep 17 00:00:00 2001 From: kox13 Date: Thu, 9 Apr 2026 16:16:11 +0200 Subject: [PATCH 8/8] chore: delete test branch from ci file --- .github/workflows/agent_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/agent_ci.yml b/.github/workflows/agent_ci.yml index e06bc4f..9272a78 100644 --- a/.github/workflows/agent_ci.yml +++ b/.github/workflows/agent_ci.yml @@ -2,7 +2,7 @@ name: Agent CI on: push: - branches: [ "main", "devel", "test/workflow" ] + branches: [ "main", "devel" ] paths: - 'sources/agent/' - '.github/workflows/agent_ci.yml'