Skip to content

Commit 73607a6

Browse files
committed
refactor core module: consolidate namespaces and remove unused test definitions
1 parent b0c18d4 commit 73607a6

File tree

40 files changed

+319
-335
lines changed

40 files changed

+319
-335
lines changed

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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
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 {
1515

1616
struct PerfAttr {
1717
/// @brief Number of times the task is run for performance evaluation.
@@ -33,8 +33,8 @@ template <typename InType, typename OutType>
3333
class Perf {
3434
public:
3535
// 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;
36+
explicit Perf(const ppc::task::TaskPtr<InType, OutType>& task_ptr) : task_(task_ptr) {
37+
task_ptr->GetStateOfTesting() = ppc::task::StateOfTesting::kPerf;
3838
}
3939
// Check performance of full task's pipeline: PreProcessing() ->
4040
// Validation() -> Run() -> PostProcessing()
@@ -92,11 +92,11 @@ class Perf {
9292
}
9393
/// @brief Retrieves the performance test results.
9494
/// @return The latest PerfResults structure.
95-
PerfResults GetPerfResults() { return perf_results_; }
95+
[[nodiscard]] PerfResults GetPerfResults() const { return perf_results_; }
9696

9797
private:
9898
PerfResults perf_results_;
99-
std::shared_ptr<Task<InType, OutType>> task_;
99+
std::shared_ptr<ppc::task::Task<InType, OutType>> task_;
100100
static void CommonRun(const PerfAttr& perf_attr, const std::function<void()>& pipeline, PerfResults& perf_results) {
101101
auto begin = perf_attr.current_timer();
102102
for (uint64_t i = 0; i < perf_attr.num_running; i++) {
@@ -107,14 +107,14 @@ class Perf {
107107
}
108108
};
109109

110-
inline std::string GetStringParamName(ppc::core::PerfResults::TypeOfRunning type_of_running) {
111-
if (type_of_running == core::PerfResults::kTaskRun) {
110+
inline std::string GetStringParamName(PerfResults::TypeOfRunning type_of_running) {
111+
if (type_of_running == PerfResults::kTaskRun) {
112112
return "task_run";
113113
}
114-
if (type_of_running == core::PerfResults::kPipeline) {
114+
if (type_of_running == PerfResults::kPipeline) {
115115
return "pipeline";
116116
}
117117
return "none";
118118
}
119119

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

0 commit comments

Comments
 (0)