diff --git a/.github/labeler.yml b/.github/labeler.yml index 1fb12bf6b..cfee42ee1 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -16,7 +16,6 @@ ci: core: - "modules/core/**" samples: - - "1stsamples/**" - "modules/ref/**" 3rdparty: - "3rdparty/**" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aec57b388..4a7efde44 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,9 +63,9 @@ jobs: env: CC: gcc-13 CXX: g++-13 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: gcc-13 CXX: g++-13 @@ -142,9 +142,9 @@ jobs: env: CC: gcc-13 CXX: g++-13 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: gcc-13 CXX: g++-13 @@ -214,9 +214,9 @@ jobs: env: CC: clang-19 CXX: clang++-19 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: clang-19 CXX: clang++-19 @@ -293,9 +293,9 @@ jobs: env: CC: clang-19 CXX: clang++-19 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: clang-19 CXX: clang++-19 @@ -364,9 +364,9 @@ jobs: env: CC: clang-19 CXX: clang++-19 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: clang-19 CXX: clang++-19 @@ -430,9 +430,9 @@ jobs: env: CC: clang-19 CXX: clang++-19 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: clang-19 CXX: clang++-19 @@ -505,9 +505,9 @@ jobs: -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -DCMAKE_C_FLAGS="-I$(brew --prefix)/opt/libomp/include" -DCMAKE_CXX_FLAGS="-I$(brew --prefix)/opt/libomp/include" -D CMAKE_BUILD_TYPE=RELEASE -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel - name: Run func tests (MPI, num_proc=1) run: | source scripts/run_mpi.sh @@ -576,9 +576,9 @@ jobs: -G Ninja -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -DCMAKE_C_FLAGS="-I$(brew --prefix)/opt/libomp/include" -DCMAKE_CXX_FLAGS="-I$(brew --prefix)/opt/libomp/include" -D CMAKE_BUILD_TYPE=RELEASE -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel - name: Run tests (threads, num_threads=5) run: source scripts/run_threads.sh env: @@ -650,7 +650,7 @@ jobs: -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE - - name: MSBuild + - name: Build project shell: bash run: | cmake --build build --config Release --parallel @@ -708,7 +708,7 @@ jobs: -D USE_SEQ=ON -D USE_MPI=ON -D USE_OMP=ON -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE - - name: MSBuild + - name: Build project shell: bash run: | cmake --build build --config Release --parallel @@ -766,14 +766,14 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: CMake configure run: > - cmake -S . -B build -GNinja -D CMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl + cmake -S . -B build -D CMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -D USE_SEQ=ON -D USE_MPI=OFF -D USE_OMP=OFF -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE env: CC: clang-cl CXX: clang-cl - - name: Ninja build + - name: Build project run: | cmake --build build --config Release --parallel -v env: @@ -820,14 +820,14 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: CMake configure run: > - cmake -S . -B build -GNinja -D CMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl + cmake -S . -B build -D CMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -D USE_SEQ=ON -D USE_MPI=OFF -D USE_OMP=OFF -D USE_TBB=ON -D USE_STL=ON -D USE_FUNC_TESTS=ON -D USE_PERF_TESTS=ON -D CMAKE_BUILD_TYPE=RELEASE env: CC: clang-cl CXX: clang-cl - - name: Ninja build + - name: Build project run: | cmake --build build --config Release --parallel -v env: @@ -906,7 +906,7 @@ jobs: -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_VERBOSE_MAKEFILE=ON -D USE_COVERAGE=ON - - name: Ninja build + - name: Build project run: | cmake --build build --parallel - name: Run tests (MPI) @@ -994,9 +994,9 @@ jobs: env: CC: gcc-12 CXX: g++-12 - - name: Ninja build + - name: Build project run: | - cmake --build build + cmake --build build --parallel env: CC: gcc-12 CXX: g++-12 diff --git a/.gitmodules b/.gitmodules index ec1da98db..9f0c5e6c3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "3rdparty/onetbb"] path = 3rdparty/onetbb url = https://github.com/uxlfoundation/oneTBB +[submodule "3rdparty/opencv"] + path = 3rdparty/opencv + url = https://github.com/opencv/opencv diff --git a/1stsamples/CMakeLists.txt b/1stsamples/CMakeLists.txt deleted file mode 100644 index dda80e6c9..000000000 --- a/1stsamples/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -message(STATUS "First samples") - -SUBDIRLIST(subdirs ${CMAKE_CURRENT_SOURCE_DIR}) - -foreach(subd ${subdirs}) - add_subdirectory(${subd}) -endforeach() diff --git a/1stsamples/mpi/CMakeLists.txt b/1stsamples/mpi/CMakeLists.txt deleted file mode 100644 index ad0a0d998..000000000 --- a/1stsamples/mpi/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -get_filename_component(Project_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(Project_ID "sample_${Project_ID}") -message( STATUS "-- " ${Project_ID} ) - -if(USE_MPI) - add_executable( ${Project_ID} main.cpp ) - - if(MPI_COMPILE_FLAGS) - set_target_properties( ${Project_ID} PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}" ) - endif(MPI_COMPILE_FLAGS) - - if(MPI_LINK_FLAGS) - set_target_properties( ${Project_ID} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}" ) - endif(MPI_LINK_FLAGS) - - target_link_libraries(${Project_ID} ${MPI_LIBRARIES}) -endif() \ No newline at end of file diff --git a/1stsamples/mpi/main.cpp b/1stsamples/mpi/main.cpp deleted file mode 100644 index 638a2c005..000000000 --- a/1stsamples/mpi/main.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -#include - -int main(int argc, char** argv) { - MPI_Init(&argc, &argv); - - int world_size; - MPI_Comm_size(MPI_COMM_WORLD, &world_size); - - int world_rank; - MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); - - char processor_name[MPI_MAX_PROCESSOR_NAME]; - int len_chars; - MPI_Get_processor_name(processor_name, &len_chars); - - MPI_Barrier(MPI_COMM_WORLD); - std::cout << "Processor = " << processor_name << '\n'; - std::cout << "Rank = " << world_rank << '\n'; - std::cout << "Number of processors = " << world_size << '\n'; - - MPI_Finalize(); - return 0; -} \ No newline at end of file diff --git a/1stsamples/mpi_boost/CMakeLists.txt b/1stsamples/mpi_boost/CMakeLists.txt deleted file mode 100644 index a9ad9a4a9..000000000 --- a/1stsamples/mpi_boost/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -get_filename_component(Project_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(Project_ID "sample_${Project_ID}") -message( STATUS "-- " ${Project_ID} ) - -if(USE_MPI) - add_executable( ${Project_ID} main.cpp ) - - if (MPI_COMPILE_FLAGS) - set_target_properties( ${Project_ID} PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}" ) - endif (MPI_COMPILE_FLAGS) - - if (MPI_LINK_FLAGS) - set_target_properties( ${Project_ID} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}" ) - endif (MPI_LINK_FLAGS) - - target_link_libraries(${Project_ID} PUBLIC ${MPI_LIBRARIES}) - add_dependencies(${Project_ID} ppc_boost) - target_link_directories(${Project_ID} PUBLIC ${CMAKE_BINARY_DIR}/ppc_boost/install/lib) - if (NOT MSVC) - target_link_libraries(${Project_ID} PUBLIC boost_mpi) - endif () -endif() diff --git a/1stsamples/mpi_boost/main.cpp b/1stsamples/mpi_boost/main.cpp deleted file mode 100644 index 86a42f516..000000000 --- a/1stsamples/mpi_boost/main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#include -#include -#include -#include - -// https://www.boost.org/doc/libs/1_68_0/doc/html/mpi/tutorial.html -int main(int argc, char** argv) { - boost::mpi::environment env(argc, argv); - boost::mpi::communicator world; - - world.barrier(); - std::cout << "Processor = " << boost::mpi::environment::processor_name() << '\n'; - std::cout << "Rank = " << world.rank() << '\n'; - std::cout << "Number of processors = " << world.size() << '\n'; - - return 0; -} diff --git a/1stsamples/omp/CMakeLists.txt b/1stsamples/omp/CMakeLists.txt deleted file mode 100644 index 7cfc5320b..000000000 --- a/1stsamples/omp/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -get_filename_component(Project_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(Project_ID "sample_${Project_ID}") -message( STATUS "-- " ${Project_ID} ) - -if(USE_OMP) - add_executable( ${Project_ID} main.cpp ) - target_link_libraries(${Project_ID} PUBLIC ${OpenMP_libomp_LIBRARY}) -endif() \ No newline at end of file diff --git a/1stsamples/omp/main.cpp b/1stsamples/omp/main.cpp deleted file mode 100644 index 7b44a37d3..000000000 --- a/1stsamples/omp/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include - -int main() { -#pragma omp parallel - { - std::cout << "Thread number = " << omp_get_thread_num() << '\n'; - std::cout << "Number of threads = " << omp_get_num_threads() << '\n'; - } - return 0; -} \ No newline at end of file diff --git a/1stsamples/stl/CMakeLists.txt b/1stsamples/stl/CMakeLists.txt deleted file mode 100644 index 342002f92..000000000 --- a/1stsamples/stl/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -get_filename_component(Project_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(Project_ID "sample_${Project_ID}") -message( STATUS "-- " ${Project_ID} ) - -if(USE_STL) - add_executable(${Project_ID} main.cpp) - target_link_libraries(${Project_ID} PUBLIC Threads::Threads) -endif() \ No newline at end of file diff --git a/1stsamples/stl/main.cpp b/1stsamples/stl/main.cpp deleted file mode 100644 index f3a04339c..000000000 --- a/1stsamples/stl/main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -namespace { -void Task(const std::string& msg) { std::cout << "thread number: " + msg << '\n'; } -} // namespace - -int main() { - const auto num_max_threads = std::thread::hardware_concurrency(); - std::cout << "Number of threads = " << num_max_threads << '\n'; - std::vector thr(num_max_threads); - - for (unsigned int i = 0; i < num_max_threads; ++i) { - thr[i] = std::thread(Task, std::to_string(i)); - } - - for (unsigned int i = 0; i < num_max_threads; ++i) { - thr[i].join(); - } - return 0; -} \ No newline at end of file diff --git a/1stsamples/tbb/CMakeLists.txt b/1stsamples/tbb/CMakeLists.txt deleted file mode 100644 index 61b98ff55..000000000 --- a/1stsamples/tbb/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -get_filename_component(Project_ID ${CMAKE_CURRENT_SOURCE_DIR} NAME) -set(Project_ID "sample_${Project_ID}") -message( STATUS "-- " ${Project_ID} ) - -if(USE_TBB) - add_executable( ${Project_ID} main.cpp ) - add_dependencies(${Project_ID} ppc_onetbb) - target_link_directories(${Project_ID} PUBLIC ${CMAKE_BINARY_DIR}/ppc_onetbb/install/lib) - if(NOT MSVC) - target_link_libraries(${Project_ID} PUBLIC tbb) - endif() -endif() \ No newline at end of file diff --git a/1stsamples/tbb/main.cpp b/1stsamples/tbb/main.cpp deleted file mode 100644 index d8058ea4b..000000000 --- a/1stsamples/tbb/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#include - -namespace { -int FibFunc(int n) { - if (n < 2) { - return n; - } - int x; - int y; - oneapi::tbb::task_group g; - g.run([&] { x = FibFunc(n - 1); }); - g.run([&] { y = FibFunc(n - 2); }); - g.wait(); - return x + y; -} -} // namespace - -int main() { return FibFunc(10) - 55; } diff --git a/3rdparty/opencv b/3rdparty/opencv new file mode 160000 index 000000000..31b0eeea0 --- /dev/null +++ b/3rdparty/opencv @@ -0,0 +1 @@ +Subproject commit 31b0eeea0b44b370fd0712312df4214d4ae1b158 diff --git a/CMakeLists.txt b/CMakeLists.txt index e0e7fba65..a6d2b0636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,82 +1,38 @@ cmake_minimum_required( VERSION 3.25 ) +message( STATUS "Parallel Programming Course (PPC)" ) project(parallel_programming_course) -message( STATUS "Parallel Programming Course" ) -include(cmake/configure.cmake) -include(cmake/gtest.cmake) +############################ Configures ############################# -option(ENABLE_ADDRESS_SANITIZER OFF) +message( STATUS "PPC step: First configures" ) +include(cmake/configure.cmake) +include(cmake/modes.cmake) include(cmake/sanitizers.cmake) -################################ MPI ################################ -option(USE_MPI OFF) -if( USE_MPI ) - find_package( MPI ) - if( MPI_FOUND ) - include_directories( ${MPI_INCLUDE_PATH} ) - else( MPI_FOUND ) - set( USE_MPI OFF ) - endif( MPI_FOUND ) - include(cmake/boost.cmake) -endif( USE_MPI ) - -############################### OpenMP ############################## -option(USE_OMP OFF) -if( USE_OMP ) - find_package( OpenMP ) - if( OpenMP_FOUND ) - include_directories( ${OpenMP_C_INCLUDE_DIRS} ${OpenMP_CXX_INCLUDE_DIRS} ) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") - if ( MSVC AND MSVC_VERSION GREATER 1919 ) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp:experimental") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp:experimental") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - add_compile_options(/openmp:experimental) - endif() - else( OpenMP_FOUND ) - if (WIN32) - message(WARNING "OpenMP NOT FOUND") - else() - message(FATAL_ERROR "OpenMP NOT FOUND") - endif() - endif( OpenMP_FOUND ) -endif( USE_OMP ) - -############################ std::thread ############################ -option(USE_STL OFF) -if( USE_STL ) - find_package( Threads ) -endif( USE_STL ) +################# Parallel programming technologies ################# -################################ TBB ################################ -option(USE_TBB OFF) -if( USE_TBB ) - include(cmake/onetbb.cmake) -endif( USE_TBB ) +message( STATUS "PPC step: Setup parallel programming technologies" ) +include(cmake/mpi.cmake) +include(cmake/openmp.cmake) +include(cmake/threads.cmake) +include(cmake/onetbb.cmake) -######################### Functional mode ########################## -option(USE_FUNC_TESTS OFF) -if( USE_FUNC_TESTS ) - message( STATUS "Enable functional tests" ) - add_compile_definitions(USE_FUNC_TESTS) -endif( USE_FUNC_TESTS ) +######################### External projects ######################### -######################### Performance mode ########################## -option(USE_PERF_TESTS OFF) -if( USE_PERF_TESTS ) - message( STATUS "Enable performance tests" ) - add_compile_definitions(USE_PERF_TESTS) -endif( USE_PERF_TESTS ) +message( STATUS "PPC step: Setup external projects" ) +include(cmake/opencv.cmake) +include(cmake/gtest.cmake) -############################## Modules ############################## +############################## Headers ############################## +message( STATUS "PPC step: Setup headers" ) include_directories(3rdparty) include_directories(modules) include_directories(tasks) +############################## Modules ############################## + +message( STATUS "PPC step: Setup modules" ) add_subdirectory(modules) add_subdirectory(tasks) -add_subdirectory(1stsamples) diff --git a/cmake/boost.cmake b/cmake/boost.cmake index 9fccb2a4f..9bd1b0dad 100644 --- a/cmake/boost.cmake +++ b/cmake/boost.cmake @@ -13,6 +13,7 @@ ExternalProject_Add(ppc_boost CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/boost/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_boost/build/" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBOOST_ENABLE_MPI=ON -D MPI_INCLUDE_PATH=${MPI_INCLUDE_PATH} -D MPI_LIBRARIES=${MPI_LIBRARIES} -D MPI_COMPILE_FLAGS=${MPI_COMPILE_FLAGS} -D MPI_LINK_FLAGS=${MPI_LINK_FLAGS} + -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_boost/build" --config ${CMAKE_BUILD_TYPE} --parallel INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_boost/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_boost/install" TEST_COMMAND "") diff --git a/cmake/configure.cmake b/cmake/configure.cmake index 3810aa05a..18776fa7a 100644 --- a/cmake/configure.cmake +++ b/cmake/configure.cmake @@ -46,16 +46,3 @@ if( MSVC ) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 /wd4267 /wd4244 /wd4100 /WX") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4267 /wd4244 /wd4100 /WX" ) endif( MSVC ) - -add_compile_definitions(PPC_PATH_TO_PROJECT="${CMAKE_CURRENT_SOURCE_DIR}") - -MACRO(SUBDIRLIST result curdir) - FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) - SET(dirlist "") - FOREACH(child ${children}) - IF(IS_DIRECTORY ${curdir}/${child}) - LIST(APPEND dirlist ${child}) - ENDIF() - ENDFOREACH() - SET(${result} ${dirlist}) -ENDMACRO() diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake index 63d0b68b8..b574bd83a 100644 --- a/cmake/gtest.cmake +++ b/cmake/gtest.cmake @@ -8,6 +8,6 @@ ExternalProject_Add(ppc_googletest INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/install" CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/googletest/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/build/" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -Dgtest_force_shared_crt=ON -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" + -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -Dgtest_force_shared_crt=ON -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/build" --config ${CMAKE_BUILD_TYPE} --parallel INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_googletest/install") diff --git a/cmake/modes.cmake b/cmake/modes.cmake new file mode 100644 index 000000000..ee787ccd0 --- /dev/null +++ b/cmake/modes.cmake @@ -0,0 +1,24 @@ +add_compile_definitions(PPC_PATH_TO_PROJECT="${CMAKE_CURRENT_SOURCE_DIR}") + +MACRO(SUBDIRLIST result curdir) + FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) + SET(dirlist "") + FOREACH(child ${children}) + IF(IS_DIRECTORY ${curdir}/${child}) + LIST(APPEND dirlist ${child}) + ENDIF() + ENDFOREACH() + SET(${result} ${dirlist}) +ENDMACRO() + +option(USE_FUNC_TESTS OFF) +if( USE_FUNC_TESTS ) + message( STATUS "Enable functional tests" ) + add_compile_definitions(USE_FUNC_TESTS) +endif( USE_FUNC_TESTS ) + +option(USE_PERF_TESTS OFF) +if( USE_PERF_TESTS ) + message( STATUS "Enable performance tests" ) + add_compile_definitions(USE_PERF_TESTS) +endif( USE_PERF_TESTS ) diff --git a/cmake/mpi.cmake b/cmake/mpi.cmake new file mode 100644 index 000000000..460e8ab58 --- /dev/null +++ b/cmake/mpi.cmake @@ -0,0 +1,10 @@ +option(USE_MPI OFF) +if( USE_MPI ) + find_package( MPI ) + if( MPI_FOUND ) + include_directories( ${MPI_INCLUDE_PATH} ) + else( MPI_FOUND ) + set( USE_MPI OFF ) + endif( MPI_FOUND ) + include(cmake/boost.cmake) +endif( USE_MPI ) diff --git a/cmake/onetbb.cmake b/cmake/onetbb.cmake index 096b6b5a9..f565aed09 100644 --- a/cmake/onetbb.cmake +++ b/cmake/onetbb.cmake @@ -1,26 +1,31 @@ -# Build Core OneTBB components -include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onetbb/include) +option(USE_TBB OFF) +if( USE_TBB ) + # Build Core OneTBB components + include_directories(${CMAKE_SOURCE_DIR}/3rdparty/onetbb/include) -include(ExternalProject) -if(MSVC) - ExternalProject_Add(ppc_onetbb - SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/onetbb" - PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" - INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" - CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/onetbb/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build/" -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --config ${CMAKE_BUILD_TYPE} --parallel - INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" - TEST_COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install/bin" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") -else(MSVC) - ExternalProject_Add(ppc_onetbb - SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/onetbb" - PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" - INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" - CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/onetbb/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build/" -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --config ${CMAKE_BUILD_TYPE} --parallel - INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install") -endif(MSVC) + include(ExternalProject) + if(WIN32) + ExternalProject_Add(ppc_onetbb + SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/onetbb" + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/onetbb/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build/" -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} + -G${CMAKE_GENERATOR} -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --config ${CMAKE_BUILD_TYPE} --parallel + INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" + TEST_COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install/bin" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + else() + ExternalProject_Add(ppc_onetbb + SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/onetbb" + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/onetbb/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build/" -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} + -G${CMAKE_GENERATOR} -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --config ${CMAKE_BUILD_TYPE} --parallel + INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_onetbb/install") + endif() +endif( USE_TBB ) diff --git a/cmake/opencv.cmake b/cmake/opencv.cmake new file mode 100644 index 000000000..90d2ec1c2 --- /dev/null +++ b/cmake/opencv.cmake @@ -0,0 +1,30 @@ +# Build OpenCV components +# core highgui imgcodecs imgproc videoio +include(ExternalProject) +include_directories(${CMAKE_SOURCE_DIR}/3rdparty/opencv/include) +if(WIN32) + ExternalProject_Add(ppc_opencv + SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/opencv" + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/install" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/opencv/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build/" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} + -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" -DENABLE_CCACHE=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF + -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_CUDA=OFF -DWITH_OPENCL=OFF -DBUILD_LIST="core,highgui,imgcodecs,imgproc,videoio," + BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" --config ${CMAKE_BUILD_TYPE} --parallel + INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/install" + TEST_COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build/bin" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +else() + ExternalProject_Add(ppc_opencv + SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/opencv" + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/install" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_SOURCE_DIR}/3rdparty/opencv/" -B "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build/" + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -G${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D CMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} + -D CMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DCMAKE_CXX_FLAGS="-w" -DCMAKE_C_FLAGS="-w" -DENABLE_CCACHE=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF + -DBUILD_EXAMPLES=OFF -DBUILD_DOCS=OFF -DWITH_CUDA=OFF -DWITH_OPENCL=OFF -DBUILD_LIST="core,highgui,imgcodecs,imgproc,videoio," + BUILD_COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" --config ${CMAKE_BUILD_TYPE} --parallel + INSTALL_COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/build" --prefix "${CMAKE_CURRENT_BINARY_DIR}/ppc_opencv/install") +endif() diff --git a/cmake/openmp.cmake b/cmake/openmp.cmake new file mode 100644 index 000000000..e94fd3e64 --- /dev/null +++ b/cmake/openmp.cmake @@ -0,0 +1,16 @@ +option(USE_OMP OFF) +if( USE_OMP ) + find_package( OpenMP ) + if( OpenMP_FOUND ) + include_directories( ${OpenMP_C_INCLUDE_DIRS} ${OpenMP_CXX_INCLUDE_DIRS} ) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + else( OpenMP_FOUND ) + if (WIN32) + message(WARNING "OpenMP NOT FOUND") + else() + message(FATAL_ERROR "OpenMP NOT FOUND") + endif() + endif( OpenMP_FOUND ) +endif( USE_OMP ) diff --git a/cmake/sanitizers.cmake b/cmake/sanitizers.cmake index fd32d7daa..d0726be15 100644 --- a/cmake/sanitizers.cmake +++ b/cmake/sanitizers.cmake @@ -1,3 +1,4 @@ +option(ENABLE_ADDRESS_SANITIZER OFF) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (ENABLE_ADDRESS_SANITIZER) add_compile_options(-fsanitize=address) diff --git a/cmake/threads.cmake b/cmake/threads.cmake new file mode 100644 index 000000000..be534ffd9 --- /dev/null +++ b/cmake/threads.cmake @@ -0,0 +1,4 @@ +option(USE_STL OFF) +if( USE_STL ) + find_package( Threads ) +endif( USE_STL ) diff --git a/modules/core/task/include/task.hpp b/modules/core/task/include/task.hpp index 2018226c5..bfaa236ee 100644 --- a/modules/core/task/include/task.hpp +++ b/modules/core/task/include/task.hpp @@ -70,9 +70,9 @@ class Task { std::chrono::high_resolution_clock::time_point tmp_time_point_; }; -inline std::filesystem::path GetAbsolutePath(const std::string &relative_path) { - std::filesystem::path path = std::string(PPC_PATH_TO_PROJECT) + "/tasks/" + relative_path; - return path; +inline std::string GetAbsolutePath(const std::string &relative_path) { + const std::filesystem::path path = std::string(PPC_PATH_TO_PROJECT) + "/tasks/" + relative_path; + return path.string(); } } // namespace ppc::core diff --git a/scripts/run.bat b/scripts/run.bat index bc20417e3..f6dfba950 100644 --- a/scripts/run.bat +++ b/scripts/run.bat @@ -3,12 +3,6 @@ build\bin\core_func_tests.exe --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating || exit 1 build\bin\ref_func_tests.exe --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating || exit 1 -if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\sample_mpi.exe -if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\sample_mpi_boost.exe -if "%CLANG_BUILD%" NEQ "1" build\bin\sample_omp.exe -build\bin\sample_stl.exe -build\bin\sample_tbb.exe - if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\all_func_tests.exe --gtest_repeat=10 || exit 1 if "%CLANG_BUILD%" NEQ "1" mpiexec.exe -np 4 build\bin\mpi_func_tests.exe --gtest_repeat=10 || exit 1 if "%CLANG_BUILD%" NEQ "1" build\bin\all_func_tests.exe || exit 1 diff --git a/scripts/run_mpi.sh b/scripts/run_mpi.sh index 9eb1bac5f..92d2835a9 100644 --- a/scripts/run_mpi.sh +++ b/scripts/run_mpi.sh @@ -1,4 +1,5 @@ #!/bin/bash +source build/ppc_opencv/install/bin/setup_vars_opencv4.sh if [[ $OSTYPE == "linux-gnu" && -z "$ASAN_RUN" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/core_func_tests @@ -12,8 +13,6 @@ fi ./build/bin/ref_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating if [[ -z "$ASAN_RUN" ]]; then - mpirun $1 -np $PROC_COUNT ./build/bin/sample_mpi - mpirun $1 -np $PROC_COUNT ./build/bin/sample_mpi_boost mpirun $1 -np $PROC_COUNT ./build/bin/all_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating mpirun $1 -np $PROC_COUNT ./build/bin/mpi_func_tests --gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating fi diff --git a/scripts/run_perf_collector.sh b/scripts/run_perf_collector.sh index f319b0f0d..6c58772e2 100644 --- a/scripts/run_perf_collector.sh +++ b/scripts/run_perf_collector.sh @@ -1,4 +1,5 @@ #!/bin/bash +source build/ppc_opencv/install/bin/setup_vars_opencv4.sh if [[ -z "$ASAN_RUN" ]]; then if [[ $OSTYPE == "linux-gnu" ]]; then diff --git a/scripts/run_threads.sh b/scripts/run_threads.sh index 947e935a1..731276bc8 100644 --- a/scripts/run_threads.sh +++ b/scripts/run_threads.sh @@ -1,4 +1,5 @@ #!/bin/bash +source build/ppc_opencv/install/bin/setup_vars_opencv4.sh if [[ $OSTYPE == "linux-gnu" && -z "$ASAN_RUN" ]]; then valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all ./build/bin/core_func_tests @@ -13,10 +14,6 @@ fi ./build/bin/core_func_tests --gtest_also_run_disabled_tests --gtest_repeat=3 --gtest_recreate_environments_when_repeating ./build/bin/ref_func_tests --gtest_also_run_disabled_tests --gtest_repeat=3 --gtest_recreate_environments_when_repeating -./build/bin/sample_omp -./build/bin/sample_stl -./build/bin/sample_tbb - ./build/bin/omp_func_tests --gtest_also_run_disabled_tests --gtest_repeat=3 --gtest_recreate_environments_when_repeating ./build/bin/seq_func_tests --gtest_also_run_disabled_tests --gtest_repeat=3 --gtest_recreate_environments_when_repeating ./build/bin/stl_func_tests --gtest_also_run_disabled_tests --gtest_repeat=3 --gtest_recreate_environments_when_repeating diff --git a/tasks/CMakeLists.txt b/tasks/CMakeLists.txt index 0253dbfb2..1ba576a9d 100644 --- a/tasks/CMakeLists.txt +++ b/tasks/CMakeLists.txt @@ -137,6 +137,28 @@ foreach(TASK_TYPE ${LIST_OF_TASKS}) endif() endif () + add_dependencies(${EXEC_FUNC} ppc_opencv) + if(WIN32) + target_include_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_opencv/install/include") + else() + target_include_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_opencv/install/include/opencv4") + endif() + + + if(WIN32) + target_link_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_opencv/build/lib") + set(OCV_VERSION "4110") + else() + target_link_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_opencv/install/lib") + endif() + + target_link_libraries(${EXEC_FUNC} PUBLIC + opencv_core${OCV_VERSION} + opencv_highgui${OCV_VERSION} + opencv_imgcodecs${OCV_VERSION} + opencv_imgproc${OCV_VERSION} + opencv_videoio${OCV_VERSION}) + add_dependencies(${EXEC_FUNC} ppc_googletest) target_link_directories(${EXEC_FUNC} PUBLIC "${CMAKE_BINARY_DIR}/ppc_googletest/install/lib") target_link_libraries(${EXEC_FUNC} PUBLIC gtest gtest_main) diff --git a/tasks/all/example/data/pic_mpi.jpg b/tasks/all/example/data/pic_mpi.jpg new file mode 100644 index 000000000..f1579e946 Binary files /dev/null and b/tasks/all/example/data/pic_mpi.jpg differ diff --git a/tasks/all/example/data/pic_omp.jpg b/tasks/all/example/data/pic_omp.jpg new file mode 100644 index 000000000..1756d435e Binary files /dev/null and b/tasks/all/example/data/pic_omp.jpg differ diff --git a/tasks/all/example/data/pic_seq.jpg b/tasks/all/example/data/pic_seq.jpg new file mode 100644 index 000000000..344580234 Binary files /dev/null and b/tasks/all/example/data/pic_seq.jpg differ diff --git a/tasks/all/example/data/pic_stl.jpg b/tasks/all/example/data/pic_stl.jpg new file mode 100644 index 000000000..3a1eda306 Binary files /dev/null and b/tasks/all/example/data/pic_stl.jpg differ diff --git a/tasks/all/example/data/pic_tbb.jpg b/tasks/all/example/data/pic_tbb.jpg new file mode 100644 index 000000000..27072f354 Binary files /dev/null and b/tasks/all/example/data/pic_tbb.jpg differ diff --git a/tasks/all/example/data/test_mpi.txt b/tasks/all/example/data/test_mpi.txt deleted file mode 100644 index 8bc658371..000000000 --- a/tasks/all/example/data/test_mpi.txt +++ /dev/null @@ -1 +0,0 @@ -120 \ No newline at end of file diff --git a/tasks/all/example/data/test_omp.txt b/tasks/all/example/data/test_omp.txt deleted file mode 100644 index 7813681f5..000000000 --- a/tasks/all/example/data/test_omp.txt +++ /dev/null @@ -1 +0,0 @@ -5 \ No newline at end of file diff --git a/tasks/all/example/data/test_seq.txt b/tasks/all/example/data/test_seq.txt deleted file mode 100644 index 105d7d9ad..000000000 --- a/tasks/all/example/data/test_seq.txt +++ /dev/null @@ -1 +0,0 @@ -100 \ No newline at end of file diff --git a/tasks/all/example/data/test_stl.txt b/tasks/all/example/data/test_stl.txt deleted file mode 100644 index 3f10ffe7a..000000000 --- a/tasks/all/example/data/test_stl.txt +++ /dev/null @@ -1 +0,0 @@ -15 \ No newline at end of file diff --git a/tasks/all/example/data/test_tbb.txt b/tasks/all/example/data/test_tbb.txt deleted file mode 100644 index 7813681f5..000000000 --- a/tasks/all/example/data/test_tbb.txt +++ /dev/null @@ -1 +0,0 @@ -5 \ No newline at end of file diff --git a/tasks/all/example/func_tests/func_mpi.cpp b/tasks/all/example/func_tests/func_mpi.cpp index 1dbc5c5f6..5f07bdb55 100644 --- a/tasks/all/example/func_tests/func_mpi.cpp +++ b/tasks/all/example/func_tests/func_mpi.cpp @@ -1,8 +1,7 @@ #include #include -#include -#include +#include #include #include @@ -248,14 +247,10 @@ TEST(Parallel_Operations_MPI, Test_Max_2_File) { auto task_data_par = std::make_shared(); if (world.rank() == 0) { - std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_mpi.txt")); - if (test_file.is_open()) { - getline(test_file, line); - } - test_file.close(); - - const int count_size_vector = std::stoi(line); + cv::Mat img = cv::imread(ppc::core::GetAbsolutePath("all/example/data/pic_mpi.jpg")); + EXPECT_EQ(img.rows, img.cols); + const int count_size_vector = img.rows + img.cols; + global_vec = GetRandomVector(count_size_vector); task_data_par->inputs.emplace_back(reinterpret_cast(global_vec.data())); task_data_par->inputs_count.emplace_back(global_vec.size()); diff --git a/tasks/all/example/func_tests/func_omp.cpp b/tasks/all/example/func_tests/func_omp.cpp index 3e590a619..f2e5d1090 100644 --- a/tasks/all/example/func_tests/func_omp.cpp +++ b/tasks/all/example/func_tests/func_omp.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -210,14 +210,11 @@ TEST(Parallel_Operations_OpenMP, Test_Mult_2) { } TEST(Parallel_Operations_OpenMP, Test_Mult_2_File) { - std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_omp.txt")); - if (test_file.is_open()) { - getline(test_file, line); - } - test_file.close(); + cv::Mat img = cv::imread(ppc::core::GetAbsolutePath("all/example/data/pic_omp.jpg")); + EXPECT_EQ(static_cast(sqrt(img.rows) * sqrt(img.rows)), img.cols); + const int count_size_vector = img.rows + img.cols; + std::vector vec = GetRandomVector(count_size_vector); - std::vector vec = GetRandomVector(std::stoi(line)); // Create data std::vector ref_res(1, 0); diff --git a/tasks/all/example/func_tests/func_seq.cpp b/tasks/all/example/func_tests/func_seq.cpp index cda2304e9..823fd3dc3 100644 --- a/tasks/all/example/func_tests/func_seq.cpp +++ b/tasks/all/example/func_tests/func_seq.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include "seq/example/include/ops_seq.hpp" @@ -121,14 +121,9 @@ TEST(Sequential, Test_Sum_100) { } TEST(Sequential, Test_Sum_100_From_File) { - std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_seq.txt")); - if (test_file.is_open()) { - getline(test_file, line); - } - test_file.close(); - - const int count = std::stoi(line); + cv::Mat img = cv::imread(ppc::core::GetAbsolutePath("all/example/data/pic_seq.jpg")); + EXPECT_EQ(img.rows, img.cols); + const int count = img.rows + img.cols; // Create data std::vector in(1, count); diff --git a/tasks/all/example/func_tests/func_stl.cpp b/tasks/all/example/func_tests/func_stl.cpp index 1a3ade05c..372283baa 100644 --- a/tasks/all/example/func_tests/func_stl.cpp +++ b/tasks/all/example/func_tests/func_stl.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include #include @@ -215,14 +215,11 @@ TEST(Parallel_Operations_STL_Threads, Test_Diff_2) { } TEST(Parallel_Operations_STL_Threads, Test_Diff_2_File) { - std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_stl.txt")); - if (test_file.is_open()) { - getline(test_file, line); - } - test_file.close(); + cv::Mat img = cv::imread(ppc::core::GetAbsolutePath("all/example/data/pic_stl.jpg")); + EXPECT_EQ(static_cast(sqrt(img.cols / 2) * sqrt(img.cols / 2)), img.rows); + const int count_size_vector = static_cast(sqrt(sqrt(img.rows))); - auto nthreads = std::thread::hardware_concurrency() * std::stoi(line); + auto nthreads = std::thread::hardware_concurrency() * count_size_vector; std::vector vec = GetRandomVector(static_cast(nthreads)); // Create data std::vector ref_res(1, 0); diff --git a/tasks/all/example/func_tests/func_tbb.cpp b/tasks/all/example/func_tests/func_tbb.cpp index eeb5e3c50..63070eb30 100644 --- a/tasks/all/example/func_tests/func_tbb.cpp +++ b/tasks/all/example/func_tests/func_tbb.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -209,14 +209,11 @@ TEST(Parallel_Operations_TBB, Test_Mult_2) { } TEST(Parallel_Operations_TBB, Test_Mult_2_File) { - std::string line; - std::ifstream test_file(ppc::core::GetAbsolutePath("all/example/data/test_tbb.txt")); - if (test_file.is_open()) { - getline(test_file, line); - } - test_file.close(); + cv::Mat img = cv::imread(ppc::core::GetAbsolutePath("all/example/data/pic_tbb.jpg")); + EXPECT_EQ(static_cast(sqrt(img.rows / 2) * sqrt(img.rows / 2)), img.cols); + const int count_size_vector = img.rows + img.cols; - std::vector vec = GetRandomVector(std::stoi(line)); + std::vector vec = GetRandomVector(count_size_vector); // Create data std::vector ref_res(1, 0);