Skip to content

Commit 73c34b5

Browse files
authored
Refactor core module (#506)
1 parent ebb7c5d commit 73c34b5

File tree

42 files changed

+332
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+332
-346
lines changed

.github/workflows/ubuntu.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ jobs:
379379
--exclude '.*tasks/.*/tests/.*' \
380380
--exclude '.*modules/.*/tests/.*' \
381381
--exclude '.*tasks/common/runners/.*' \
382-
--exclude '.*modules/core/runners/.*' \
383-
--exclude '.*modules/core/util/include/perf_test_util.hpp' \
384-
--exclude '.*modules/core/util/include/func_test_util.hpp' \
385-
--exclude '.*modules/core/util/src/func_test_util.cpp' \
382+
--exclude '.*modules/runners/.*' \
383+
--exclude '.*modules/util/include/perf_test_util.hpp' \
384+
--exclude '.*modules/util/include/func_test_util.hpp' \
385+
--exclude '.*modules/util/src/func_test_util.cpp' \
386386
--xml --output ../coverage.xml \
387387
--html=../cov-report/index.html --html-details
388388
- name: Upload coverage reports to Codecov

codecov.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ ignore:
22
- "tasks/**/tests/**"
33
- "modules/**/tests/**"
44
- "tasks/common/runners/**"
5-
- "modules/core/runners/**"
6-
- "modules/core/util/include/perf_test_util.hpp"
7-
- "modules/core/util/include/func_test_util.hpp"
8-
- "modules/core/util/src/func_test_util.cpp"
5+
- "modules/runners/**"
6+
- "modules/util/include/perf_test_util.hpp"
7+
- "modules/util/include/func_test_util.hpp"
8+
- "modules/util/src/func_test_util.cpp"
99
coverage:
1010
status:
1111
project:

modules/CMakeLists.txt

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,53 @@
1-
message(STATUS "Modules")
1+
message(STATUS "Core components")
2+
set(exec_func_tests "core_func_tests")
3+
set(exec_func_lib "core_module_lib")
24

35
subdirlist(subdirs ${CMAKE_CURRENT_SOURCE_DIR})
46

57
foreach(subd ${subdirs})
6-
add_subdirectory(${subd})
8+
get_filename_component(PROJECT_ID ${subd} NAME)
9+
set(PATH_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${subd}")
10+
set(PROJECT_ID "${PROJECT_ID}")
11+
message(STATUS "-- " ${PROJECT_ID})
12+
13+
file(GLOB_RECURSE TMP_LIB_SOURCE_FILES ${PATH_PREFIX}/include/*
14+
${PATH_PREFIX}/src/*)
15+
list(APPEND LIB_SOURCE_FILES ${TMP_LIB_SOURCE_FILES})
16+
17+
file(GLOB_RECURSE TMP_FUNC_TESTS_SOURCE_FILES ${PATH_PREFIX}/tests/*)
18+
list(APPEND FUNC_TESTS_SOURCE_FILES ${TMP_FUNC_TESTS_SOURCE_FILES})
719
endforeach()
20+
21+
project(${exec_func_lib})
22+
add_library(${exec_func_lib} STATIC ${LIB_SOURCE_FILES})
23+
set_target_properties(${exec_func_lib} PROPERTIES LINKER_LANGUAGE CXX)
24+
25+
# Add include directories to target
26+
target_include_directories(
27+
${exec_func_lib} PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty
28+
${CMAKE_SOURCE_DIR}/modules ${CMAKE_SOURCE_DIR}/tasks)
29+
30+
ppc_link_envpp(${exec_func_lib})
31+
ppc_link_json(${exec_func_lib})
32+
ppc_link_gtest(${exec_func_lib})
33+
ppc_link_threads(${exec_func_lib})
34+
ppc_link_openmp(${exec_func_lib})
35+
ppc_link_tbb(${exec_func_lib})
36+
ppc_link_mpi(${exec_func_lib})
37+
ppc_link_stb(${exec_func_lib})
38+
39+
add_executable(${exec_func_tests} ${FUNC_TESTS_SOURCE_FILES})
40+
41+
target_link_libraries(${exec_func_tests} PUBLIC ${exec_func_lib})
42+
43+
enable_testing()
44+
add_test(NAME ${exec_func_tests} COMMAND ${exec_func_tests})
45+
46+
# Installation rules
47+
install(
48+
TARGETS ${exec_func_lib}
49+
ARCHIVE DESTINATION lib
50+
LIBRARY DESTINATION lib
51+
RUNTIME DESTINATION bin)
52+
53+
install(TARGETS ${exec_func_tests} RUNTIME DESTINATION bin)

modules/core/CMakeLists.txt

Lines changed: 0 additions & 55 deletions
This file was deleted.

modules/core/performance/tests/test_task.hpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

modules/core/task/tests/test_task.hpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

modules/core/performance/include/performance.hpp renamed to modules/performance/include/performance.hpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
#include <stdexcept>
1010
#include <string>
1111

12-
#include "core/task/include/task.hpp"
12+
#include "task/include/task.hpp"
1313

14-
namespace ppc::core {
14+
namespace ppc::performance {
15+
16+
inline double DefaultTimer() { return -1.0; }
1517

1618
struct PerfAttr {
1719
/// @brief Number of times the task is run for performance evaluation.
1820
uint64_t num_running = 5;
1921
/// @brief Timer function returning current time in seconds.
2022
/// @cond
21-
std::function<double()> current_timer = [&] { return -1.0; };
23+
std::function<double()> current_timer = DefaultTimer;
2224
/// @endcond
2325
};
2426

@@ -33,15 +35,15 @@ template <typename InType, typename OutType>
3335
class Perf {
3436
public:
3537
// Init performance analysis with an initialized task and initialized data
36-
explicit Perf(const TaskPtr<InType, OutType>& task_ptr) : task_(task_ptr) {
37-
task_ptr->GetStateOfTesting() = StateOfTesting::kPerf;
38+
explicit Perf(const ppc::task::TaskPtr<InType, OutType>& task_ptr) : task_(task_ptr) {
39+
task_ptr->GetStateOfTesting() = ppc::task::StateOfTesting::kPerf;
3840
}
3941
// Check performance of full task's pipeline: PreProcessing() ->
4042
// Validation() -> Run() -> PostProcessing()
4143
void PipelineRun(const PerfAttr& perf_attr) {
4244
perf_results_.type_of_running = PerfResults::TypeOfRunning::kPipeline;
4345

44-
CommonRun(perf_attr, [&]() {
46+
CommonRun(perf_attr, [&] {
4547
task_->Validation();
4648
task_->PreProcessing();
4749
task_->Run();
@@ -54,7 +56,7 @@ class Perf {
5456

5557
task_->Validation();
5658
task_->PreProcessing();
57-
CommonRun(perf_attr, [&]() { task_->Run(); }, perf_results_);
59+
CommonRun(perf_attr, [&] { task_->Run(); }, perf_results_);
5860
task_->PostProcessing();
5961

6062
task_->Validation();
@@ -92,11 +94,11 @@ class Perf {
9294
}
9395
/// @brief Retrieves the performance test results.
9496
/// @return The latest PerfResults structure.
95-
PerfResults GetPerfResults() { return perf_results_; }
97+
[[nodiscard]] PerfResults GetPerfResults() const { return perf_results_; }
9698

9799
private:
98100
PerfResults perf_results_;
99-
std::shared_ptr<Task<InType, OutType>> task_;
101+
std::shared_ptr<ppc::task::Task<InType, OutType>> task_;
100102
static void CommonRun(const PerfAttr& perf_attr, const std::function<void()>& pipeline, PerfResults& perf_results) {
101103
auto begin = perf_attr.current_timer();
102104
for (uint64_t i = 0; i < perf_attr.num_running; i++) {
@@ -107,14 +109,14 @@ class Perf {
107109
}
108110
};
109111

110-
inline std::string GetStringParamName(ppc::core::PerfResults::TypeOfRunning type_of_running) {
111-
if (type_of_running == core::PerfResults::kTaskRun) {
112+
inline std::string GetStringParamName(PerfResults::TypeOfRunning type_of_running) {
113+
if (type_of_running == PerfResults::kTaskRun) {
112114
return "task_run";
113115
}
114-
if (type_of_running == core::PerfResults::kPipeline) {
116+
if (type_of_running == PerfResults::kPipeline) {
115117
return "pipeline";
116118
}
117119
return "none";
118120
}
119121

120-
} // namespace ppc::core
122+
} // namespace ppc::performance

0 commit comments

Comments
 (0)