Peano
Loading...
Searching...
No Matches
Loop.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3//
4// Included by peano4/utils/Loop.h. Do not use directly
5//
6
14#define parallelForWithSchedulerInstructions(counter, max, loopParallelism) \
15 for( int counter = 0; counter < max; counter++ ) {
16
17#define endParallelFor }
18
19
20#define parallelDforWithDynamicScheduling2d(counter, max, loopParallelism) \
21 { \
22 tarch::la::Vector<2,int> counter##Max(max); \
23 for( int counter##0 = 0; counter##0 < counter##Max(0); counter##0++ ) \
24 for( int counter##1 = 0; counter##1 < counter##Max(1); counter##1++ ) { \
25 tarch::la::Vector<2, int> counter = { counter##0, counter##1 };
26
27#define parallelDforWithDynamicScheduling3d(counter, max, loopParallelism) \
28 { \
29 tarch::la::Vector<3,int> counter##Max(max); \
30 for( int counter##0 = 0; counter##0 < counter##Max(0); counter##0++ ) \
31 for( int counter##1 = 0; counter##1 < counter##Max(1); counter##1++ ) \
32 for( int counter##2 = 0; counter##2 < counter##Max(2); counter##2++ ) { \
33 tarch::la::Vector<3, int> counter = { counter##0, counter##1, counter##2 };
34
35#define parallelDforWithDynamicScheduling4d(counter, max, loopParallelism) \
36 { \
37 tarch::la::Vector<4,int> counter##Max(max); \
38 for( int counter##0 = 0; counter##0 < counter##Max(0); counter##0++ ) \
39 for( int counter##1 = 0; counter##1 < counter##Max(1); counter##1++ ) \
40 for( int counter##2 = 0; counter##2 < counter##Max(2); counter##2++ ) \
41 for( int counter##3 = 0; counter##3 < counter##Max(3); counter##3++ ) { \
42 tarch::la::Vector<4, int> counter = { counter##0, counter##1, counter##2, counter##3 };
43
44#define parallelDforWithDynamicScheduling5d(counter, max, loopParallelism) \
45 { \
46 tarch::la::Vector<5,int> counter##Max(max); \
47 for( int counter##0 = 0; counter##0 < counter##Max(0); counter##0++ ) \
48 for( int counter##1 = 0; counter##1 < counter##Max(1); counter##1++ ) \
49 for( int counter##2 = 0; counter##2 < counter##Max(2); counter##2++ ) \
50 for( int counter##3 = 0; counter##3 < counter##Max(3); counter##3++ ) \
51 for( int counter##4 = 0; counter##4 < counter##Max(4); counter##4++ ) { \
52 tarch::la::Vector<5, int> counter = { counter##0, counter##1, counter##2, counter##3, counter##4 };
53
54#define endParallelDfor }}
55
56
57#define simtForWithSchedulerInstructions(counter, max, loopParallelism) \
58 tarch::multicore::getHostSYCLQueue().submit([&](auto& handle) { \
59 handle.parallel_for( \
60 ::sycl::range<1>{static_cast<std::size_t>(max)}, \
61 [=](::sycl::id<1> counter##Iterator) { \
62 int counter = counter##Iterator[0];
63
64
72#define endSimtFor \
73 } \
74 ); \
75 }).wait();
76
84 #define simtDforWithDynamicScheduling2d(counter, max, loopParallelism) \
85 { \
86 tarch::la::Vector<2,int> counter##Max(tarch::la::expandOrSlice<2>(max)); \
87 tarch::multicore::getHostSYCLQueue().submit([&](auto& handle) { \
88 handle.parallel_for( \
89 ::sycl::range<2>{static_cast<std::size_t>(counter##Max(0)),static_cast<std::size_t>(counter##Max(1))}, \
90 [=](::sycl::id<2> counter##Iterator) {{ \
91 tarch::la::Vector<2, int> counter = { static_cast<int>(counter##Iterator[0]), static_cast<int>(counter##Iterator[1]) };
92
93
94 #define simtDforWithDynamicScheduling3d(counter, max, loopParallelism) \
95 { \
96 tarch::la::Vector<3,int> counter##Max(tarch::la::expandOrSlice<3>(max)); \
97 tarch::multicore::getHostSYCLQueue().submit([&](auto& handle) { \
98 handle.parallel_for( \
99 ::sycl::range<3>{static_cast<std::size_t>(counter##Max(0)),static_cast<std::size_t>(counter##Max(1)),static_cast<std::size_t>(counter##Max(2))}, \
100 [=](::sycl::id<3> counter##Iterator) {{ \
101 tarch::la::Vector<3, int> counter = { static_cast<int>(counter##Iterator[0]), static_cast<int>(counter##Iterator[1]), static_cast<int>(counter##Iterator[2]) };
102
103
104 #define simtDforWithDynamicScheduling4d(counter, max, loopParallelism) \
105 { \
106 tarch::la::Vector<4,int> counter##Max(tarch::la::expandOrSlice<4>(max)); \
107 tarch::multicore::getHostSYCLQueue().submit([&](auto& handle) { \
108 handle.parallel_for( \
109 ::sycl::range<3>{static_cast<std::size_t>(counter##Max(0)),static_cast<std::size_t>(counter##Max(1)),static_cast<std::size_t>(counter##Max(2))}, \
110 [=](::sycl::id<3> counter##Iterator) { \
111 for (int counter##Iterator3 = 0; counter##Iterator3<counter##Max(3); counter##Iterator3++ ) { \
112 tarch::la::Vector<4, int> counter = { static_cast<int>(counter##Iterator[0]), static_cast<int>(counter##Iterator[1]), static_cast<int>(counter##Iterator[2]), static_cast<int>(counter##Iterator3) };
113
114
115 #define simtDforWithDynamicScheduling5d(counter, max, loopParallelism) \
116 { \
117 tarch::la::Vector<5,int> counter##Max(tarch::la::expandOrSlice<5>(max)); \
118 tarch::multicore::getHostSYCLQueue().submit([&](auto& handle) { \
119 handle.parallel_for( \
120 ::sycl::range<3>{static_cast<std::size_t>(counter##Max(0)),static_cast<std::size_t>(counter##Max(1)),static_cast<std::size_t>(counter##Max(2))}, \
121 [=](::sycl::id<3> counter##Iterator) { \
122 for (int counter##Iterator3 = 0; counter##Iterator3<counter##Max(3); counter##Iterator3++ ) \
123 for (int counter##Iterator4 = 0; counter##Iterator4<counter##Max(4); counter##Iterator4++ ) { \
124 tarch::la::Vector<5, int> counter = { static_cast<int>(counter##Iterator[0]), static_cast<int>(counter##Iterator[1]), static_cast<int>(counter##Iterator[2]), static_cast<int>(counter##Iterator3), static_cast<int>(counter##Iterator4) };
125
126
139 #define endSimtDfor \
140 }} \
141 ); \
142 }).wait(); \
143 }