-
Notifications
You must be signed in to change notification settings - Fork 2
Modernize ITLabAI CMake build, externals, and CI/test data handling for multi‑config builds #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 50 commits
a82b43f
481a688
3749b9f
6d64a63
ab529f9
70b4db8
b509f49
886750f
3187625
09722f1
5777222
6e96609
9513353
8fdff9c
098a95c
3256e78
2ed8dbc
521f06d
d1639aa
8e24def
195d89d
4dce952
f5ac779
667537b
78c1204
1346a68
c4e0adc
2bef137
06bf5db
e501f2e
ea94ea0
4021267
4bc9639
851d617
f2a4802
1e7bb37
756d1cf
91d43d8
2c7a564
c008bc6
7807116
f89621b
483dacf
2ddaa75
09e3ed9
e6c49b5
f596e65
90b3f63
647a2d0
ee494d3
371e8be
4ff4b5f
013421c
54f8d9a
b66c92b
7058586
236dc9a
55726a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,15 @@ jobs: | |
| strategy: | ||
| matrix: | ||
| include: | ||
| - build_type: DEBUG | ||
| - build_type: RELEASE | ||
| stats: false | ||
| - build_type: RELEASE | ||
| stats: true | ||
| - preset: dev-debug | ||
| build_dir: build/debug | ||
| artifact_name: DEBUG | ||
| - preset: dev-release | ||
| build_dir: build/release | ||
| artifact_name: RELEASE | ||
| - preset: ci-stats | ||
| build_dir: build/ci-stats | ||
| artifact_name: RELEASE-stats | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
@@ -32,48 +36,41 @@ jobs: | |
| - name: Set binary paths | ||
| id: set_binaries | ||
| run: | | ||
| echo "ACC_BINARY=build/bin/ACC" >> $GITHUB_OUTPUT | ||
| echo "ACC_BINARY=${{ matrix.build_dir }}/bin/itlabai_acc" >> $GITHUB_OUTPUT | ||
| - name: Setup ccache | ||
| uses: hendrikmuhs/ccache-action@v1.2 | ||
| with: | ||
| key: ccache-${{ github.job }}-${{ matrix.build_type }} | ||
| key: ccache-${{ github.job }}-${{ matrix.preset }} | ||
| max-size: 2G | ||
| - name: Build | ||
| run: | | ||
| cmake -S . -B build -G Ninja \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | ||
| -DOPENCV_PATH=build/3rdparty/opencv_build \ | ||
| ${{ matrix.stats && '-DENABLE_STATISTIC_TENSORS=ON' || '' }} \ | ||
| ${{ matrix.stats && '-DENABLE_STATISTIC_TIME=ON' || '' }} \ | ||
| ${{ matrix.stats && '-DENABLE_STATISTIC_WEIGHTS=ON' || '' }} | ||
| cmake --build build --parallel | ||
| cmake --preset ${{ matrix.preset }} \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| cmake --build --preset ${{ matrix.preset }} --parallel | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| - name: Prepare ALL libs | ||
| run: | | ||
| mkdir -p build/bin/all_libs | ||
| cp -a build/3rdparty/opencv_build/lib/* build/bin/all_libs/ 2>/dev/null || true | ||
| ldd build/bin/ACC | grep "=> /" | awk '{print $3}' | xargs -I {} cp {} build/bin/all_libs/ 2>/dev/null || true | ||
| mkdir -p ${{ matrix.build_dir }}/bin/all_libs | ||
| find ${{ matrix.build_dir }}/_external/install -type f \( -name "*.so" -o -name "*.so.*" -o -name "*.dylib" \) -exec cp {} ${{ matrix.build_dir }}/bin/all_libs/ \; 2>/dev/null || true | ||
| ldd ${{ matrix.build_dir }}/bin/itlabai_acc | grep "=> /" | awk '{print $3}' | xargs -I {} cp {} ${{ matrix.build_dir }}/bin/all_libs/ 2>/dev/null || true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider simplifying it |
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: mnist-${{ matrix.build_type }}${{ matrix.stats && '-stats' || '' }} | ||
| name: mnist-${{ matrix.artifact_name }} | ||
| path: | | ||
| ${{ steps.set_binaries.outputs.ACC_BINARY }} | ||
| build/bin/all_libs/* | ||
| build/bin/opencv_libs/* | ||
| build/setenv.sh | ||
| ${{ matrix.build_dir }}/bin/all_libs/* | ||
| - name: Test | ||
| run: cmake --build build -t test | ||
| run: ctest --preset ${{ matrix.preset }} --output-on-failure -L unit | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| - name: Test (valgrind) | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y valgrind | ||
| valgrind cmake --build build -t test | ||
| valgrind --error-exitcode=1 ${{ matrix.build_dir }}/bin/itlabai_run_test --gtest_filter=-convlayer_parall.* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add TODO to re-enable the tests |
||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| build-linux-clang: | ||
|
|
@@ -91,21 +88,21 @@ jobs: | |
| key: ccache-${{ github.job }} | ||
| - name: Build | ||
| run: | | ||
| cmake -S . -B build -G Ninja \ | ||
| cmake --preset dev-release \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_C_COMPILER=clang \ | ||
| -DCMAKE_CXX_COMPILER=clang++ | ||
| cmake --build build --parallel | ||
| cmake --build --preset dev-release --parallel | ||
| - name: Test | ||
| run: cmake --build build -t test | ||
| run: ctest --preset dev-release --output-on-failure -L unit | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| - name: Test (valgrind) | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y valgrind | ||
| valgrind cmake --build build -t test | ||
| valgrind --error-exitcode=1 build/release/bin/itlabai_run_test --gtest_filter=-convlayer_parall.* | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| build-macos: | ||
|
|
@@ -126,7 +123,7 @@ jobs: | |
| run: | | ||
| OPENMP_PATH=$(brew --prefix libomp) | ||
| echo "OpenMP path: $OPENMP_PATH" | ||
| cmake -S . -B build -G Ninja \ | ||
| cmake --preset dev-release \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_PREFIX_PATH=$OPENMP_PATH \ | ||
|
|
@@ -139,12 +136,12 @@ jobs: | |
| -DOpenMP_omp_LIBRARY="$OPENMP_PATH/lib/libomp.dylib" \ | ||
| -DCMAKE_EXE_LINKER_FLAGS="-L$OPENMP_PATH/lib -lomp" \ | ||
| -DCMAKE_SHARED_LINKER_FLAGS="-L$OPENMP_PATH/lib -lomp" | ||
| cmake --build build --parallel | ||
| cmake --build --preset dev-release --parallel | ||
| env: | ||
| LDFLAGS: "-L$(brew --prefix libomp)/lib -lomp" | ||
| CPPFLAGS: "-I$(brew --prefix libomp)/include" | ||
| - name: Test | ||
| run: cmake --build build -t test | ||
| run: ctest --preset dev-release --output-on-failure -L unit | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| build-windows: | ||
|
|
@@ -167,12 +164,10 @@ jobs: | |
| uses: ilammy/msvc-dev-cmd@v1 | ||
| - name: Build | ||
| run: | | ||
| cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release | ||
| cmake --build build --parallel --config Release | ||
| cmake --preset dev-release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| cmake --build --preset dev-release --parallel --config Release | ||
| - name: Test | ||
| run: | | ||
| cd build | ||
| ctest --output-on-failure | ||
| run: ctest --preset dev-release --output-on-failure -L unit | ||
| build-linux-arm64: | ||
| runs-on: ubuntu-24.04-arm | ||
| steps: | ||
|
|
@@ -187,12 +182,11 @@ jobs: | |
| key: ccache-${{ github.job }} | ||
| - name: Build and Test | ||
| run: | | ||
| cmake -S . -B build -G Ninja \ | ||
| cmake --preset dev-release \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_BUILD_TYPE=Release | ||
| cmake --build build --parallel | ||
| cmake --build build -t test | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| cmake --build --preset dev-release --parallel | ||
| ctest --preset dev-release --output-on-failure -L unit | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| codecov: | ||
|
|
@@ -206,19 +200,16 @@ jobs: | |
| - name: Setup ccache | ||
| uses: hendrikmuhs/ccache-action@v1.2 | ||
| with: | ||
| key: ccache-${{ github.job }}-${{ matrix.build_type }} | ||
| key: ccache-${{ github.job }} | ||
| max-size: 2G | ||
| - name: Build | ||
| run: | | ||
| cmake -S . -B build -G Ninja \ | ||
| cmake --preset coverage \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_C_FLAGS="--coverage" \ | ||
| -DCMAKE_CXX_FLAGS="--coverage" \ | ||
| -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
| cmake --build build --parallel | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| cmake --build --preset coverage --parallel | ||
| - name: Test | ||
| run: cmake --build build -t test | ||
| run: ctest --preset coverage --output-on-failure -L unit | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| - name: Generate Coverage Data | ||
|
|
@@ -228,6 +219,8 @@ jobs: | |
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| slug: embedded-dev-research/ITLabAI | ||
| files: coverage.xml | ||
| disable_search: true | ||
|
|
||
| evaluate-model: | ||
| runs-on: ubuntu-latest | ||
|
|
@@ -249,7 +242,12 @@ jobs: | |
| - name: Set binary path | ||
| id: set_eval_binary | ||
| run: | | ||
| echo "EVAL_BINARY=build/bin/ACC" >> $GITHUB_OUTPUT | ||
| EVAL_BINARY=$(find build -type f -name itlabai_acc | head -n1) | ||
| if [ -z "$EVAL_BINARY" ]; then | ||
| echo "Failed to locate itlabai_acc in downloaded artifact" | ||
| exit 1 | ||
| fi | ||
| echo "EVAL_BINARY=$EVAL_BINARY" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
|
|
@@ -284,12 +282,18 @@ jobs: | |
|
|
||
| - name: Prepare environment | ||
| run: | | ||
| LIB_DIR=$(find build -type d -name all_libs | head -n1) | ||
| if [ -z "$LIB_DIR" ]; then | ||
| echo "Failed to locate all_libs directory in downloaded artifact" | ||
| exit 1 | ||
| fi | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, remove |
||
| chmod +x "${{ steps.set_eval_binary.outputs.EVAL_BINARY }}" | ||
| export LD_LIBRARY_PATH=$PWD/build/bin/all_libs:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | ||
| export LD_LIBRARY_PATH=$PWD/$LIB_DIR:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | ||
|
|
||
| - name: Run evaluation | ||
| run: | | ||
| export LD_LIBRARY_PATH=$PWD/build/bin/all_libs:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | ||
| LIB_DIR=$(find build -type d -name all_libs | head -n1) | ||
| export LD_LIBRARY_PATH=$PWD/$LIB_DIR:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be simplified |
||
| "${{ steps.set_eval_binary.outputs.EVAL_BINARY }}" --model alexnet_mnist > accuracy.txt 2>&1 | ||
| if [ $? -ne 0 ]; then | ||
| exit 1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Perf Daily | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need it? |
||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 8 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| perf-daily-linux: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
| - name: Setup ccache | ||
| uses: hendrikmuhs/ccache-action@v1.2 | ||
| with: | ||
| key: ccache-${{ github.job }} | ||
| - name: Build | ||
| run: | | ||
| cmake --preset dev-release \ | ||
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| cmake --build --preset dev-release --parallel | ||
| - name: Run Perf Tests | ||
| run: ctest --preset dev-release --output-on-failure -L perf | ||
| env: | ||
| CTEST_OUTPUT_ON_FAILURE: 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,61 @@ | ||
| cmake_minimum_required(VERSION 3.20) | ||
|
|
||
| project(ITLabAI) | ||
| project(ITLabAI VERSION 0.1.0 LANGUAGES CXX) | ||
| include(GNUInstallDirs) | ||
| include(CMakePackageConfigHelpers) | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ProjectDefaults.cmake) | ||
|
|
||
| set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Options.cmake) | ||
|
|
||
| option(ENABLE_STATISTIC_TENSORS "Enable statistic tensors" OFF) | ||
|
|
||
| if(ENABLE_STATISTIC_TENSORS) | ||
| add_definitions(-DENABLE_STATISTIC_TENSORS) | ||
| endif() | ||
|
|
||
| option(ENABLE_STATISTIC_TIME "Enable statistic time" OFF) | ||
|
|
||
| if(ENABLE_STATISTIC_TIME) | ||
| add_definitions(-DENABLE_STATISTIC_TIME) | ||
| endif() | ||
|
|
||
| option(ENABLE_STATISTIC_WEIGHTS "Enable statistic weights" OFF) | ||
|
|
||
| if(ENABLE_STATISTIC_WEIGHTS) | ||
| add_definitions(-DENABLE_STATISTIC_WEIGHTS) | ||
| if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we check for |
||
| set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) | ||
| endif() | ||
|
|
||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
|
|
||
| enable_testing() | ||
|
|
||
| find_package(OpenMP REQUIRED) | ||
|
|
||
| if(OpenMP_FOUND) | ||
| message(STATUS "OpenMP found - enabling parallel support") | ||
| add_definitions(-DHAS_OPENMP) | ||
| link_libraries(OpenMP::OpenMP_CXX) | ||
| else() | ||
| message(STATUS "OpenMP not found - parallel features disabled") | ||
| endif() | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Features.cmake) | ||
|
|
||
| include_directories("include") | ||
| list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
|
||
| list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TargetsCommon.cmake) | ||
|
|
||
| add_subdirectory(3rdparty) | ||
| # External dependencies | ||
| include(cmake/deps.cmake) | ||
|
|
||
| include(cmake/opencv_config.cmake) | ||
| include(cmake/kokkos_config.cmake) | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestData.cmake) | ||
|
|
||
| include_directories("${KOKKOS_INSTALL_DIR}/include") | ||
| add_subdirectory(src) | ||
| if(ITLABAI_BUILD_APPS) | ||
| add_subdirectory(app) | ||
| endif() | ||
| if(BUILD_TESTING) | ||
| enable_testing() | ||
| add_subdirectory(test) | ||
| endif() | ||
|
|
||
| add_library(Kokkos_imported INTERFACE) | ||
| add_dependencies(Kokkos_imported kokkos_external) | ||
| include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/InTreeAliases.cmake) | ||
|
|
||
| target_include_directories(Kokkos_imported INTERFACE | ||
| "${KOKKOS_INSTALL_DIR}/include" | ||
| # Aggregate interface target | ||
| if(NOT TARGET itlabai) | ||
| add_library(itlabai INTERFACE) | ||
| add_library(ITLabAI::itlabai ALIAS itlabai) | ||
| endif() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is that? Aggregates are an overkill in all the cases for such a small lib |
||
| target_include_directories(itlabai INTERFACE | ||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) | ||
|
|
||
| target_link_directories(Kokkos_imported INTERFACE | ||
| "${KOKKOS_INSTALL_DIR}/lib" | ||
| target_link_libraries(itlabai INTERFACE itlabai_options) | ||
|
|
||
| # Install/export | ||
| target_link_libraries(itlabai INTERFACE | ||
| itlabai_graph_lib | ||
| itlabai_graph_transformations_lib | ||
| itlabai_layers_lib | ||
| itlabai_layers_onednn_lib | ||
| itlabai_perf_lib | ||
| itlabai_reader_lib | ||
| ) | ||
|
|
||
|
|
||
| target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) | ||
|
|
||
|
|
||
| if(MSVC) | ||
| add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) | ||
| endif() | ||
|
|
||
| if (NOT WIN32) | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") | ||
| else() | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /wd4996 /wd4190 /wd4189 /WX") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4996 /wd4190 /wd4189 /WX") | ||
| endif() | ||
|
|
||
| foreach(CONFIG "" _DEBUG _RELEASE) | ||
| set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY${CONFIG}" "${CMAKE_BINARY_DIR}/lib") | ||
| set("CMAKE_LIBRARY_OUTPUT_DIRECTORY${CONFIG}" "${CMAKE_BINARY_DIR}/lib") | ||
| set("CMAKE_RUNTIME_OUTPUT_DIRECTORY${CONFIG}" "${CMAKE_BINARY_DIR}/bin") | ||
| endforeach() | ||
|
|
||
| add_subdirectory(app) | ||
| add_subdirectory(include) | ||
| add_subdirectory(src) | ||
| add_subdirectory(test) | ||
| include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Packaging.cmake") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are they dev-debug and dev-release and not just debug and release?