Peano
Loading...
Searching...
No Matches
ParallelDForTest.cpp
Go to the documentation of this file.
2#include "peano4/utils/Loop.h"
3#include "ParallelDForTest.h"
4
5#include "tarch/la/Vector.h"
6
7
8tarch::logging::Log peano4::utils::tests::ParallelDForTest::_log("peano4::grid::tests::SpacetreeTest");
9
10
11#ifdef UseTestSpecificCompilerSettings
12#pragma optimize("",off)
13#endif
14
15
17 TestCase( "peano4::utils::tests::ParallelDForTest" ) {
18}
19
20
22 constexpr int Size = 24;
23 constexpr int Samples = 64;
24 #if Dimension==2
25 constexpr int DSize = Size*Size;
26 #else
27 constexpr int DSize = Size*Size*Size;
28 #endif
29 int output[ DSize ];
30
31 for (int i=0; i<DSize; i++) {
32 output[i] = 0;
33 }
34
35 for (int sample=0; sample<Samples; sample++) {
36 parallelDfor(counter,Size) {
37 int index = peano4::utils::dLinearised(counter,Size);
38 output[index]++;
40 }
41
42 dfor(counter,Size) {
43 int index = peano4::utils::dLinearised(counter,Size);
44 validateEqualsWithParams2( output[index], Samples, index, counter );
45 }
46}
47
48
50 testMethod( testParallelDFor );
51}
52
53
54#ifdef UseTestSpecificCompilerSettings
55#pragma optimize("",on)
56#endif
#define parallelDfor(counter, max)
Definition Loop.h:452
#define dfor(counter, max)
d-dimensional Loop
Definition Loop.h:313
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateEqualsWithParams2(actualValue, validValue, param0, param1)
Definition TestMacros.h:328
static tarch::logging::Log _log
Logging device.
virtual void run() override
This routine is triggered by the TestCaseCollection.
Log Device.
Definition Log.h:516
#define endParallelDfor
Definition Loop.h:115
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
Definition Loop.cpp:106