GCC Code Coverage Report


Directory: ./
File: tasks/tsibareva_e_integral_calculate_trapezoid_method/omp/src/ops_omp.cpp
Date: 2026-05-11 08:26:31
Exec Total Coverage
Lines: 25 25 100.0%
Functions: 5 5 100.0%
Branches: 9 14 64.3%

Line Branch Exec Source
1 #include "tsibareva_e_integral_calculate_trapezoid_method/omp/include/ops_omp.hpp"
2
3 #include <cmath>
4 #include <vector>
5
6 #include "tsibareva_e_integral_calculate_trapezoid_method/common/include/common.hpp"
7
8 namespace tsibareva_e_integral_calculate_trapezoid_method {
9
10 24 TsibarevaEIntegralCalculateTrapezoidMethodOMP::TsibarevaEIntegralCalculateTrapezoidMethodOMP(const InType &in)
11
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 : BaseTask() {
12 SetTypeOfTask(GetStaticTypeOfTask());
13
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetInput() = in;
14 24 GetOutput() = 0.0;
15 24 }
16
17 24 bool TsibarevaEIntegralCalculateTrapezoidMethodOMP::ValidationImpl() {
18 24 return true;
19 }
20
21 24 bool TsibarevaEIntegralCalculateTrapezoidMethodOMP::PreProcessingImpl() {
22 24 GetOutput() = 0.0;
23 24 return true;
24 }
25
26 24 bool TsibarevaEIntegralCalculateTrapezoidMethodOMP::RunImpl() {
27 24 int dim = GetInput().dim;
28
29 24 std::vector<double> h(dim);
30
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<int> sizes(dim);
31 int total_nodes = 1;
32
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for (int i = 0; i < dim; ++i) {
33 48 h[i] = (GetInput().hi[i] - GetInput().lo[i]) / GetInput().steps[i];
34 48 sizes[i] = GetInput().steps[i] + 1;
35 48 total_nodes *= sizes[i];
36 }
37
38 double global_sum = 0.0;
39
40 24 #pragma omp parallel for default(none) shared(dim, h, sizes, total_nodes) reduction(+ : global_sum)
41 for (int node = 0; node < total_nodes; ++node) {
42 int remainder = node;
43 double node_weight = 1.0;
44 std::vector<double> point(dim);
45
46 for (int i = dim - 1; i >= 0; --i) {
47 int idx = remainder % sizes[i];
48 remainder /= sizes[i];
49
50 if (idx == 0 || idx == GetInput().steps[i]) {
51 node_weight *= 0.5;
52 }
53
54 point[i] = GetInput().lo[i] + (idx * h[i]);
55 }
56
57 global_sum += node_weight * GetInput().f(point);
58 }
59
60 double res_h = 1.0;
61
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for (int i = 0; i < dim; ++i) {
62 48 res_h *= h[i];
63 }
64
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
24 GetOutput() = global_sum * res_h;
65 24 return true;
66 }
67
68 24 bool TsibarevaEIntegralCalculateTrapezoidMethodOMP::PostProcessingImpl() {
69 24 return true;
70 }
71
72 } // namespace tsibareva_e_integral_calculate_trapezoid_method
73