From a80dc951cfe8887b3f52eaf4379cde5e93752164 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sat, 20 Dec 2025 14:27:16 +0300 Subject: [PATCH 01/33] fix --- .gitmodules | 4 +++ 3rdparty/kokkos | 1 + CMakeLists.txt | 14 +++++++++- app/Graph/CMakeLists.txt | 2 +- cmake/kokkos_config.cmake | 43 ++++++++++++++++++++++++++++++ include/graph/graph.hpp | 28 ++++++++++++------- include/parallel/backends.hpp | 38 +++++++++++++++++++++++++- include/parallel/parallel.hpp | 5 +++- src/layers/CMakeLists.txt | 2 ++ test/single_layer/test_ewlayer.cpp | 15 +++++++++++ 10 files changed, 139 insertions(+), 13 deletions(-) create mode 160000 3rdparty/kokkos create mode 100644 cmake/kokkos_config.cmake diff --git a/.gitmodules b/.gitmodules index f19f40a5..c074c99d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,7 @@ [submodule "3rdparty/oneDNN"] path = 3rdparty/oneDNN url = https://github.com/uxlfoundation/oneDNN +[submodule "3rdparty/kokkos"] + path = 3rdparty/kokkos + url = https://github.com/kokkos/kokkos.git + branch = release-candidate-5.0.1 diff --git a/3rdparty/kokkos b/3rdparty/kokkos new file mode 160000 index 00000000..f5723022 --- /dev/null +++ b/3rdparty/kokkos @@ -0,0 +1 @@ +Subproject commit f572302292068a22672ab0012adaeeee0596fcea diff --git a/CMakeLists.txt b/CMakeLists.txt index 67d60660..5a8180af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(ENABLE_STATISTIC_WEIGHTS) add_definitions(-DENABLE_STATISTIC_WEIGHTS) endif() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) enable_testing() @@ -43,6 +43,18 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") add_subdirectory(3rdparty) include(cmake/opencv_config.cmake) +include(cmake/kokkos_config.cmake) + +set(Kokkos_DIR "${KOKKOS_BUILD_DIR}/install/lib/cmake/Kokkos") +find_package(Kokkos REQUIRED CONFIG) + +if(Kokkos_FOUND) + include_directories(${KOKKOS_BUILD_DIR}/install/include) +endif() + +if(MSVC) + add_compile_options(/wd4267 /wd4244 /wd4127) +endif() if (NOT WIN32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") diff --git a/app/Graph/CMakeLists.txt b/app/Graph/CMakeLists.txt index 69e934d3..742434d6 100644 --- a/app/Graph/CMakeLists.txt +++ b/app/Graph/CMakeLists.txt @@ -59,4 +59,4 @@ add_definitions(-DMODEL_PATH_DENSENET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/dense add_definitions(-DMODEL_PATH_RESNET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/resnest101e_Opset16_onnx_model.json") add_definitions(-DMODEL_PATH_YOLO11NET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/yolo11x-cls_onnx_model.json") add_definitions(-DIMAGENET_LABELS="${CMAKE_SOURCE_DIR}/docs/imagenet1000_clsidx_to_labels.json") -add_definitions(-DMNIST_PATH="${CMAKE_SOURCE_DIR}/docs/mnist/mnist/test") +add_definitions(-DMNIST_PATH="${CMAKE_SOURCE_DIR}/docs/mnist/test") diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake new file mode 100644 index 00000000..4f9df7ed --- /dev/null +++ b/cmake/kokkos_config.cmake @@ -0,0 +1,43 @@ +set(KOKKOS_BUILD_DIR "${CMAKE_BINARY_DIR}/3rdparty/kokkos_build") +file(MAKE_DIRECTORY "${KOKKOS_BUILD_DIR}") + +execute_process( + COMMAND ${CMAKE_COMMAND} + -S "${CMAKE_SOURCE_DIR}/3rdparty/kokkos" + -B "${KOKKOS_BUILD_DIR}" + -G "${CMAKE_GENERATOR}" + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${KOKKOS_BUILD_DIR}/install + + -DKokkos_ENABLE_SERIAL=ON + -DKokkos_ARCH_NATIVE=OFF + -DKokkos_ENABLE_OPENMP=OFF + -DKokkos_ENABLE_CUDA=OFF + -DKokkos_ENABLE_HIP=OFF + -DKokkos_ENABLE_TESTS=OFF + -DKokkos_ENABLE_EXAMPLES=OFF + + -DKokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON + -DKokkos_ENABLE_LIBDL=OFF + WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" + RESULT_VARIABLE config_result +) + +if(NOT config_result EQUAL 0) + message(FATAL_ERROR "Failed to configure Kokkos") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} --build "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} -j${NPROC} + RESULT_VARIABLE build_result + WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" +) + +if(NOT build_result EQUAL 0) + message(FATAL_ERROR "Failed to build Kokkos") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} + WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" +) diff --git a/include/graph/graph.hpp b/include/graph/graph.hpp index 93114b76..18824f1c 100644 --- a/include/graph/graph.hpp +++ b/include/graph/graph.hpp @@ -247,7 +247,13 @@ class Graph { if (it != branch_list_.rend()) { for (size_t f = 0; f < it->distribution.size(); ++f) { if (it->distribution[f].first == current_layer) { - inten_.push_back(it->give_for_all[it->distribution[f].second]); + bool last_use = (it->count_used_ten == 1); + auto& src = it->give_for_all[it->distribution[f].second]; + if (last_use) { + inten_.push_back(std::move(src)); + } else { + inten_.push_back(src); + } } } } @@ -262,6 +268,9 @@ class Graph { } } } + if (outten_.empty()) { + outten_.resize(1); + } layers_[current_layer]->run(inten_, outten_); #ifdef ENABLE_STATISTIC_TENSORS @@ -272,18 +281,18 @@ class Graph { weights_.push_back(layers_[current_layer]->get_weights()); #endif - inten_ = outten_; + inten_.swap(outten_); if (layers_[current_layer]->postops.count > 0) { for (unsigned int j = 0; j < layers_[current_layer]->postops.count; j++) { layers_[current_layer]->postops.layers[j]->run(inten_, outten_); } - inten_ = outten_; + inten_.swap(outten_); } BranchState new_branch; - new_branch.give_for_all = inten_; + new_branch.give_for_all = std::move(inten_); new_branch.count_used_ten = countinout[current_layer].second; new_branch.ind_layer = current_layer; new_branch.split = layers_[current_layer]->getName() == kSplit; @@ -308,7 +317,12 @@ class Graph { } new_branch.distribution = dis; } - branch_list_.push_back(new_branch); + branch_list_.push_back(std::move(new_branch)); + if (outtenres_ && current_layer == end_ && + !branch_list_.back().give_for_all.empty() && + countinout[current_layer].second == 0) { + *outtenres_ = std::move(branch_list_.back().give_for_all[0]); + } #ifdef ENABLE_STATISTIC_TIME auto end = std::chrono::high_resolution_clock::now(); @@ -318,10 +332,6 @@ class Graph { time_layer_.push_back(layers_[current_layer]->getName()); #endif } - - if (outtenres_ && !outten_.empty()) { - *outtenres_ = outten_[0]; - } } void setOutput(Layer* layer, Tensor& vec) { diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index b63d128c..f309d1c4 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -17,7 +18,8 @@ enum class Backend : std::uint8_t { kSeq = 0, kThreads = 1, kTbb = 2, - kOmp = 3 + kOmp = 3, + kKokkos = 4 }; struct Options { @@ -116,5 +118,39 @@ inline void impl_omp(std::size_t count, } #endif +inline void impl_kokkos(std::size_t count, + const std::function& func, + const Options& opt) { + if (count == 0) return; + + static bool kokkos_initialized = false; + if (!kokkos_initialized) { + int num_threads = + opt.max_threads > 0 + ? opt.max_threads + : static_cast(std::thread::hardware_concurrency()); + + Kokkos::InitializationSettings args; + args.set_num_threads(num_threads); + + Kokkos::initialize(args); + kokkos_initialized = true; + + static struct KokkosFinalizer { + ~KokkosFinalizer() { + if (kokkos_initialized) { + Kokkos::finalize(); + } + } + } finalizer; + } + + auto kokkos_func = [&func](const std::size_t i) { func(i); }; + + Kokkos::parallel_for("parallel_for", count, kokkos_func); + + Kokkos::fence(); +} + } // namespace parallel } // namespace it_lab_ai diff --git a/include/parallel/parallel.hpp b/include/parallel/parallel.hpp index 5232dcae..e0e66262 100644 --- a/include/parallel/parallel.hpp +++ b/include/parallel/parallel.hpp @@ -19,7 +19,7 @@ inline Backend resolve_default_backend(std::size_t n, const Options& opt) { #ifdef HAS_OPENMP return Backend::kOmp; #else - return Backend::kTbb; + return Backend::kSeq; #endif } @@ -56,6 +56,9 @@ inline void parallel_for(std::size_t count, Func&& func, case Backend::kOmp: impl_omp(count, std::forward(func), opt); break; + case Backend::kKokkos: + impl_kokkos(count, std::forward(func), opt); + break; } } diff --git a/src/layers/CMakeLists.txt b/src/layers/CMakeLists.txt index 50f14846..c3bb2544 100644 --- a/src/layers/CMakeLists.txt +++ b/src/layers/CMakeLists.txt @@ -3,3 +3,5 @@ add_library(layers_lib STATIC "${LAYERS_HEADERS}" "${layers_src}") target_link_libraries(layers_lib PUBLIC TBB_unified) target_link_libraries(layers_lib PUBLIC OpenMP::OpenMP_CXX) target_link_libraries(layers_lib PUBLIC dnnl) +#target_include_directories(layers_lib PUBLIC ${KOKKOS_BUILD_DIR}/install/include) +target_link_libraries(layers_lib PUBLIC Kokkos::kokkos) diff --git a/test/single_layer/test_ewlayer.cpp b/test/single_layer/test_ewlayer.cpp index 7ed0e743..81528ca6 100644 --- a/test/single_layer/test_ewlayer.cpp +++ b/test/single_layer/test_ewlayer.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "gtest/gtest.h" @@ -380,6 +381,7 @@ TEST(ewlayer, parallel_for_notmatrix) { auto end = std::chrono::high_resolution_clock::now(); auto total_duration = std::chrono::duration_cast(end - start); + std::cout << total_duration << std::endl; for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); @@ -390,6 +392,7 @@ TEST(ewlayer, parallel_for_notmatrix) { end = std::chrono::high_resolution_clock::now(); total_duration = std::chrono::duration_cast(end - start); + std::cout << total_duration << std::endl; for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); start = std::chrono::high_resolution_clock::now(); @@ -399,6 +402,7 @@ TEST(ewlayer, parallel_for_notmatrix) { end = std::chrono::high_resolution_clock::now(); total_duration = std::chrono::duration_cast(end - start); + std::cout << total_duration << std::endl; for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); start = std::chrono::high_resolution_clock::now(); @@ -408,5 +412,16 @@ TEST(ewlayer, parallel_for_notmatrix) { end = std::chrono::high_resolution_clock::now(); total_duration = std::chrono::duration_cast(end - start); + std::cout << total_duration << std::endl; + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kKokkos); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + std::cout << total_duration << std::endl; for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); } From 9bb58e39d7cb613550ec11cca51d8f576c8c9b16 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 15:05:36 +0300 Subject: [PATCH 02/33] Update CMakeLists.txt --- app/Graph/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Graph/CMakeLists.txt b/app/Graph/CMakeLists.txt index 901ced0c..7ba68416 100644 --- a/app/Graph/CMakeLists.txt +++ b/app/Graph/CMakeLists.txt @@ -47,4 +47,4 @@ add_definitions(-DMODEL_PATH_DENSENET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/dense add_definitions(-DMODEL_PATH_RESNET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/resnest101e_Opset16_onnx_model.json") add_definitions(-DMODEL_PATH_YOLO11NET_ONNX="${CMAKE_SOURCE_DIR}/docs/jsons/yolo11x-cls_onnx_model.json") add_definitions(-DIMAGENET_LABELS="${CMAKE_SOURCE_DIR}/docs/imagenet1000_clsidx_to_labels.json") -add_definitions(-DMNIST_PATH="${CMAKE_SOURCE_DIR}/docs/mnist/test") +add_definitions(-DMNIST_PATH="${CMAKE_SOURCE_DIR}/docs/mnist/mnist/test") From 5e9b94d61ee0ccdc7c640c65adc53b4438fa39c0 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 15:06:02 +0300 Subject: [PATCH 03/33] Fix formatting in graph.hpp --- include/graph/graph.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/graph/graph.hpp b/include/graph/graph.hpp index c89bb7d3..07d86c0e 100644 --- a/include/graph/graph.hpp +++ b/include/graph/graph.hpp @@ -272,7 +272,6 @@ class Graph { if (outten_.empty()) { outten_.resize(1); } - layers_[current_layer]->run(inten_, outten_, options); #ifdef ENABLE_STATISTIC_TENSORS From 57a9976d73126bad2c7195e6a6e33d3d31102549 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 15:06:47 +0300 Subject: [PATCH 04/33] Remove commented Kokkos include directory Removed commented include directories for Kokkos. --- src/layers/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layers/CMakeLists.txt b/src/layers/CMakeLists.txt index 68799be9..a204e3b7 100644 --- a/src/layers/CMakeLists.txt +++ b/src/layers/CMakeLists.txt @@ -4,5 +4,4 @@ add_library(layers_lib STATIC "${LAYERS_HEADERS}" "${layers_src}") target_link_libraries(layers_lib PUBLIC TBB_unified) target_link_libraries(layers_lib PUBLIC OpenMP::OpenMP_CXX) target_link_libraries(layers_lib PUBLIC dnnl) -#target_include_directories(layers_lib PUBLIC ${KOKKOS_BUILD_DIR}/install/include) target_link_libraries(layers_lib PUBLIC Kokkos::kokkos) From e8bf78d3a79b98ce79fff4663fd410521218b041 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 16:13:15 +0300 Subject: [PATCH 05/33] Replace count() with contains() for maps --- app/Graph/build.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Graph/build.cpp b/app/Graph/build.cpp index f6b33ef0..fea9e6bb 100644 --- a/app/Graph/build.cpp +++ b/app/Graph/build.cpp @@ -227,8 +227,8 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input, try { std::sort(connection_list.begin(), connection_list.end(), [&](const auto& a, const auto& b) { - if (!name_to_layer_ptr.count(a.first) || - !name_to_layer_ptr.count(b.first)) { + if (!name_to_layer_ptr.contains(a.first) || + !name_to_layer_ptr.contains(b.first)) { return false; } return name_to_layer_ptr[a.first]->getID() < @@ -239,8 +239,8 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input, } for (const auto& [source_name, target_name] : connection_list) { - if (name_to_layer_ptr.count(source_name) && - name_to_layer_ptr.count(target_name)) { + if (name_to_layer_ptr.contains(source_name) && + name_to_layer_ptr.contains(target_name)) { if (target_name.find("Concat") != std::string::npos || name_to_layer_ptr[target_name]->getName() == it_lab_ai::kConcat) { if (concat_connections.find(target_name) != concat_connections.end()) { @@ -573,7 +573,7 @@ ParseResult parse_json_model(RuntimeOptions options, std::string constant_name = inputs[1].get(); constant_name = get_base_layer_name(constant_name); - if (layer_parameters.count(constant_name)) { + if (layer_parameters.contains(constant_name)) { splits = layer_parameters[constant_name]; } else if (constant_name.find("onnx::") != std::string::npos) { splits = last_constant_value; @@ -771,7 +771,7 @@ ParseResult parse_json_model(RuntimeOptions options, std::string constant_name = inputs[1].get(); constant_name = get_base_layer_name(constant_name); - if (layer_parameters.count(constant_name)) { + if (layer_parameters.contains(constant_name)) { shape = layer_parameters[constant_name]; } } @@ -833,7 +833,7 @@ ParseResult parse_json_model(RuntimeOptions options, std::string constant_name = inputs[1].get(); constant_name = get_base_layer_name(constant_name); - if (layer_parameters.count(constant_name)) { + if (layer_parameters.contains(constant_name)) { axes = layer_parameters[constant_name]; } else if (constant_name.find("onnx::") != std::string::npos) { axes = last_constant_value; From 5f3325659776ad32f8b1829374d807e6faca37d5 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 16:50:32 +0300 Subject: [PATCH 06/33] Update backends.hpp --- include/parallel/backends.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index f309d1c4..db4f76b7 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -3,7 +3,9 @@ #include #include +// NOLINTNEXTLINE #include + #include #include #include @@ -154,3 +156,4 @@ inline void impl_kokkos(std::size_t count, } // namespace parallel } // namespace it_lab_ai + From bb56e13bec5094cb40626635ea0799a6135172a9 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 16:56:46 +0300 Subject: [PATCH 07/33] Update backends.hpp --- include/parallel/backends.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index db4f76b7..600aa92e 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -2,8 +2,6 @@ #include #include #include - -// NOLINTNEXTLINE #include #include @@ -157,3 +155,4 @@ inline void impl_kokkos(std::size_t count, } // namespace parallel } // namespace it_lab_ai + From 461d2735d5d4f93ebf26c27e95073d63cbb8dc5a Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 17:14:32 +0300 Subject: [PATCH 08/33] Update backends.hpp --- include/parallel/backends.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index 600aa92e..9093f27b 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -2,8 +2,9 @@ #include #include #include -#include +// NOLINTNEXTLINE +#include #include #include #include @@ -156,3 +157,4 @@ inline void impl_kokkos(std::size_t count, } // namespace it_lab_ai + From c8cfe03bc6240132314b6d7f2a99ea53970c6b43 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sat, 20 Dec 2025 17:18:12 +0300 Subject: [PATCH 09/33] Refactor backend implementation in backends.hpp --- include/parallel/backends.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index 9093f27b..b79dbead 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -155,6 +155,3 @@ inline void impl_kokkos(std::size_t count, } // namespace parallel } // namespace it_lab_ai - - - From c5b29c9d6c352581222dfaab7f82d0b459ed4655 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 16:56:04 +0300 Subject: [PATCH 10/33] fix --- CMakeLists.txt | 22 +- cmake/kokkos_config.cmake | 48 ++-- include/parallel/backends.hpp | 21 +- include/parallel/parallel.hpp | 5 +- src/layers/CMakeLists.txt | 2 +- test/single_layer/test_ewlayer.cpp | 193 ------------- .../test_ewlayer_parall.cpp | 260 ++++++++++++++++++ 7 files changed, 308 insertions(+), 243 deletions(-) create mode 100644 test/single_layer_parall_version/test_ewlayer_parall.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a8180af..3c8259c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,15 +45,27 @@ add_subdirectory(3rdparty) include(cmake/opencv_config.cmake) include(cmake/kokkos_config.cmake) -set(Kokkos_DIR "${KOKKOS_BUILD_DIR}/install/lib/cmake/Kokkos") -find_package(Kokkos REQUIRED CONFIG) +include_directories("${KOKKOS_INSTALL_DIR}/include") -if(Kokkos_FOUND) - include_directories(${KOKKOS_BUILD_DIR}/install/include) +add_library(Kokkos_imported INTERFACE) +add_dependencies(Kokkos_imported kokkos_external) + +target_include_directories(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/include" +) + +target_link_directories(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/lib" +) + +if(WIN32) + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) +else() + target_link_libraries(Kokkos_imported INTERFACE kokkos) endif() if(MSVC) - add_compile_options(/wd4267 /wd4244 /wd4127) + add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) endif() if (NOT WIN32) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index 4f9df7ed..ffa678df 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -1,17 +1,23 @@ +include(ExternalProject) + set(KOKKOS_BUILD_DIR "${CMAKE_BINARY_DIR}/3rdparty/kokkos_build") -file(MAKE_DIRECTORY "${KOKKOS_BUILD_DIR}") +set(KOKKOS_INSTALL_DIR "${CMAKE_BINARY_DIR}/3rdparty/kokkos_install") -execute_process( - COMMAND ${CMAKE_COMMAND} - -S "${CMAKE_SOURCE_DIR}/3rdparty/kokkos" - -B "${KOKKOS_BUILD_DIR}" +ExternalProject_Add( + kokkos_external + SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/kokkos" + BINARY_DIR "${KOKKOS_BUILD_DIR}" + INSTALL_DIR "${KOKKOS_INSTALL_DIR}" + + CMAKE_ARGS -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${KOKKOS_BUILD_DIR}/install + -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_DIR} -DKokkos_ENABLE_SERIAL=ON -DKokkos_ARCH_NATIVE=OFF -DKokkos_ENABLE_OPENMP=OFF + -DKokkos_ENABLE_THREADS=ON -DKokkos_ENABLE_CUDA=OFF -DKokkos_ENABLE_HIP=OFF -DKokkos_ENABLE_TESTS=OFF @@ -19,25 +25,15 @@ execute_process( -DKokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON -DKokkos_ENABLE_LIBDL=OFF - WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" - RESULT_VARIABLE config_result -) - -if(NOT config_result EQUAL 0) - message(FATAL_ERROR "Failed to configure Kokkos") -endif() - -execute_process( - COMMAND ${CMAKE_COMMAND} --build "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} -j${NPROC} - RESULT_VARIABLE build_result - WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" + + BUILD_COMMAND ${CMAKE_COMMAND} --build "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} -j${NPROC} + + INSTALL_COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} + + BUILD_ALWAYS OFF + LOG_CONFIGURE ON + LOG_BUILD ON + LOG_INSTALL ON ) -if(NOT build_result EQUAL 0) - message(FATAL_ERROR "Failed to build Kokkos") -endif() - -execute_process( - COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} - WORKING_DIRECTORY "${KOKKOS_BUILD_DIR}" -) +set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") \ No newline at end of file diff --git a/include/parallel/backends.hpp b/include/parallel/backends.hpp index b79dbead..694fdc32 100644 --- a/include/parallel/backends.hpp +++ b/include/parallel/backends.hpp @@ -3,7 +3,7 @@ #include #include -// NOLINTNEXTLINE +// NOLINTNEXTLINE(misc-header-include-cycle) #include #include #include @@ -123,9 +123,8 @@ inline void impl_kokkos(std::size_t count, const std::function& func, const Options& opt) { if (count == 0) return; - - static bool kokkos_initialized = false; - if (!kokkos_initialized) { + static std::once_flag init_flag; + std::call_once(init_flag, [&opt]() { int num_threads = opt.max_threads > 0 ? opt.max_threads @@ -133,23 +132,13 @@ inline void impl_kokkos(std::size_t count, Kokkos::InitializationSettings args; args.set_num_threads(num_threads); - Kokkos::initialize(args); - kokkos_initialized = true; - static struct KokkosFinalizer { - ~KokkosFinalizer() { - if (kokkos_initialized) { - Kokkos::finalize(); - } - } - } finalizer; - } + std::atexit([]() { Kokkos::finalize(); }); + }); auto kokkos_func = [&func](const std::size_t i) { func(i); }; - Kokkos::parallel_for("parallel_for", count, kokkos_func); - Kokkos::fence(); } diff --git a/include/parallel/parallel.hpp b/include/parallel/parallel.hpp index e0e66262..5834aeba 100644 --- a/include/parallel/parallel.hpp +++ b/include/parallel/parallel.hpp @@ -19,7 +19,7 @@ inline Backend resolve_default_backend(std::size_t n, const Options& opt) { #ifdef HAS_OPENMP return Backend::kOmp; #else - return Backend::kSeq; + return Backend::kTbb; #endif } @@ -29,7 +29,8 @@ inline Backend select_backend(const Options& opt, std::size_t n) { } if (opt.backend == Backend::kSeq || opt.backend == Backend::kThreads || - opt.backend == Backend::kTbb || opt.backend == Backend::kOmp) { + opt.backend == Backend::kTbb || opt.backend == Backend::kOmp || + opt.backend == Backend::kKokkos) { return opt.backend; } diff --git a/src/layers/CMakeLists.txt b/src/layers/CMakeLists.txt index a204e3b7..35382404 100644 --- a/src/layers/CMakeLists.txt +++ b/src/layers/CMakeLists.txt @@ -4,4 +4,4 @@ add_library(layers_lib STATIC "${LAYERS_HEADERS}" "${layers_src}") target_link_libraries(layers_lib PUBLIC TBB_unified) target_link_libraries(layers_lib PUBLIC OpenMP::OpenMP_CXX) target_link_libraries(layers_lib PUBLIC dnnl) -target_link_libraries(layers_lib PUBLIC Kokkos::kokkos) +target_link_libraries(layers_lib PUBLIC Kokkos_imported) diff --git a/test/single_layer/test_ewlayer.cpp b/test/single_layer/test_ewlayer.cpp index f583d1d3..e925a310 100644 --- a/test/single_layer/test_ewlayer.cpp +++ b/test/single_layer/test_ewlayer.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include "gtest/gtest.h" @@ -217,195 +216,3 @@ TEST(ewlayer, new_ewlayer_can_sigmoid_float_extreme_values) { EXPECT_NEAR((*out[0].as())[i], expected_output[i], 1e-5F); } } - -TEST(ewlayer, parallel_for_ew) { - EWLayer layer("relu"); - - std::vector vec(8000000, -1); - Tensor input = make_tensor(vec); - Tensor output; - std::vector in{input}; - std::vector out{output}; - - std::vector backends = {ParBackend::kSeq, ParBackend::kThreads, - ParBackend::kTbb, ParBackend::kOmp}; - - for (auto backend : backends) { - RuntimeOptions options; - options.setParallelBackend(backend); - - auto start = std::chrono::high_resolution_clock::now(); - layer.run(in, out, options); - auto end = std::chrono::high_resolution_clock::now(); - auto duration = - std::chrono::duration_cast(end - start); - std::cout << " time: " << duration.count() << " ms" << std::endl; - for (size_t i = 0; i < 8000000; i++) { - EXPECT_EQ((*out[0].as())[i], 0); - } - } -} - -TEST(ewlayer, parallel_for_ew_sigmoid_compact) { - EWLayer layer("sigmoid"); - - std::vector vec(8000000, -1); - Tensor input = make_tensor(vec); - Tensor output; - std::vector in{input}; - std::vector out{output}; - - std::vector> backends = { - {ParBackend::kSeq, "Sequential"}, - {ParBackend::kThreads, "Threads"}, - {ParBackend::kTbb, "TBB"}, - {ParBackend::kOmp, "OpenMP"}}; - - std::vector reference_result; - bool first = true; - - for (const auto& [backend, name] : backends) { - RuntimeOptions options; - options.parallel = (backend != ParBackend::kSeq); - options.par_backend = backend; - if (backend == ParBackend::kThreads) { - options.threads = 4; - } - - auto start = std::chrono::high_resolution_clock::now(); - layer.run(in, out, options); - auto end = std::chrono::high_resolution_clock::now(); - auto duration = - std::chrono::duration_cast(end - start); - - std::cout << "Sigmoid " << name << " time: " << duration.count() << " ms" - << std::endl; - - auto current_result = *out[0].as(); - if (first) { - reference_result = current_result; - first = false; - for (size_t i = 0; i < 100; i++) { - EXPECT_EQ(current_result[i], 0) - << "Invalid sigmoid result at index " << i; - } - } else { - for (size_t i = 0; i < reference_result.size(); i++) { - EXPECT_EQ(current_result[i], reference_result[i]) - << "Mismatch with " << name << " at index " << i; - } - } - } -} - -TEST(ewlayer, parallel_for_direct) { - const int SIZE = 2000; - std::vector matrix1(SIZE * SIZE); - std::vector matrix2(SIZE * SIZE); - std::vector result(SIZE * SIZE); - - for (int i = 0; i < SIZE * SIZE; ++i) { - matrix1[i] = 1; - matrix2[i] = 1; - } - - auto start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, - ParBackend::kSeq); - - auto end = std::chrono::high_resolution_clock::now(); - auto total_duration = - std::chrono::duration_cast(end - start); - - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, - ParBackend::kThreads); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, - ParBackend::kTbb); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, - ParBackend::kOmp); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); -} - -TEST(ewlayer, parallel_for_notmatrix) { - const int SIZE = 3000; - std::vector matrix1(SIZE * SIZE); - std::vector result(SIZE * SIZE); - - for (int i = 0; i < SIZE * SIZE; ++i) { - matrix1[i] = 1; - } - - auto start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, - ParBackend::kSeq); - - auto end = std::chrono::high_resolution_clock::now(); - auto total_duration = - std::chrono::duration_cast(end - start); - std::cout << total_duration << std::endl; - - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, - ParBackend::kThreads); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - std::cout << total_duration << std::endl; - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, - ParBackend::kTbb); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - std::cout << total_duration << std::endl; - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, - ParBackend::kOmp); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - std::cout << total_duration << std::endl; - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); - - start = std::chrono::high_resolution_clock::now(); - parallel::parallel_for( - SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, - ParBackend::kKokkos); - end = std::chrono::high_resolution_clock::now(); - total_duration = - std::chrono::duration_cast(end - start); - std::cout << total_duration << std::endl; - for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); -} diff --git a/test/single_layer_parall_version/test_ewlayer_parall.cpp b/test/single_layer_parall_version/test_ewlayer_parall.cpp new file mode 100644 index 00000000..deb4660a --- /dev/null +++ b/test/single_layer_parall_version/test_ewlayer_parall.cpp @@ -0,0 +1,260 @@ +#include +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "layers/EWLayer.hpp" + +#define ENABLE_TIMING_OUTPUT 1 + +#if ENABLE_TIMING_OUTPUT +#define PRINT_TIMING(msg) std::cout << msg << std::endl +#else +#define PRINT_TIMING(msg) ((void)0) +#endif + +using namespace it_lab_ai; + +TEST(ewlayer_parall, parallel_for_ew_relu) { + EWLayer layer("relu"); + + std::vector vec(8000000, -1); + Tensor input = make_tensor(vec); + Tensor output; + std::vector in{input}; + std::vector out{output}; + + std::vector backends = {ParBackend::kSeq, ParBackend::kThreads, + ParBackend::kTbb, ParBackend::kOmp, + ParBackend::kKokkos}; + + for (auto backend : backends) { + RuntimeOptions options; + options.setParallelBackend(backend); + + auto start = std::chrono::high_resolution_clock::now(); + layer.run(in, out, options); + auto end = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << duration.count() << " ms"); + for (size_t i = 0; i < 8000000; i++) { + EXPECT_EQ((*out[0].as())[i], 0); + } + } +} + +TEST(ewlayer_parall, parallel_for_sigmoid) { + EWLayer layer("sigmoid"); + + std::vector vec(8000000, -1); + Tensor input = make_tensor(vec); + Tensor output; + std::vector in{input}; + std::vector out{output}; + + std::vector backends = {ParBackend::kSeq, ParBackend::kThreads, + ParBackend::kTbb, ParBackend::kOmp, + ParBackend::kKokkos}; + + for (auto backend : backends) { + RuntimeOptions options; + options.setParallelBackend(backend); + + auto start = std::chrono::high_resolution_clock::now(); + layer.run(in, out, options); + auto end = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << duration.count() << " ms"); + for (size_t i = 0; i < 8000000; i++) { + EXPECT_EQ((*out[0].as())[i], 0); + } + } +} + +TEST(ewlayer_parall, parallel_for_minus) { + EWLayer layer("minus"); + + std::vector vec(8000000, -1); + Tensor input = make_tensor(vec); + Tensor output; + std::vector in{input}; + std::vector out{output}; + + std::vector backends = {ParBackend::kSeq, ParBackend::kThreads, + ParBackend::kTbb, ParBackend::kOmp, + ParBackend::kKokkos}; + + for (auto backend : backends) { + RuntimeOptions options; + options.setParallelBackend(backend); + + auto start = std::chrono::high_resolution_clock::now(); + layer.run(in, out, options); + auto end = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << duration.count() << " ms"); + for (size_t i = 0; i < 8000000; i++) { + EXPECT_EQ((*out[0].as())[i], 1); + } + } +} + +TEST(ewlayer_parall, parallel_for_linear) { + EWLayer layer("linear", 2.0F, 2.0F); + + std::vector vec(8000000, -1); + Tensor input = make_tensor(vec); + Tensor output; + std::vector in{input}; + std::vector out{output}; + + std::vector backends = {ParBackend::kSeq, ParBackend::kThreads, + ParBackend::kTbb, ParBackend::kOmp, + ParBackend::kKokkos}; + + for (auto backend : backends) { + RuntimeOptions options; + options.setParallelBackend(backend); + + auto start = std::chrono::high_resolution_clock::now(); + layer.run(in, out, options); + auto end = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << duration.count() << " ms"); + for (size_t i = 0; i < 8000000; i++) { + EXPECT_EQ((*out[0].as())[i], 0); + } + } +} + +TEST(ewlayer_parall, parallel_for_direct) { + const int SIZE = 2000; + std::vector matrix1(SIZE * SIZE); + std::vector matrix2(SIZE * SIZE); + std::vector result(SIZE * SIZE); + + for (int i = 0; i < SIZE * SIZE; ++i) { + matrix1[i] = 1; + matrix2[i] = 1; + } + + auto start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, + ParBackend::kSeq); + + auto end = std::chrono::high_resolution_clock::now(); + auto total_duration = + std::chrono::duration_cast(end - start); + + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, + ParBackend::kThreads); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, + ParBackend::kTbb); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, + ParBackend::kOmp); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + matrix2[i]; }, + ParBackend::kKokkos); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); +} + +TEST(ewlayer_parall, parallel_for_notmatrix) { + const int SIZE = 3000; + std::vector matrix1(SIZE * SIZE); + std::vector result(SIZE * SIZE); + + for (int i = 0; i < SIZE * SIZE; ++i) { + matrix1[i] = 1; + } + + auto start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kSeq); + + auto end = std::chrono::high_resolution_clock::now(); + auto total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kThreads); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kTbb); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kOmp); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); + + start = std::chrono::high_resolution_clock::now(); + parallel::parallel_for( + SIZE * SIZE, [&](std::size_t i) { result[i] = matrix1[i] + 1; }, + ParBackend::kKokkos); + end = std::chrono::high_resolution_clock::now(); + total_duration = + std::chrono::duration_cast(end - start); + PRINT_TIMING(" time: " << total_duration.count() << " ms"); + for (int i = 0; i < SIZE * SIZE; i++) ASSERT_EQ(result[i], 2); +} From 7f33859fa522498f1479a00e9997451376dc0a76 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 17:15:46 +0300 Subject: [PATCH 11/33] fix --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8259c0..1552fa5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,9 +59,15 @@ target_link_directories(Kokkos_imported INTERFACE ) if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) + target_link_libraries(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/lib/kokkoscore.lib" + "${KOKKOS_INSTALL_DIR}/lib/kokkoscontainers.lib" + ) else() - target_link_libraries(Kokkos_imported INTERFACE kokkos) + target_link_libraries(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" + ) endif() if(MSVC) From 9fb2e90df9c0fcbc2c311ebe7cb12fc421c80062 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 17:21:22 +0300 Subject: [PATCH 12/33] fix --- CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1552fa5a..3c8259c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,15 +59,9 @@ target_link_directories(Kokkos_imported INTERFACE ) if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE - "${KOKKOS_INSTALL_DIR}/lib/kokkoscore.lib" - "${KOKKOS_INSTALL_DIR}/lib/kokkoscontainers.lib" - ) + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) else() - target_link_libraries(Kokkos_imported INTERFACE - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" - ) + target_link_libraries(Kokkos_imported INTERFACE kokkos) endif() if(MSVC) From 4794d80f9016053673caad679ed2d53c769d73d6 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 17:54:42 +0300 Subject: [PATCH 13/33] fix --- cmake/kokkos_config.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index ffa678df..a8c3e133 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -34,6 +34,10 @@ ExternalProject_Add( LOG_CONFIGURE ON LOG_BUILD ON LOG_INSTALL ON + BUILD_BYPRODUCTS + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" + "${KOKKOS_INSTALL_DIR}/lib/libkokkos.a" ) set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") \ No newline at end of file From 9b4df61995855b9f822d7485de339971d1b838ce Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 18:15:06 +0300 Subject: [PATCH 14/33] fix --- CMakeLists.txt | 2 -- cmake/kokkos_config.cmake | 4 ---- 2 files changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8259c0..e918f8ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,6 @@ add_subdirectory(3rdparty) include(cmake/opencv_config.cmake) include(cmake/kokkos_config.cmake) -include_directories("${KOKKOS_INSTALL_DIR}/include") - add_library(Kokkos_imported INTERFACE) add_dependencies(Kokkos_imported kokkos_external) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index a8c3e133..ffa678df 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -34,10 +34,6 @@ ExternalProject_Add( LOG_CONFIGURE ON LOG_BUILD ON LOG_INSTALL ON - BUILD_BYPRODUCTS - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" - "${KOKKOS_INSTALL_DIR}/lib/libkokkos.a" ) set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") \ No newline at end of file From 0c787801b43b9a529d2a12afeeec6df6a0d2f903 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 18:22:30 +0300 Subject: [PATCH 15/33] fix --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e918f8ee..3c8259c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,8 @@ add_subdirectory(3rdparty) include(cmake/opencv_config.cmake) include(cmake/kokkos_config.cmake) +include_directories("${KOKKOS_INSTALL_DIR}/include") + add_library(Kokkos_imported INTERFACE) add_dependencies(Kokkos_imported kokkos_external) From 18cddb4e9664474338670cc79be94cbbf21dc1bf Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 18:56:48 +0300 Subject: [PATCH 16/33] fix --- src/graph/CMakeLists.txt | 1 + src/graph_transformations/CMakeLists.txt | 1 + src/layers_oneDNN/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/src/graph/CMakeLists.txt b/src/graph/CMakeLists.txt index 9054e8a2..5012ec69 100644 --- a/src/graph/CMakeLists.txt +++ b/src/graph/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE graph_src *.cpp) add_library(graph_lib STATIC "${GRAPH_HEADERS}" "${graph_src}") target_link_libraries(graph_lib PUBLIC TBB_unified) +target_link_libraries(graph_lib PUBLIC Kokkos_imported) diff --git a/src/graph_transformations/CMakeLists.txt b/src/graph_transformations/CMakeLists.txt index 6942b48f..df5304c2 100644 --- a/src/graph_transformations/CMakeLists.txt +++ b/src/graph_transformations/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE graphT_src *.cpp) add_library(graphT_lib STATIC "${GRAPHT_HEADERS}" "${graphT_src}") target_link_libraries(graphT_lib PUBLIC TBB_unified) +target_link_libraries(graphT_lib PUBLIC Kokkos_imported) diff --git a/src/layers_oneDNN/CMakeLists.txt b/src/layers_oneDNN/CMakeLists.txt index e4ee067e..987371c2 100644 --- a/src/layers_oneDNN/CMakeLists.txt +++ b/src/layers_oneDNN/CMakeLists.txt @@ -1,6 +1,7 @@ file(GLOB_RECURSE layers_oneDNN_src *.cpp) add_library(layers_oneDNN_lib STATIC "${LAYERS_ONEDNN_HEADERS}" "${layers_oneDNN_src}") target_link_libraries(layers_oneDNN_lib PUBLIC dnnl TBB_unified) +target_link_libraries(layers_oneDNN_lib PUBLIC Kokkos_imported) target_include_directories(layers_oneDNN_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) From 2027a3a0f328d1ecbef602b49ee4c2fa46a6df44 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:00:17 +0300 Subject: [PATCH 17/33] fix --- CMakeLists.txt | 2 +- src/graph/CMakeLists.txt | 1 - src/graph_transformations/CMakeLists.txt | 1 - src/layers_oneDNN/CMakeLists.txt | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8259c0..59401812 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_directories(Kokkos_imported INTERFACE if(WIN32) target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) else() - target_link_libraries(Kokkos_imported INTERFACE kokkos) + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) endif() if(MSVC) diff --git a/src/graph/CMakeLists.txt b/src/graph/CMakeLists.txt index 5012ec69..9054e8a2 100644 --- a/src/graph/CMakeLists.txt +++ b/src/graph/CMakeLists.txt @@ -1,4 +1,3 @@ file(GLOB_RECURSE graph_src *.cpp) add_library(graph_lib STATIC "${GRAPH_HEADERS}" "${graph_src}") target_link_libraries(graph_lib PUBLIC TBB_unified) -target_link_libraries(graph_lib PUBLIC Kokkos_imported) diff --git a/src/graph_transformations/CMakeLists.txt b/src/graph_transformations/CMakeLists.txt index df5304c2..6942b48f 100644 --- a/src/graph_transformations/CMakeLists.txt +++ b/src/graph_transformations/CMakeLists.txt @@ -1,4 +1,3 @@ file(GLOB_RECURSE graphT_src *.cpp) add_library(graphT_lib STATIC "${GRAPHT_HEADERS}" "${graphT_src}") target_link_libraries(graphT_lib PUBLIC TBB_unified) -target_link_libraries(graphT_lib PUBLIC Kokkos_imported) diff --git a/src/layers_oneDNN/CMakeLists.txt b/src/layers_oneDNN/CMakeLists.txt index 987371c2..e4ee067e 100644 --- a/src/layers_oneDNN/CMakeLists.txt +++ b/src/layers_oneDNN/CMakeLists.txt @@ -1,7 +1,6 @@ file(GLOB_RECURSE layers_oneDNN_src *.cpp) add_library(layers_oneDNN_lib STATIC "${LAYERS_ONEDNN_HEADERS}" "${layers_oneDNN_src}") target_link_libraries(layers_oneDNN_lib PUBLIC dnnl TBB_unified) -target_link_libraries(layers_oneDNN_lib PUBLIC Kokkos_imported) target_include_directories(layers_oneDNN_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) From 61f356d4f70e59e15d7ddc8213fbc7dd193744d4 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:07:46 +0300 Subject: [PATCH 18/33] fix --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59401812..6e9c8f1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,8 @@ include_directories("${KOKKOS_INSTALL_DIR}/include") add_library(Kokkos_imported INTERFACE) add_dependencies(Kokkos_imported kokkos_external) +find_package(Kokkos REQUIRED PATHS "${KOKKOS_INSTALL_DIR}" NO_DEFAULT_PATH) + target_include_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/include" ) @@ -58,11 +60,7 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) -if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) -else() - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) -endif() +target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) if(MSVC) add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) From a7177444a623b0a6ea8f8a6fc052c2607cbf98b1 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:11:29 +0300 Subject: [PATCH 19/33] fix --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e9c8f1a..c44e0b35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,8 +50,6 @@ include_directories("${KOKKOS_INSTALL_DIR}/include") add_library(Kokkos_imported INTERFACE) add_dependencies(Kokkos_imported kokkos_external) -find_package(Kokkos REQUIRED PATHS "${KOKKOS_INSTALL_DIR}" NO_DEFAULT_PATH) - target_include_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/include" ) @@ -60,6 +58,18 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) +if(WIN32) + target_link_libraries(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/lib/kokkoscore.lib" + "${KOKKOS_INSTALL_DIR}/lib/kokkoscontainers.lib" + ) +else() + target_link_libraries(Kokkos_imported INTERFACE + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" + "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" + ) +endif() + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) if(MSVC) From d2e8b1122f6b55cf8d68f89f2ac4188332a7b990 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:15:40 +0300 Subject: [PATCH 20/33] fix --- CMakeLists.txt | 12 ------------ cmake/kokkos_config.cmake | 6 +++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c44e0b35..a6681c37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,18 +58,6 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) -if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE - "${KOKKOS_INSTALL_DIR}/lib/kokkoscore.lib" - "${KOKKOS_INSTALL_DIR}/lib/kokkoscontainers.lib" - ) -else() - target_link_libraries(Kokkos_imported INTERFACE - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscore.a" - "${KOKKOS_INSTALL_DIR}/lib/libkokkoscontainers.a" - ) -endif() - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) if(MSVC) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index ffa678df..811ddd0b 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -36,4 +36,8 @@ ExternalProject_Add( LOG_INSTALL ON ) -set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") \ No newline at end of file +set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") + +INSTALL_COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} -E echo "Kokkos installed. Contents of lib dir:" + COMMAND ${CMAKE_COMMAND} -E ls "${KOKKOS_INSTALL_DIR}/lib" \ No newline at end of file From 0869a17fc1ff00cf5a7da2be96a2344d47221413 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:19:41 +0300 Subject: [PATCH 21/33] fix --- cmake/kokkos_config.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index 811ddd0b..a7503f30 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -29,6 +29,8 @@ ExternalProject_Add( BUILD_COMMAND ${CMAKE_COMMAND} --build "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} -j${NPROC} INSTALL_COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} -E echo "Kokkos installed. Contents of lib dir:" + COMMAND ${CMAKE_COMMAND} -E ls "${KOKKOS_INSTALL_DIR}/lib" BUILD_ALWAYS OFF LOG_CONFIGURE ON @@ -37,7 +39,3 @@ ExternalProject_Add( ) set(Kokkos_DIR "${KOKKOS_INSTALL_DIR}/lib/cmake/Kokkos" CACHE PATH "Path to Kokkos CMake config") - -INSTALL_COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} - COMMAND ${CMAKE_COMMAND} -E echo "Kokkos installed. Contents of lib dir:" - COMMAND ${CMAKE_COMMAND} -E ls "${KOKKOS_INSTALL_DIR}/lib" \ No newline at end of file From d9d664282cd232a11f9b181a873f094c1e519e04 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:27:20 +0300 Subject: [PATCH 22/33] fix --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6681c37..59401812 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,11 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) -target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) +if(WIN32) + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) +else() + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) +endif() if(MSVC) add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) From 04329427f232e6f6d0b9586235812a69703fe4d0 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:43:12 +0300 Subject: [PATCH 23/33] fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59401812..3c8259c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_directories(Kokkos_imported INTERFACE if(WIN32) target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) else() - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) + target_link_libraries(Kokkos_imported INTERFACE kokkos) endif() if(MSVC) From 071438e56b8df200a53421f2f2f589eb214a3411 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 19:52:56 +0300 Subject: [PATCH 24/33] fix --- cmake/kokkos_config.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/kokkos_config.cmake b/cmake/kokkos_config.cmake index a7503f30..fecbe7e6 100644 --- a/cmake/kokkos_config.cmake +++ b/cmake/kokkos_config.cmake @@ -29,8 +29,6 @@ ExternalProject_Add( BUILD_COMMAND ${CMAKE_COMMAND} --build "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} -j${NPROC} INSTALL_COMMAND ${CMAKE_COMMAND} --install "${KOKKOS_BUILD_DIR}" --config ${CMAKE_BUILD_TYPE} - COMMAND ${CMAKE_COMMAND} -E echo "Kokkos installed. Contents of lib dir:" - COMMAND ${CMAKE_COMMAND} -E ls "${KOKKOS_INSTALL_DIR}/lib" BUILD_ALWAYS OFF LOG_CONFIGURE ON From 2f8766f70c7a52dabe96d21794b136ef4d19069f Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:23:25 +0300 Subject: [PATCH 25/33] fix --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8259c0..c6f5fa70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,10 @@ else() target_link_libraries(Kokkos_imported INTERFACE kokkos) endif() +target_link_libraries(Kokkos_imported INTERFACE + $ +) + if(MSVC) add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) endif() From f4218fd20c319253f9ec336fce70a76b4430c1b4 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:25:51 +0300 Subject: [PATCH 26/33] fix --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6f5fa70..27ae6654 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,11 +58,9 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) -if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) -else() - target_link_libraries(Kokkos_imported INTERFACE kokkos) -endif() + +target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) + target_link_libraries(Kokkos_imported INTERFACE $ From 4dbb9df5d50fb350b86af32c4cf71824cf07e135 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:28:12 +0300 Subject: [PATCH 27/33] fix --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ae6654..c6f5fa70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,9 +58,11 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) - -target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) - +if(WIN32) + target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) +else() + target_link_libraries(Kokkos_imported INTERFACE kokkos) +endif() target_link_libraries(Kokkos_imported INTERFACE $ From 5bfbd5e06cb5c4a40fb14a63d4a58e7024bd5286 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:31:34 +0300 Subject: [PATCH 28/33] fix --- CMakeLists.txt | 4 ---- app/Accuracy/CMakeLists.txt | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6f5fa70..3c8259c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,10 +64,6 @@ else() target_link_libraries(Kokkos_imported INTERFACE kokkos) endif() -target_link_libraries(Kokkos_imported INTERFACE - $ -) - if(MSVC) add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) endif() diff --git a/app/Accuracy/CMakeLists.txt b/app/Accuracy/CMakeLists.txt index b4010c21..ba26815a 100644 --- a/app/Accuracy/CMakeLists.txt +++ b/app/Accuracy/CMakeLists.txt @@ -13,6 +13,7 @@ target_link_libraries( ACCLib gtest_main) add_executable(Accuracy_Check accuracy_check.cpp) target_link_libraries(Accuracy_Check ACCLib) +target_link_libraries(Accuracy_Check PUBLIC Kokkos_imported) file(DOWNLOAD "https://raw.githubusercontent.com/opencv/opencv/4.x/samples/data/lena.jpg" From 0145aeb4fc5fca0a70f64cffe06ce4d2d7375300 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:35:33 +0300 Subject: [PATCH 29/33] fix --- app/Accuracy/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Accuracy/CMakeLists.txt b/app/Accuracy/CMakeLists.txt index ba26815a..ae3deee3 100644 --- a/app/Accuracy/CMakeLists.txt +++ b/app/Accuracy/CMakeLists.txt @@ -10,10 +10,10 @@ target_link_libraries( ACCLib ${OpenCV_LIBS} ) target_link_libraries( ACCLib TBB_unified) target_link_libraries( ACCLib layers_lib) target_link_libraries( ACCLib gtest_main) +target_link_libraries( ACCLib Kokkos_imported) add_executable(Accuracy_Check accuracy_check.cpp) target_link_libraries(Accuracy_Check ACCLib) -target_link_libraries(Accuracy_Check PUBLIC Kokkos_imported) file(DOWNLOAD "https://raw.githubusercontent.com/opencv/opencv/4.x/samples/data/lena.jpg" From 6f404d6f7a154386f2f073f78727a30295471121 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:40:39 +0300 Subject: [PATCH 30/33] fix --- src/graph/CMakeLists.txt | 1 + src/graph_transformations/CMakeLists.txt | 1 + src/layers_oneDNN/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/src/graph/CMakeLists.txt b/src/graph/CMakeLists.txt index 9054e8a2..b84b830d 100644 --- a/src/graph/CMakeLists.txt +++ b/src/graph/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE graph_src *.cpp) add_library(graph_lib STATIC "${GRAPH_HEADERS}" "${graph_src}") target_link_libraries(graph_lib PUBLIC TBB_unified) +add_dependencies(graph_lib kokkos_external) diff --git a/src/graph_transformations/CMakeLists.txt b/src/graph_transformations/CMakeLists.txt index 6942b48f..08050170 100644 --- a/src/graph_transformations/CMakeLists.txt +++ b/src/graph_transformations/CMakeLists.txt @@ -1,3 +1,4 @@ file(GLOB_RECURSE graphT_src *.cpp) add_library(graphT_lib STATIC "${GRAPHT_HEADERS}" "${graphT_src}") target_link_libraries(graphT_lib PUBLIC TBB_unified) +add_dependencies(graphT_lib kokkos_external) diff --git a/src/layers_oneDNN/CMakeLists.txt b/src/layers_oneDNN/CMakeLists.txt index e4ee067e..23763d82 100644 --- a/src/layers_oneDNN/CMakeLists.txt +++ b/src/layers_oneDNN/CMakeLists.txt @@ -1,6 +1,7 @@ file(GLOB_RECURSE layers_oneDNN_src *.cpp) add_library(layers_oneDNN_lib STATIC "${LAYERS_ONEDNN_HEADERS}" "${layers_oneDNN_src}") target_link_libraries(layers_oneDNN_lib PUBLIC dnnl TBB_unified) +add_dependencies(layers_oneDNN_lib kokkos_external) target_include_directories(layers_oneDNN_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include ) From 2026ace277b6b2f14a529d4f4f94e50757bec9ab Mon Sep 17 00:00:00 2001 From: AndreySorokin7 Date: Sun, 28 Dec 2025 20:43:22 +0300 Subject: [PATCH 31/33] fix --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c8259c0..6cb6861d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,11 +58,9 @@ target_link_directories(Kokkos_imported INTERFACE "${KOKKOS_INSTALL_DIR}/lib" ) -if(WIN32) - target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) -else() - target_link_libraries(Kokkos_imported INTERFACE kokkos) -endif() + +target_link_libraries(Kokkos_imported INTERFACE kokkoscore kokkoscontainers) + if(MSVC) add_compile_options(/wd4267 /wd4244 /wd4127 /wd4324) From baacd775669a4c8e9c3a102258148da27b3578db Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sun, 28 Dec 2025 20:58:59 +0300 Subject: [PATCH 32/33] Update build.cpp --- app/Graph/build.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Graph/build.cpp b/app/Graph/build.cpp index 8391a834..ab120465 100644 --- a/app/Graph/build.cpp +++ b/app/Graph/build.cpp @@ -211,7 +211,6 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input, for (const auto& [source_name, target_name] : connection_list) { if (name_to_layer_ptr.contains(source_name) && name_to_layer_ptr.contains(target_name)) { - if (target_name.find("Concat") != std::string::npos || name_to_layer[target_name]->getName() == it_lab_ai::kConcat) { if (concat_connections.find(target_name) != concat_connections.end()) { From e1093e09c328f8e48d4d653011adb6c08214baa3 Mon Sep 17 00:00:00 2001 From: AndreySorokin7 <129724280+AndreySorokin7@users.noreply.github.com> Date: Sun, 28 Dec 2025 21:05:29 +0300 Subject: [PATCH 33/33] Replace name_to_layer_ptr with name_to_layer --- app/Graph/build.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Graph/build.cpp b/app/Graph/build.cpp index ab120465..c4ee7fe9 100644 --- a/app/Graph/build.cpp +++ b/app/Graph/build.cpp @@ -196,12 +196,12 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input, try { std::sort(connection_list.begin(), connection_list.end(), [&](const auto& a, const auto& b) { - if (!name_to_layer_ptr.contains(a.first) || - !name_to_layer_ptr.contains(b.first)) { + if (!name_to_layer.contains(a.first) || + !name_to_layer.contains(b.first)) { return false; } - return name_to_layer_ptr[a.first]->getID() < - name_to_layer_ptr[b.first]->getID(); + return name_to_layer[a.first]->getID() < + name_to_layer[b.first]->getID(); }); } catch (const std::exception& e) { @@ -209,8 +209,8 @@ void build_graph(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input, } for (const auto& [source_name, target_name] : connection_list) { - if (name_to_layer_ptr.contains(source_name) && - name_to_layer_ptr.contains(target_name)) { + if (name_to_layer.contains(source_name) && + name_to_layer.contains(target_name)) { if (target_name.find("Concat") != std::string::npos || name_to_layer[target_name]->getName() == it_lab_ai::kConcat) { if (concat_connections.find(target_name) != concat_connections.end()) {