Changeset 716da7 for src/comm/mpi/datatypes_local.cpp
- Timestamp:
- Apr 24, 2012, 2:26:14 PM (14 years ago)
- Children:
- b51c3b
- Parents:
- e3dbbf
- File:
-
- 1 edited
-
src/comm/mpi/datatypes_local.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/comm/mpi/datatypes_local.cpp
re3dbbf r716da7 23 23 using namespace VMG; 24 24 25 static inline int to_1d(const int& x, const int& y, const int& z) 25 static inline int to_1d(const Index& i) __attribute__((always_inline)); 26 static inline int to_1d(const Index& i) 26 27 { 27 return z+3*(y+3*x);28 return i.Z()+3*(i.Y()+3*i.X()); 28 29 } 29 30 … … 36 37 37 38 template <class T> 38 void VMG::MPI::DatatypesLocal::InitDatatypesLocal(const T& grid, const MPI_Comm& comm )39 void VMG::MPI::DatatypesLocal::InitDatatypesLocal(const T& grid, const MPI_Comm& comm, const bool& alloc_buffer) 39 40 { 40 41 if (comm != MPI_COMM_NULL) { … … 43 44 Index dims, periods, coords; 44 45 Index sizes, subsizes, starts; 46 Index offset, i; 45 47 const LocalIndices& l = grid.Local(); 46 48 47 49 MPI_Cart_get(comm, 3, dims.vec(), periods.vec(), coords.vec()); 48 50 49 for (i nt i=-1; i<=1; ++i)50 for (i nt j=-1; j<=1; ++j)51 for (i nt k=-1; k<=1; ++k)52 if (is_valid(coords + Index(i,j,k), dims, periods))53 MPI_Cart_rank(comm, (coords + Index(i,j,k)).vec(), &ranks[to_1d(i+1,j+1,k+1)]);51 for (i.X()=-1; i.X()<=1; ++i.X()) 52 for (i.Y()=-1; i.Y()<=1; ++i.Y()) 53 for (i.Z()=-1; i.Z()<=1; ++i.Z()) 54 if (is_valid(coords + i, dims, periods)) 55 MPI_Cart_rank(comm, (coords + i).vec(), &ranks[to_1d(i+1)]); 54 56 55 57 sizes = l.SizeTotal(); 56 58 57 59 /* -1 0 0 */ 58 if (is_valid(coords + Index(-1,0,0), dims, periods)) { 59 index = to_1d(0,1,1); 60 offset = Index(-1,0,0); 61 if (is_valid(coords + offset, dims, periods)) { 62 index = to_1d(offset+1); 60 63 subsizes = Index(l.HaloSize1().X(), l.Size().Y(), l.Size().Z()); 61 64 starts = Index(0, l.Begin().Y(), l.Begin().Z()); 62 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 0, 1)); 63 starts = l.Begin(); 64 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 0, 1)); 65 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 0, 1, alloc_buffer)); 66 starts = l.Begin(); 67 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 0, 1, alloc_buffer)); 68 _offset.push_back(offset); 65 69 } 66 70 67 71 /* 1 0 0 */ 68 if (is_valid(coords + Index(1,0,0), dims, periods)) { 69 index = to_1d(2,1,1); 72 offset = Index(1,0,0); 73 if (is_valid(coords + offset, dims, periods)) { 74 index = to_1d(offset+1); 70 75 subsizes = Index(l.HaloSize2().X(), l.Size().Y(), l.Size().Z()); 71 76 starts = Index(l.End().X(), l.Begin().Y(), l.Begin().Z()); 72 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 1, 0));77 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 1, 0, alloc_buffer)); 73 78 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z()); 74 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 1, 0)); 79 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 1, 0, alloc_buffer)); 80 _offset.push_back(offset); 75 81 } 76 82 77 83 /* 0 -1 0 */ 78 if (is_valid(coords + Index(0,-1,0), dims, periods)) { 79 index = to_1d(1,0,1); 84 offset = Index(0,-1,0); 85 if (is_valid(coords + offset, dims, periods)) { 86 index = to_1d(offset+1); 80 87 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.Size().Z()); 81 88 starts = Index(l.Begin().X(), 0, l.Begin().Z()); 82 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 2, 3)); 83 starts = l.Begin(); 84 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 2, 3)); 89 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 2, 3, alloc_buffer)); 90 starts = l.Begin(); 91 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 2, 3, alloc_buffer)); 92 _offset.push_back(offset); 85 93 } 86 94 87 95 /* 0 1 0 */ 88 if (is_valid(coords + Index(0,1,0), dims, periods)) { 89 index = to_1d(1,2,1); 96 offset = Index(0,1,0); 97 if (is_valid(coords + offset, dims, periods)) { 98 index = to_1d(offset+1); 90 99 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.Size().Z()); 91 100 starts = Index(l.Begin().X(), l.End().Y(), l.Begin().Z()); 92 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 3, 2));101 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 3, 2, alloc_buffer)); 93 102 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 94 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 3, 2)); 103 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 3, 2, alloc_buffer)); 104 _offset.push_back(offset); 95 105 } 96 106 97 107 /* 0 0 -1 */ 98 if (is_valid(coords + Index(0,0,-1), dims, periods)) { 99 index = to_1d(1,1,0); 108 offset = Index(0,0,-1); 109 if (is_valid(coords + offset, dims, periods)) { 110 index = to_1d(offset+1); 100 111 subsizes = Index(l.Size().X(), l.Size().Y(), l.HaloSize1().Z()); 101 112 starts = Index(l.Begin().X(), l.Begin().Y(), 0); 102 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 4, 5)); 103 starts = l.Begin(); 104 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 4, 5)); 113 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 4, 5, alloc_buffer)); 114 starts = l.Begin(); 115 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 4, 5, alloc_buffer)); 116 _offset.push_back(offset); 105 117 } 106 118 107 119 /* 0 0 1 */ 108 if (is_valid(coords + Index(0,0,1), dims, periods)) { 109 index = to_1d(1,1,2); 120 offset = Index(0,0,1); 121 if (is_valid(coords + offset, dims, periods)) { 122 index = to_1d(offset+1); 110 123 subsizes = Index(l.Size().X(), l.Size().Y(), l.HaloSize2().Z()); 111 124 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()); 112 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 5, 4));125 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 5, 4, alloc_buffer)); 113 126 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 114 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 5, 4)); 127 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 5, 4, alloc_buffer)); 128 _offset.push_back(offset); 115 129 } 116 130 117 131 /* -1 -1 0 */ 118 if (is_valid(coords + Index(-1,-1,0), dims, periods)) { 119 index = to_1d(0,0,1); 132 offset = Index(-1,-1,0); 133 if (is_valid(coords + offset, dims, periods)) { 134 index = to_1d(offset+1); 120 135 subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.Size().Z()); 121 136 starts = Index(0, 0, l.Begin().Z()); 122 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 6, 7)); 123 starts = l.Begin(); 124 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 6, 7)); 137 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 6, 7, alloc_buffer)); 138 starts = l.Begin(); 139 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 6, 7, alloc_buffer)); 140 _offset.push_back(offset); 125 141 } 126 142 127 143 /* -1 1 0 */ 128 if (is_valid(coords + Index(-1,1,0), dims, periods)) { 129 index = to_1d(0,2,1); 144 offset = Index(-1,1,0); 145 if (is_valid(coords + offset, dims, periods)) { 146 index = to_1d(offset+1); 130 147 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.Size().Z()); 131 148 starts = Index(0, l.End().Y(), l.Begin().Z()); 132 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 8, 9));149 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 8, 9, alloc_buffer)); 133 150 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 134 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 8, 9)); 151 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 8, 9, alloc_buffer)); 152 _offset.push_back(offset); 135 153 } 136 154 137 155 /* 1 -1 0 */ 138 if (is_valid(coords + Index(1,-1,0), dims, periods)) { 139 index = to_1d(2,0,1); 156 offset = Index(1,-1,0); 157 if (is_valid(coords + offset, dims, periods)) { 158 index = to_1d(offset+1); 140 159 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.Size().Z()); 141 160 starts = Index(l.End().X(), 0, l.Begin().Z()); 142 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 9, 8));161 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 9, 8, alloc_buffer)); 143 162 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z()); 144 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 9, 8)); 163 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 9, 8, alloc_buffer)); 164 _offset.push_back(offset); 145 165 } 146 166 147 167 /* 1 1 0 */ 148 if (is_valid(coords + Index(1,1,0), dims, periods)) { 149 index = to_1d(2,2,1); 168 offset = Index(1,1,0); 169 if (is_valid(coords + offset, dims, periods)) { 170 index = to_1d(offset+1); 150 171 subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.Size().Z()); 151 172 starts = Index(l.End().X(), l.End().Y(), l.Begin().Z()); 152 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 7, 6));173 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 7, 6, alloc_buffer)); 153 174 starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 154 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 7, 6)); 175 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 7, 6, alloc_buffer)); 176 _offset.push_back(offset); 155 177 } 156 178 157 179 /* -1 0 -1 */ 158 if (is_valid(coords + Index(-1,0,-1), dims, periods)) { 159 index = to_1d(0,1,0); 180 offset = Index(-1,0,-1); 181 if (is_valid(coords + offset, dims, periods)) { 182 index = to_1d(offset+1); 160 183 subsizes = Index(l.HaloSize1().X(), l.Size().Y(), l.HaloSize1().Z()); 161 184 starts = Index(0, l.Begin().Y(), 0); 162 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 10, 11)); 163 starts = l.Begin(); 164 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 10, 11)); 185 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 10, 11, alloc_buffer)); 186 starts = l.Begin(); 187 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 10, 11, alloc_buffer)); 188 _offset.push_back(offset); 165 189 } 166 190 167 191 /* -1 0 1 */ 168 if (is_valid(coords + Index(-1,0,1), dims, periods)) { 169 index = to_1d(0,1,2); 192 offset = Index(-1,0,1); 193 if (is_valid(coords + offset, dims, periods)) { 194 index = to_1d(offset+1); 170 195 subsizes = Index(l.HaloSize1().X(), l.Size().Y(), l.HaloSize2().Z()); 171 196 starts = Index(0, l.Begin().Y(), l.End().Z()); 172 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 12, 13));197 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 12, 13, alloc_buffer)); 173 198 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 174 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 12, 13)); 199 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 12, 13, alloc_buffer)); 200 _offset.push_back(offset); 175 201 } 176 202 177 203 /* 1 0 -1 */ 178 if (is_valid(coords + Index(1,0,-1), dims, periods)) { 179 index = to_1d(2,1,0); 204 offset = Index(1,0,-1); 205 if (is_valid(coords + offset, dims, periods)) { 206 index = to_1d(offset+1); 180 207 subsizes = Index(l.HaloSize2().X(), l.Size().Y(), l.HaloSize1().Z()); 181 208 starts = Index(l.End().X(), l.Begin().Y(), 0); 182 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 13, 12));209 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 13, 12, alloc_buffer)); 183 210 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z()); 184 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 13, 12)); 211 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 13, 12, alloc_buffer)); 212 _offset.push_back(offset); 185 213 } 186 214 187 215 /* 1 0 1 */ 188 if (is_valid(coords + Index(1,0,1), dims, periods)) { 189 index = to_1d(2,1,2); 216 offset = Index(1,0,1); 217 if (is_valid(coords + offset, dims, periods)) { 218 index = to_1d(offset+1); 190 219 subsizes = Index(l.HaloSize2().X(), l.Size().Y(), l.HaloSize2().Z()); 191 220 starts = Index(l.End().X(), l.Begin().Y(), l.End().Z()); 192 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 11, 10));221 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 11, 10, alloc_buffer)); 193 222 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 194 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 11, 10)); 223 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 11, 10, alloc_buffer)); 224 _offset.push_back(offset); 195 225 } 196 226 197 227 /* 0 -1 -1 */ 198 if (is_valid(coords + Index(0,-1,-1), dims, periods)) { 199 index = to_1d(1,0,0); 228 offset = Index(0,-1,-1); 229 if (is_valid(coords + offset, dims, periods)) { 230 index = to_1d(offset+1); 200 231 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize1().Z()); 201 232 starts = Index(l.Begin().X(), 0, 0); 202 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15));233 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer)); 203 234 starts = l.Begin(); 204 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15)); 235 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer)); 236 _offset.push_back(offset); 205 237 } 206 238 207 239 /* 0 -1 1 */ 208 if (is_valid(coords + Index(0,-1,1), dims, periods)) { 209 index = to_1d(1,0,2); 240 offset = Index(0,-1,1); 241 if (is_valid(coords + offset, dims, periods)) { 242 index = to_1d(offset+1); 210 243 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 211 244 starts = Index(l.Begin().X(), 0, l.End().Z()); 212 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17));245 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer)); 213 246 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 214 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17)); 247 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer)); 248 _offset.push_back(offset); 215 249 } 216 250 217 251 /* 0 1 -1 */ 218 if (is_valid(coords + Index(0,1,-1), dims, periods)) { 219 index = to_1d(1,2,0); 252 offset = Index(0,1,-1); 253 if (is_valid(coords + offset, dims, periods)) { 254 index = to_1d(offset+1); 220 255 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 221 256 starts = Index(l.Begin().X(), l.End().Y(), 0); 222 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16));257 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer)); 223 258 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 224 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16)); 259 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer)); 260 _offset.push_back(offset); 225 261 } 226 262 227 263 /* 0 1 1 */ 228 if (is_valid(coords + Index(0,1,1), dims, periods)) { 229 index = to_1d(1,2,2); 264 offset = Index(0,1,1); 265 if (is_valid(coords + offset, dims, periods)) { 266 index = to_1d(offset+1); 230 267 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize2().Z()); 231 268 starts = Index(l.Begin().X(), l.End().Y(), l.End().Z()); 232 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14));269 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer)); 233 270 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z()); 234 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14)); 271 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer)); 272 _offset.push_back(offset); 235 273 } 236 274 237 275 /* -1 -1 -1 */ 238 if (is_valid(coords + Index(-1,-1,-1), dims, periods)) { 239 index = to_1d(0,0,0); 276 offset = Index(-1,-1,-1); 277 if (is_valid(coords + offset, dims, periods)) { 278 index = to_1d(offset+1); 240 279 subsizes = l.HaloSize1(); 241 280 starts = 0; 242 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19));281 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer)); 243 282 starts = l.Begin(); 244 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19)); 283 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer)); 284 _offset.push_back(offset); 245 285 } 246 286 247 287 /* -1 -1 1 */ 248 if (is_valid(coords + Index(-1,-1,1), dims, periods)) { 249 index = to_1d(0,0,2); 288 offset = Index(-1,-1,1); 289 if (is_valid(coords + offset, dims, periods)) { 290 index = to_1d(offset+1); 250 291 subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 251 292 starts = Index(0, 0, l.End().Z());; 252 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21));293 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer)); 253 294 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 254 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21)); 295 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer)); 296 _offset.push_back(offset); 255 297 } 256 298 257 299 /* -1 1 -1 */ 258 if (is_valid(coords + Index(-1,1,-1), dims, periods)) { 259 index = to_1d(0,2,0); 300 offset = Index(-1,1,-1); 301 if (is_valid(coords + offset, dims, periods)) { 302 index = to_1d(offset+1); 260 303 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 261 304 starts = Index(0, l.End().Y(), 0); 262 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23));305 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer)); 263 306 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 264 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23)); 307 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer)); 308 _offset.push_back(offset); 265 309 } 266 310 267 311 /* 1 -1 -1 */ 268 if (is_valid(coords + Index(1,-1,-1), dims, periods)) { 269 index = to_1d(2,0,0); 312 offset = Index(1,-1,-1); 313 if (is_valid(coords + offset, dims, periods)) { 314 index = to_1d(offset+1); 270 315 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize1().Z()); 271 316 starts = Index(l.End().X(), 0, 0); 272 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25));317 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer)); 273 318 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z()); 274 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25)); 319 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer)); 320 _offset.push_back(offset); 275 321 } 276 322 277 323 /* -1 1 1 */ 278 if (is_valid(coords + Index(-1,1,1), dims, periods)) { 279 index = to_1d(0,2,2); 324 offset = Index(-1,1,1); 325 if (is_valid(coords + offset, dims, periods)) { 326 index = to_1d(offset+1); 280 327 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize2().Z()); 281 328 starts = Index(0, l.End().Y(), l.End().Z()); 282 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24));329 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer)); 283 330 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z()); 284 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24)); 331 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer)); 332 _offset.push_back(offset); 285 333 } 286 334 287 335 /* 1 -1 1 */ 288 if (is_valid(coords + Index(1,-1,1), dims, periods)) { 289 index = to_1d(2,0,2); 336 offset = Index(1,-1,1); 337 if (is_valid(coords + offset, dims, periods)) { 338 index = to_1d(offset+1); 290 339 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 291 340 starts = Index(l.End().X(), 0, l.End().Z()); 292 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22));341 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer)); 293 342 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 294 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22)); 343 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer)); 344 _offset.push_back(offset); 295 345 } 296 346 297 347 /* 1 1 -1 */ 298 if (is_valid(coords + Index(1,1,-1), dims, periods)) { 299 index = to_1d(2,2,0); 348 offset = Index(1,1,-1); 349 if (is_valid(coords + offset, dims, periods)) { 350 index = to_1d(offset+1); 300 351 subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 301 352 starts = Index(l.End().X(), l.End().Y(), 0); 302 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20));353 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer)); 303 354 starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 304 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20)); 355 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer)); 356 _offset.push_back(offset); 305 357 } 306 358 307 359 /* 1 1 1 */ 308 if (is_valid(coords + Index(1,1,1), dims, periods)) { 309 index = to_1d(2,2,2); 360 offset = Index(1,1,1); 361 if (is_valid(coords + offset, dims, periods)) { 362 index = to_1d(offset+1); 310 363 subsizes = l.HaloSize2(); 311 364 starts = l.End(); 312 halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18));365 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer)); 313 366 starts = l.End()-l.HaloSize2(); 314 nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18)); 367 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer)); 368 _offset.push_back(offset); 315 369 } 316 370 … … 318 372 } 319 373 320 template void VMG::MPI::DatatypesLocal::InitDatatypesLocal<VMG::Grid>(const VMG::Grid& grid, const MPI_Comm& comm );321 template void VMG::MPI::DatatypesLocal::InitDatatypesLocal<VMG::Particle::LinkedCellList>(const VMG::Particle::LinkedCellList& grid, const MPI_Comm& comm );322 374 template void VMG::MPI::DatatypesLocal::InitDatatypesLocal<VMG::Grid>(const VMG::Grid& grid, const MPI_Comm& comm, const bool& alloc_buffer); 375 template void VMG::MPI::DatatypesLocal::InitDatatypesLocal<VMG::Particle::LinkedCellList>(const VMG::Particle::LinkedCellList& grid, const MPI_Comm& comm, const bool& alloc_buffer); 376
Note:
See TracChangeset
for help on using the changeset viewer.
