Skip to content

Commit 2672c06

Browse files
committed
Add TestParallelForLastprivate.
1 parent c837f61 commit 2672c06

8 files changed

Lines changed: 232 additions & 0 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
Point 1 :
8+
32.8041
9+
-12507.5
10+
-7865.59
11+
-128.973
12+
-3249.85
13+
Point 2 :
14+
-83.9704
15+
-1378.79
16+
474.401
17+
-1044.34
18+
-63769.4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
Point 1 :
8+
32.8041
9+
-12507.5
10+
-7865.59
11+
-128.973
12+
-3249.85
13+
Point 2 :
14+
-83.9704
15+
-1378.79
16+
474.401
17+
-1044.34
18+
-63769.4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
Point 1 :
8+
32.8041
9+
-12507.5
10+
-7865.59
11+
-128.973
12+
-3249.85
13+
Point 2 :
14+
-83.9704
15+
-1378.79
16+
474.401
17+
-1044.34
18+
-63769.4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
Point 1 :
8+
32.8041
9+
-12507.5
10+
-7865.59
11+
-128.973
12+
-3249.85
13+
Point 2 :
14+
-83.9704
15+
-1378.79
16+
474.401
17+
-1044.34
18+
-63769.4
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
0
4+
0
5+
0
6+
0
7+
Point 1 :
8+
32.8041
9+
0
10+
0
11+
0
12+
0
13+
Point 2 :
14+
-83.9704
15+
0
16+
0
17+
0
18+
0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
Point 1 :
8+
32.8041
9+
-12507.5
10+
-7865.59
11+
-128.973
12+
-3249.85
13+
Point 2 :
14+
-83.9704
15+
-1378.79
16+
474.401
17+
-1044.34
18+
-63769.4
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Point 0 :
2+
-2.30162
3+
159.64
4+
25.0196
5+
-654.451
6+
-132.877
7+
-336999
8+
207726
9+
-1069.36
10+
35835.3
11+
207726
12+
-396013
13+
485938
14+
-45.5657
15+
-1069.36
16+
485938
17+
-1.16325e+06
18+
-110046
19+
35835.3
20+
-45.5657
21+
-110046
22+
-22937.1
23+
Point 1 :
24+
32.8041
25+
-12507.5
26+
-7865.59
27+
-128.973
28+
-3249.85
29+
-1.2948e+07
30+
-6.61277e+06
31+
-29524.6
32+
-9.94793e+06
33+
-6.61277e+06
34+
7.30508e+07
35+
9.77476e+07
36+
-54148.9
37+
-29524.6
38+
9.77476e+07
39+
1.21033e+08
40+
-7.58212e+06
41+
-9.94793e+06
42+
-54148.9
43+
-7.58212e+06
44+
-5.59522e+07
45+
Point 2 :
46+
-83.9704
47+
-1378.79
48+
474.401
49+
-1044.34
50+
-63769.4
51+
-9.19543e+06
52+
-7.36488e+06
53+
2990.13
54+
371784
55+
-7.36488e+06
56+
1.3558e+06
57+
5.35612e+06
58+
144953
59+
2990.13
60+
5.35612e+06
61+
4.1439e+06
62+
5.54801e+06
63+
371784
64+
144953
65+
5.54801e+06
66+
1.66489e+08
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* OpDiLib, an Open Multiprocessing Differentiation Library
3+
*
4+
* Copyright (C) 2020-2022 Chair for Scientific Computing (SciComp), TU Kaiserslautern
5+
* Copyright (C) 2023-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
6+
* Homepage: https://scicomp.rptu.de
7+
* Contact: Prof. Nicolas R. Gauger (opdi@scicomp.uni-kl.de)
8+
*
9+
* Lead developer: Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
10+
*
11+
* This file is part of OpDiLib (https://scicomp.rptu.de/software/opdi).
12+
*
13+
* OpDiLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
14+
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
15+
* version.
16+
*
17+
* OpDiLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
18+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
19+
* details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License along with OpDiLib. If not, see
22+
* <http://www.gnu.org/licenses/>.
23+
*
24+
*/
25+
26+
#pragma once
27+
28+
#include "testBase.hpp"
29+
30+
template<typename _Case>
31+
struct TestParallelForLastprivate : public TestBase<4, 1, 3, TestParallelForLastprivate<_Case>> {
32+
public:
33+
using Case = _Case;
34+
using Base = TestBase<4, 1, 3, TestParallelForLastprivate<Case>>;
35+
36+
template<typename T>
37+
static void test(std::array<T, Base::nIn> const& in, std::array<T, Base::nOut>& out) {
38+
39+
int const N = 1000;
40+
T* jobResults = new T[N];
41+
42+
T helper = 0.0;
43+
44+
OPDI_PARALLEL(for lastprivate(helper))
45+
for (int i = 0; i < N; ++i) {
46+
helper = in[0] * sin(i);
47+
Base::job1(i, in, jobResults[i]);
48+
jobResults[i] *= helper;
49+
}
50+
OPDI_END_PARALLEL
51+
52+
for (int i = 0; i < N; ++i) {
53+
out[0] += helper * jobResults[i];
54+
}
55+
56+
delete [] jobResults;
57+
}
58+
};

0 commit comments

Comments
 (0)