77
88namespace ppc ::util {
99
10- enum TestParamIndex : uint8_t { kTaskGetter , kNameTest , kTestParams };
10+ enum GTestParamIndex : uint8_t { kTaskGetter , kNameTest , kTestParams };
1111
1212inline std::string GetStringParamName (ppc::core::PerfResults::TypeOfRunning type_of_running) {
1313 if (type_of_running == core::PerfResults::kTaskRun ) {
@@ -19,6 +19,28 @@ inline std::string GetStringParamName(ppc::core::PerfResults::TypeOfRunning type
1919 return " none" ;
2020}
2121
22+ inline std::string GetStringTaskType (ppc::core::TypeOfTask type_of_task) {
23+ if (type_of_task == ppc::core::TypeOfTask::kALL ) {
24+ return " all" ;
25+ }
26+ if (type_of_task == ppc::core::TypeOfTask::kSTL ) {
27+ return " stl" ;
28+ }
29+ if (type_of_task == ppc::core::TypeOfTask::kOMP ) {
30+ return " omp" ;
31+ }
32+ if (type_of_task == ppc::core::TypeOfTask::kMPI ) {
33+ return " mpi" ;
34+ }
35+ if (type_of_task == ppc::core::TypeOfTask::kTBB ) {
36+ return " tbb" ;
37+ }
38+ if (type_of_task == ppc::core::TypeOfTask::kSEQ ) {
39+ return " seq" ;
40+ }
41+ return " unknown" ;
42+ }
43+
2244template <typename InType, typename OutType, typename TestType = void >
2345using FuncTestParam = std::tuple<std::function<ppc::core::TaskPtr<InType, OutType>(InType)>, std::string, TestType>;
2446
@@ -32,8 +54,8 @@ template <typename InType, typename OutType>
3254class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, OutType>> {
3355 public:
3456 static std::string CustomPerfTestName (const ::testing::TestParamInfo<PerfTestParam<InType, OutType>>& info) {
35- return ppc::util::GetStringParamName (std::get<TestParamIndex ::kTestParams >(info.param )) + " _" +
36- std::get<TestParamIndex ::kNameTest >(info.param );
57+ return ppc::util::GetStringParamName (std::get<GTestParamIndex ::kTestParams >(info.param )) + " _" +
58+ std::get<GTestParamIndex ::kNameTest >(info.param );
3759 }
3860
3961 protected:
@@ -42,9 +64,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
4264 virtual InType GetTestInputData () = 0;
4365
4466 void ExecuteTest (const PerfTestParam<InType, OutType>& perf_test_param) {
45- auto task_getter = std::get<TestParamIndex ::kTaskGetter >(perf_test_param);
46- auto test_name = std::get<TestParamIndex ::kNameTest >(perf_test_param);
47- auto mode = std::get<TestParamIndex ::kTestParams >(perf_test_param);
67+ auto task_getter = std::get<GTestParamIndex ::kTaskGetter >(perf_test_param);
68+ auto test_name = std::get<GTestParamIndex ::kNameTest >(perf_test_param);
69+ auto mode = std::get<GTestParamIndex ::kTestParams >(perf_test_param);
4870
4971 task_ = task_getter (GetTestInputData ());
5072 ppc::core::Perf perf (task_);
@@ -74,10 +96,14 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
7496 ppc::core::TaskPtr<InType, OutType> task_;
7597};
7698
77- #define ADD_PERF_MODES (TaskType, InputTypeParam ) \
78- std::make_tuple (ppc::core::TaskGetter<TaskType, InputTypeParam>, ppc::util::GetNamespace<TaskType>(), \
79- ppc::core::PerfResults::TypeOfRunning::kPipeline ), \
80- std::make_tuple (ppc::core::TaskGetter<TaskType, InputTypeParam>, ppc::util::GetNamespace<TaskType>(), \
99+ #define ADD_PERF_MODES (TaskType, InputTypeParam ) \
100+ std::make_tuple (ppc::core::TaskGetter<TaskType, InputTypeParam>, \
101+ std::string (ppc::util::GetNamespace<TaskType>()) + std::string(" _" ) + \
102+ ppc::util::GetStringTaskType(TaskType::GetTypeOfTask()), \
103+ ppc::core::PerfResults::TypeOfRunning::kPipeline), \
104+ std::make_tuple(ppc::core::TaskGetter<TaskType, InputTypeParam>, \
105+ std::string (ppc::util::GetNamespace<TaskType>()) + std::string(" _" ) + \
106+ ppc::util::GetStringTaskType(TaskType::GetTypeOfTask()), \
81107 ppc::core::PerfResults::TypeOfRunning::kTaskRun)
82108
83109template <typename T, typename TestType>
@@ -100,13 +126,13 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
100126 template <typename Derived>
101127 static std::string PrintFuncTestName (const GTestFuncParam<InType, OutType, TestType>& info) {
102128 RequireStaticInterface<Derived>();
103- TestType test_param = std::get<ppc::util::TestParamIndex ::kTestParams >(info.param );
104- return std::get<TestParamIndex ::kNameTest >(info.param ) + " _" + Derived::PrintTestParam (test_param);
129+ TestType test_param = std::get<ppc::util::GTestParamIndex ::kTestParams >(info.param );
130+ return std::get<GTestParamIndex ::kNameTest >(info.param ) + " _" + Derived::PrintTestParam (test_param);
105131 }
106132
107133 protected:
108134 void ExecuteTest (FuncTestParam<InType, OutType, TestType> test_param) {
109- task_ = std::get<TestParamIndex ::kTaskGetter >(test_param)(GetTestInputData ());
135+ task_ = std::get<GTestParamIndex ::kTaskGetter >(test_param)(GetTestInputData ());
110136 ASSERT_TRUE (task_->Validation ());
111137 ASSERT_TRUE (task_->PreProcessing ());
112138 ASSERT_TRUE (task_->Run ());
@@ -129,16 +155,18 @@ auto ExpandToValues(const Tuple& t) {
129155 return ExpandToValuesImpl (t, std::make_index_sequence<kN >{});
130156}
131157
132- #define INIT_TASK_GENERATOR (InTypeParam, SizesParam ) \
133- template <typename Task, std::size_t ... Is> \
134- auto GenTaskTuplesImpl (std::index_sequence<Is...>) { \
135- return std::make_tuple (std::make_tuple (ppc::core::TaskGetter<Task, InTypeParam>, ppc::util::GetNamespace<Task>(), \
136- SizesParam[Is])...); \
137- } \
138- \
139- template <typename Task> \
140- auto TaskListGenerator () { \
141- return GenTaskTuplesImpl<Task>(std::make_index_sequence<SizesParam.size ()>{}); \
158+ #define INIT_TASK_GENERATOR (InTypeParam, SizesParam ) \
159+ template <typename Task, std::size_t ... Is> \
160+ auto GenTaskTuplesImpl (std::index_sequence<Is...>) { \
161+ return std::make_tuple (std::make_tuple (ppc::core::TaskGetter<Task, InTypeParam>, \
162+ std::string (ppc::util::GetNamespace<Task>()) + std::string (" _" ) + \
163+ ppc::util::GetStringTaskType (Task::GetTypeOfTask ()), \
164+ SizesParam[Is])...); \
165+ } \
166+ \
167+ template <typename Task> \
168+ auto TaskListGenerator () { \
169+ return GenTaskTuplesImpl<Task>(std::make_index_sequence<SizesParam.size ()>{}); \
142170 }
143171
144172} // namespace ppc::util
0 commit comments