Skip to content

Commit 3d56395

Browse files
committed
Add testcase.
1 parent a180e83 commit 3d56395

8 files changed

Lines changed: 270 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+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
0
4+
0
5+
0
6+
0
7+
Point 1 :
8+
525.989
9+
0
10+
0
11+
0
12+
0
13+
Point 2 :
14+
415.495
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+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
Point 1 :
8+
525.989
9+
-5603.59
10+
-66981.3
11+
-80166.6
12+
-2712.39
13+
Point 2 :
14+
415.495
15+
2920.65
16+
43411
17+
31465.3
18+
34829.2
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Point 0 :
2+
504.058
3+
-2995.59
4+
12478.8
5+
-7023.06
6+
2306.68
7+
-9.48083e+06
8+
-509567
9+
773598
10+
-1.10835e+06
11+
-509567
12+
-5.13969e+07
13+
7.74634e+07
14+
307741
15+
773598
16+
7.74634e+07
17+
-1.25133e+08
18+
-2.55012e+06
19+
-1.10835e+06
20+
307741
21+
-2.55012e+06
22+
-651335
23+
Point 1 :
24+
525.989
25+
-5603.59
26+
-66981.3
27+
-80166.6
28+
-2712.39
29+
-1.023e+07
30+
-6.84998e+06
31+
341414
32+
470782
33+
-6.84998e+06
34+
-1.45156e+08
35+
-1.7744e+08
36+
-1.22462e+06
37+
341414
38+
-1.7744e+08
39+
-2.22884e+08
40+
3.82312e+06
41+
470782
42+
-1.22462e+06
43+
3.82312e+06
44+
2.00867e+07
45+
Point 2 :
46+
415.495
47+
2920.65
48+
43411
49+
31465.3
50+
34829.2
51+
9.90581e+06
52+
1.55215e+07
53+
5.59021e+06
54+
-563088
55+
1.55215e+07
56+
-2.17085e+08
57+
-1.67039e+08
58+
7.84007e+07
59+
5.59021e+06
60+
-1.67039e+08
61+
-1.25016e+08
62+
5.32699e+07
63+
-563088
64+
7.84007e+07
65+
5.32699e+07
66+
-1.47689e+08
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 TestSingleCopyprivateNowait : public TestBase<4, 1, 3, TestSingleCopyprivateNowait<_Case>> {
32+
public:
33+
using Case = _Case;
34+
using Base = TestBase<4, 1, 3, TestSingleCopyprivateNowait<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+
OPDI_PARALLEL()
43+
{
44+
int nThreads = omp_get_num_threads();
45+
int start = ((N / 2 - 1) / nThreads + 1) * omp_get_thread_num();
46+
int end = ((N / 2 - 1) / nThreads + 1) * (omp_get_thread_num() + 1);
47+
48+
for (int i = start; i < end; ++i) {
49+
Base::job1(i, in, jobResults[i]);
50+
}
51+
52+
OPDI_BARRIER()
53+
54+
T helper;
55+
56+
#if _OPENMP >= 202411
57+
OPDI_SINGLE_COPYPRIVATE_NOWAIT(copyprivate(helper))
58+
#else
59+
OPDI_SINGLE_COPYPRIVATE(copyprivate(helper))
60+
#endif
61+
{
62+
for (int i = 0; i < N / 2; ++i) {
63+
helper = jobResults[i];
64+
out[0] += cos(helper);
65+
}
66+
}
67+
OPDI_END_SINGLE
68+
69+
start = N / 2 + ((N / 2 - 1) / nThreads + 1) * omp_get_thread_num();
70+
end = std::min(N, N / 2 + ((N / 2 - 1) / nThreads + 1) * (omp_get_thread_num() + 1));
71+
72+
for (int i = start; i < end; ++i) {
73+
Base::job1(i, in, jobResults[i]);
74+
}
75+
76+
OPDI_BARRIER()
77+
78+
for (int i = start; i < end; ++i) {
79+
jobResults[i] = helper * jobResults[i];
80+
}
81+
82+
OPDI_BARRIER()
83+
84+
OPDI_SINGLE_NOWAIT()
85+
{
86+
for (int i = N / 2; i < N; ++i) {
87+
out[0] += jobResults[i];
88+
}
89+
}
90+
OPDI_END_SINGLE
91+
}
92+
OPDI_END_PARALLEL
93+
94+
delete [] jobResults;
95+
}
96+
};

0 commit comments

Comments
 (0)