Skip to content

Commit 76a13a4

Browse files
committed
Refactor example tasks to example_threads and streamline task/test macros
Reorganized the directory structure by renaming `example` tasks to `example_threads`. Updated include paths, CMakeLists, and JSON settings accordingly. Simplified task and test macro structure by consolidating redundant definitions and improving generator logic.
1 parent 647bf7e commit 76a13a4

22 files changed

Lines changed: 83 additions & 87 deletions

File tree

modules/core/util/include/func_test_util.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ auto ExpandToValues(const Tuple& t) {
8383
return ExpandToValuesImpl(t, std::make_index_sequence<kN>{});
8484
}
8585

86-
#define INIT_TASK_GENERATOR(InTypeParam, SizesParam, SettingsPath) \
86+
#define INIT_FUNC_TASK_GENERATOR(InTypeParam, SizesParam, SettingsPath) \
8787
template <typename Task, std::size_t... Is> \
8888
auto GenTaskTuplesImpl(std::index_sequence<Is...>) { \
8989
return std::make_tuple( \
@@ -98,12 +98,10 @@ auto ExpandToValues(const Tuple& t) {
9898
return GenTaskTuplesImpl<Task>(std::make_index_sequence<SizesParam.size()>{}); \
9999
}
100100

101-
#define ADD_FUNC_TASK_THREADS(TASK) TaskListGenerator<TASK>()
102-
103101
#if 1
104-
#define ADD_FUNC_TASK_PROCESS(TASK) TaskListGenerator<TASK>()
102+
#define ADD_FUNC_TASK(TASK) TaskListGenerator<TASK>()
105103
#else
106-
#define ADD_FUNC_TASK_PROCESS(TASK) std::tuple<>()
104+
#define ADD_FUNC_TASK(TASK) std::tuple<>()
107105
#endif
108106

109107
} // namespace ppc::util

modules/core/util/include/perf_test_util.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
9393
ppc::core::TaskPtr<InType, OutType> task_;
9494
};
9595

96-
#define ADD_PERF_TASK_THREADS(TaskType, InputTypeParam, SettingsPath) \
96+
#if 1
97+
#define ADD_PERF_TASK(TaskType, InputTypeParam, SettingsPath) \
9798
std::tuple(std::make_tuple(ppc::core::TaskGetter<TaskType, InputTypeParam>, \
9899
std::string(ppc::util::GetNamespace<TaskType>()) + "_" + \
99100
ppc::core::GetStringTaskType(TaskType::GetStaticTypeOfTask(), SettingsPath), \
@@ -102,6 +103,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
102103
std::string(ppc::util::GetNamespace<TaskType>()) + "_" + \
103104
ppc::core::GetStringTaskType(TaskType::GetStaticTypeOfTask(), SettingsPath), \
104105
ppc::core::PerfResults::TypeOfRunning::kTaskRun))
106+
#else
107+
#define ADD_PERF_TASK(TaskType, InputTypeParam, SettingsPath) std::make_tuple()
108+
#endif
105109

106110
template <typename Tuple, std::size_t... I>
107111
auto TupleToGTestValuesImpl(Tuple&& tup, std::index_sequence<I...>) {
@@ -114,18 +118,12 @@ auto TupleToGTestValues(Tuple&& tup) {
114118
return TupleToGTestValuesImpl(std::forward<Tuple>(tup), std::make_index_sequence<size>{});
115119
}
116120

117-
#if 1
118-
#define ADD_PERF_TASK_PROCESS(TaskType, InputTypeParam, SettingsPath) \
119-
std::tuple(std::make_tuple(ppc::core::TaskGetter<TaskType, InputTypeParam>, \
120-
std::string(ppc::util::GetNamespace<TaskType>()) + "_" + \
121-
ppc::core::GetStringTaskType(TaskType::GetStaticTypeOfTask(), SettingsPath), \
122-
ppc::core::PerfResults::TypeOfRunning::kPipeline), \
123-
std::make_tuple(ppc::core::TaskGetter<TaskType, InputTypeParam>, \
124-
std::string(ppc::util::GetNamespace<TaskType>()) + "_" + \
125-
ppc::core::GetStringTaskType(TaskType::GetStaticTypeOfTask(), SettingsPath), \
126-
ppc::core::PerfResults::TypeOfRunning::kTaskRun))
127-
#else
128-
#define ADD_PERF_TASK_PROCESS(TaskType, InputTypeParam, SettingsPath) std::make_tuple()
129-
#endif
121+
#define INIT_PERF_TASK_GENERATOR(InType, EnvVarSettingsPath) \
122+
template <typename... Ts> \
123+
struct perf_tasks_type_list {}; \
124+
template <typename... Ts> \
125+
auto MakeTask(perf_tasks_type_list<Ts...>) { \
126+
return std::tuple_cat(ADD_PERF_TASK(Ts, InType, EnvVarSettingsPath)...); \
127+
}
130128

131129
} // namespace ppc::util

tasks/example/tests/performance/main.cpp

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

tasks/example/all/include/ops_all.hpp renamed to tasks/example_threads/all/include/ops_all.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <vector>
44

5-
#include "example/common/include/common.hpp"
5+
#include "example_threads/common/include/common.hpp"
66

77
namespace nesterov_a_test_task {
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "example/all/include/ops_all.hpp"
1+
#include "example_threads/all/include/ops_all.hpp"
22

33
#include <mpi.h>
44

File renamed without changes.

tasks/example/mpi/include/ops_mpi.hpp renamed to tasks/example_threads/mpi/include/ops_mpi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <vector>
44

55
#include "core/task/include/task.hpp"
6-
#include "example/common/include/common.hpp"
6+
#include "example_threads/common/include/common.hpp"
77

88
namespace nesterov_a_test_task {
99

0 commit comments

Comments
 (0)