forked from learning-process/parallel_programming_course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (42 loc) · 1.73 KB
/
main.cpp
File metadata and controls
54 lines (42 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <gtest/gtest.h>
#include <chrono>
#include <cstddef>
#include <memory>
#include <vector>
#include "core/perf/include/perf.hpp"
#include "core/util/include/util.hpp"
#include "stl/example/include/ops_stl.hpp"
class NesterovTaskSTLTest : public ::testing::TestWithParam<ppc::core::PerfResults::TypeOfRunning> {
protected:
static void RunTest(ppc::core::PerfResults::TypeOfRunning mode) {
constexpr size_t kCount = 450;
// Create data
std::vector<int> in(kCount * kCount, 0);
for (size_t i = 0; i < kCount; i++) {
in[(i * kCount) + i] = 1;
}
// Create Task
auto test_task_stl = std::make_shared<nesterov_a_test_task_stl::TestTaskSTL>(in);
// Create Perf analyzer
ppc::core::Perf perf_analyzer(test_task_stl);
// Create Perf attributes
ppc::core::PerfAttr perf_attr;
const auto t0 = std::chrono::high_resolution_clock::now();
perf_attr.current_timer = [&] {
auto current_time_point = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(current_time_point - t0).count();
return static_cast<double>(duration) * 1e-9;
};
if (mode == ppc::core::PerfResults::TypeOfRunning::kPipeline) {
perf_analyzer.PipelineRun(perf_attr);
} else {
perf_analyzer.TaskRun(perf_attr);
}
perf_analyzer.PrintPerfStatistic();
ASSERT_EQ(in, test_task_stl->Get());
}
};
TEST_P(NesterovTaskSTLTest, RunModes) { RunTest(GetParam()); }
INSTANTIATE_TEST_SUITE_P_NOLINT(NesterovSTLTests, NesterovTaskSTLTest,
::testing::Values(ppc::core::PerfResults::TypeOfRunning::kPipeline,
ppc::core::PerfResults::TypeOfRunning::kTaskRun));