Skip to content

Commit 11d5777

Browse files
committed
Add example_processes task with MPI and SEQ modes
Implemented new task structure under `example_processes` with support for MPI and SEQ modes. Added functional and performance tests, updated CMake files and settings, and integrated with the existing testing framework.
1 parent 54f5e9a commit 11d5777

32 files changed

Lines changed: 344 additions & 63 deletions

File tree

3rdparty/stb_image_wrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define STB_IMAGE_IMPLEMENTATION
2+
#include "stb_library.hpp"

3rdparty/stb_library.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#pragma clang diagnostic ignored "-Wcast-align"
66
#endif
77

8-
#define STB_IMAGE_IMPLEMENTATION
98
#include <stb/stb_image.h>
109

1110
#if defined(__clang__)

modules/core/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ if( MPI_LINK_FLAGS )
6464
endif( MPI_LINK_FLAGS )
6565
target_link_libraries(${exec_func_lib} PUBLIC ${MPI_LIBRARIES})
6666

67-
target_link_directories(${exec_func_lib} INTERFACE ${CMAKE_SOURCE_DIR}/3rdparty/stb)
67+
68+
add_library(stb_image STATIC ${CMAKE_SOURCE_DIR}/3rdparty/stb_image_wrapper.cpp)
69+
target_include_directories(stb_image PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty/stb)
70+
target_link_libraries(${exec_func_lib} PUBLIC stb_image)
6871

6972
add_executable(${exec_func_tests} ${FUNC_TESTS_SOURCE_FILES})
7073

modules/core/util/include/util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace ppc::util {
2929

3030
enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
3131

32-
std::string GetAbsolutePath(const std::string &relative_path);
32+
std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
3333
int GetNumThreads();
3434

3535
template <typename T>

modules/core/util/src/util.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66
#include <libenvpp/env.hpp>
77
#include <string>
88

9-
std::string ppc::util::GetAbsolutePath(const std::string& relative_path) {
9+
namespace {
10+
11+
static std::string GetAbsolutePath(const std::string& relative_path) {
1012
const std::filesystem::path path = std::string(PPC_PATH_TO_PROJECT) + "/tasks/" + relative_path;
1113
return path.string();
1214
}
1315

16+
} // namespace
17+
18+
std::string ppc::util::GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path) {
19+
return GetAbsolutePath(id_path + "/data/" + relative_path);
20+
}
21+
1422
int ppc::util::GetNumThreads() {
1523
const auto num_threads = env::get<int>("PPC_NUM_THREADS");
1624
if (num_threads.has_value()) {

tasks/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ set(exec_perf_tests "ppc_perf_tests")
77
# Init func tests executable files
88
set(list_of_exec_tests "")
99
if (USE_FUNC_TESTS)
10-
add_executable(${exec_func_tests} "${CMAKE_CURRENT_SOURCE_DIR}/common/runners/functional.cpp"
11-
"../modules/core/util/func_tests/util.cpp")
10+
add_executable(${exec_func_tests} "${CMAKE_CURRENT_SOURCE_DIR}/common/runners/functional.cpp")
1211
list(APPEND list_of_exec_tests ${exec_func_tests})
1312
endif (USE_FUNC_TESTS)
1413

@@ -26,13 +25,11 @@ foreach(subd ${subdirs})
2625

2726
set(SETTINGS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${subd}/settings.json")
2827
add_compile_definitions(PPC_SETTINGS_${subd}=\"${SETTINGS_PATH}\")
28+
add_compile_definitions(PPC_ID_${subd}=\"${subd}\")
2929
3030
add_subdirectory(${subd})
3131
endforeach()
3232
33-
# Link 3rdparty libraries
34-
add_library(stb_image INTERFACE)
35-
3633
foreach (exec_func ${list_of_exec_tests})
3734
enable_testing()
3835
add_test(NAME ${exec_func} COMMAND ${exec_func})
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
get_filename_component(CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
2+
project(CURRENT_DIR_NAME)
3+
4+
set(exec_func_tests "ppc_func_tests")
5+
set(exec_perf_tests "ppc_perf_tests")
6+
set(test_base_dir "${CMAKE_CURRENT_SOURCE_DIR}/tests")
7+
8+
# Init func tests executable files
9+
set(list_of_exec_tests "")
10+
if (USE_FUNC_TESTS)
11+
file(GLOB_RECURSE func_tests_source_files "${test_base_dir}/functional/*")
12+
target_sources(${exec_func_tests} PRIVATE ${func_tests_source_files})
13+
list(APPEND list_of_exec_tests ${exec_func_tests})
14+
endif (USE_FUNC_TESTS)
15+
16+
# Init perf tests executable files
17+
if (USE_PERF_TESTS)
18+
file(GLOB_RECURSE perf_tests_source_files "${test_base_dir}/performance/*")
19+
target_sources(${exec_perf_tests} PRIVATE ${perf_tests_source_files})
20+
list(APPEND list_of_exec_tests ${exec_perf_tests})
21+
endif (USE_PERF_TESTS)
22+
23+
# Print student task name
24+
get_filename_component(TASK_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
25+
message(STATUS "-- ${TASK_NAME}")
26+
27+
set(technologies "all" "mpi" "omp" "seq" "stl" "tbb")
28+
29+
# Create lib
30+
foreach (dir_type ${technologies})
31+
# Check directory existing
32+
set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}/${dir_type}")
33+
if (NOT EXISTS "${base_dir}")
34+
continue()
35+
endif ()
36+
37+
# Print type of directories
38+
message(STATUS "-- -- ${dir_type}")
39+
40+
# Create task library
41+
file(GLOB_RECURSE lib_source_files "${base_dir}/include/*" "${base_dir}/src/*")
42+
file(GLOB source_files "${base_dir}/src/*")
43+
44+
list(LENGTH source_files result_length)
45+
set(name_lib "${TASK_NAME}_${dir_type}")
46+
if(result_length EQUAL 0)
47+
add_library(${name_lib} INTERFACE ${lib_source_files})
48+
else()
49+
add_library(${name_lib} STATIC ${lib_source_files})
50+
endif()
51+
set_target_properties(${name_lib} PROPERTIES LINKER_LANGUAGE CXX)
52+
target_link_libraries(${name_lib} PUBLIC core_module_lib)
53+
54+
# Link core library
55+
foreach (exec_func ${list_of_exec_tests})
56+
target_link_libraries(${exec_func} PUBLIC ${name_lib})
57+
endforeach ()
58+
endforeach ()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <utility>
4+
#include <vector>
5+
6+
#include "core/task/include/task.hpp"
7+
#include "core/util/include/util.hpp"
8+
9+
namespace nesterov_a_test_task_processes {
10+
11+
using InType = int;
12+
using OutType = int;
13+
using TestType = std::tuple<int, std::string>;
14+
using BaseTask = ppc::core::Task<InType, OutType>;
15+
16+
} // namespace nesterov_a_test_task_processes
15 KB
Loading

tasks/example_processes/info.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"student": {
3+
"first_name": "Нестеров",
4+
"last_name": "Александр",
5+
"middle_name": "Юрьевич",
6+
"group_number": "АБВ-123"
7+
}
8+
}

0 commit comments

Comments
 (0)