Changeset 8180d8 for src/comm/mpi
- Timestamp:
- Apr 5, 2013, 12:39:30 PM (13 years ago)
- Children:
- 4a709e
- Parents:
- f57182
- Location:
- src/comm/mpi
- Files:
-
- 4 edited
-
datatype.cpp (modified) (6 diffs)
-
datatypes_local.hpp (modified) (4 diffs)
-
key.hpp (modified) (1 diff)
-
settings.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/comm/mpi/datatype.cpp
rf57182 r8180d8 72 72 for (i.X()=_starts.X(); i.X()<end.X(); ++i.X()) 73 73 for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) { 74 std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);75 c += _subsizes.Z();74 std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size); 75 c += _subsizes.Z(); 76 76 } 77 77 … … 91 91 for (i.X()=_starts.X(); i.X()<end.X(); ++i.X()) 92 92 for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) { 93 std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);94 c += _subsizes.Z();93 std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size); 94 c += _subsizes.Z(); 95 95 } 96 96 … … 124 124 for (i.X()=_starts.X(); i.X()<end.X(); ++i.X()) 125 125 for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) { 126 std::memcpy(&grid(i.X(), i.Y(), _starts.Z()), &_buffer[c], memcpy_size);127 c += _subsizes.Z();126 std::memcpy(&grid(i.X(), i.Y(), _starts.Z()), &_buffer[c], memcpy_size); 127 c += _subsizes.Z(); 128 128 } 129 129 … … 142 142 for (i.X()=_starts.X(); i.X()<end.X(); ++i.X()) 143 143 for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) 144 for (i.Z()=_starts.Z(); i.Z()<end.Z(); ++i.Z())145 grid(i) += *iter++;144 for (i.Z()=_starts.Z(); i.Z()<end.Z(); ++i.Z()) 145 grid(i) += *iter++; 146 146 147 147 assert(iter == _buffer.end()); … … 150 150 151 151 void VMG::MPI::Datatype::Set(const GridIteratorSet& bounds, const Grid& grid, const int& rank, 152 const int& tag_send, const int& tag_receive)152 const int& tag_send, const int& tag_receive) 153 153 { 154 154 _sizes = grid.Local().SizeTotal(); … … 166 166 167 167 void VMG::MPI::Datatype::Set(const Index& sizes, const Index& subsizes, const Index& starts, const int& rank, 168 const int& tag_send, const int& tag_receive)168 const int& tag_send, const int& tag_receive) 169 169 { 170 170 _sizes = sizes; -
src/comm/mpi/datatypes_local.hpp
rf57182 r8180d8 37 37 DatatypesLocal(const T& grid, const MPI_Comm& comm, const bool& alloc) 38 38 { 39 InitDatatypesLocal(grid, comm, alloc);39 InitDatatypesLocal(grid, comm, alloc); 40 40 } 41 41 … … 69 69 { 70 70 return (periods[0] || (coord[0] >= 0 && coord[0] < dims[0])) && 71 (periods[1] || (coord[1] >= 0 && coord[1] < dims[1])) &&72 (periods[2] || (coord[2] >= 0 && coord[2] < dims[2]));71 (periods[1] || (coord[1] >= 0 && coord[1] < dims[1])) && 72 (periods[2] || (coord[2] >= 0 && coord[2] < dims[2])); 73 73 } 74 74 … … 90 90 for (i.X()=-1; i.X()<=1; ++i.X()) 91 91 for (i.Y()=-1; i.Y()<=1; ++i.Y()) 92 for (i.Z()=-1; i.Z()<=1; ++i.Z())93 if (_is_valid(coords + i, dims, periods))94 MPI_Cart_rank(comm, (coords + i).vec(), &ranks[to_1d(i+1)]);92 for (i.Z()=-1; i.Z()<=1; ++i.Z()) 93 if (_is_valid(coords + i, dims, periods)) 94 MPI_Cart_rank(comm, (coords + i).vec(), &ranks[to_1d(i+1)]); 95 95 96 96 sizes = l.SizeTotal(); … … 266 266 /* 0 -1 -1 */ 267 267 offset = Index(0,-1,-1); 268 if (_is_valid(coords + offset, dims, periods)) {269 index = to_1d(offset+1);270 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize1().Z());271 starts = Index(l.Begin().X(), 0, 0);272 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));273 starts = l.Begin();274 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));275 _offset.push_back(offset);276 }268 if (_is_valid(coords + offset, dims, periods)) { 269 index = to_1d(offset+1); 270 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize1().Z()); 271 starts = Index(l.Begin().X(), 0, 0); 272 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer)); 273 starts = l.Begin(); 274 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer)); 275 _offset.push_back(offset); 276 } 277 277 278 278 /* 0 -1 1 */ 279 offset = Index(0,-1,1);280 if (_is_valid(coords + offset, dims, periods)) {281 index = to_1d(offset+1);282 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize2().Z());283 starts = Index(l.Begin().X(), 0, l.End().Z());284 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));285 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());286 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));287 _offset.push_back(offset);288 }279 offset = Index(0,-1,1); 280 if (_is_valid(coords + offset, dims, periods)) { 281 index = to_1d(offset+1); 282 subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 283 starts = Index(l.Begin().X(), 0, l.End().Z()); 284 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer)); 285 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 286 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer)); 287 _offset.push_back(offset); 288 } 289 289 290 290 /* 0 1 -1 */ 291 offset = Index(0,1,-1);292 if (_is_valid(coords + offset, dims, periods)) {293 index = to_1d(offset+1);294 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize1().Z());295 starts = Index(l.Begin().X(), l.End().Y(), 0);296 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));297 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());298 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));299 _offset.push_back(offset);300 }291 offset = Index(0,1,-1); 292 if (_is_valid(coords + offset, dims, periods)) { 293 index = to_1d(offset+1); 294 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 295 starts = Index(l.Begin().X(), l.End().Y(), 0); 296 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer)); 297 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 298 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer)); 299 _offset.push_back(offset); 300 } 301 301 302 302 /* 0 1 1 */ 303 offset = Index(0,1,1);304 if (_is_valid(coords + offset, dims, periods)) {305 index = to_1d(offset+1);306 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize2().Z());307 starts = Index(l.Begin().X(), l.End().Y(), l.End().Z());308 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));309 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());310 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));311 _offset.push_back(offset);312 }303 offset = Index(0,1,1); 304 if (_is_valid(coords + offset, dims, periods)) { 305 index = to_1d(offset+1); 306 subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize2().Z()); 307 starts = Index(l.Begin().X(), l.End().Y(), l.End().Z()); 308 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer)); 309 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z()); 310 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer)); 311 _offset.push_back(offset); 312 } 313 313 314 314 /* -1 -1 -1 */ 315 offset = Index(-1,-1,-1);316 if (_is_valid(coords + offset, dims, periods)) {317 index = to_1d(offset+1);318 subsizes = l.HaloSize1();319 starts = 0;320 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));321 starts = l.Begin();322 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));323 _offset.push_back(offset);324 }315 offset = Index(-1,-1,-1); 316 if (_is_valid(coords + offset, dims, periods)) { 317 index = to_1d(offset+1); 318 subsizes = l.HaloSize1(); 319 starts = 0; 320 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer)); 321 starts = l.Begin(); 322 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer)); 323 _offset.push_back(offset); 324 } 325 325 326 326 /* -1 -1 1 */ 327 offset = Index(-1,-1,1);328 if (_is_valid(coords + offset, dims, periods)) {329 index = to_1d(offset+1);330 subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.HaloSize2().Z());331 starts = Index(0, 0, l.End().Z());;332 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));333 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());334 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));335 _offset.push_back(offset);336 }327 offset = Index(-1,-1,1); 328 if (_is_valid(coords + offset, dims, periods)) { 329 index = to_1d(offset+1); 330 subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 331 starts = Index(0, 0, l.End().Z());; 332 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer)); 333 starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 334 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer)); 335 _offset.push_back(offset); 336 } 337 337 338 338 /* -1 1 -1 */ 339 offset = Index(-1,1,-1);340 if (_is_valid(coords + offset, dims, periods)) {341 index = to_1d(offset+1);342 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize1().Z());343 starts = Index(0, l.End().Y(), 0);344 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));345 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());346 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));347 _offset.push_back(offset);348 }339 offset = Index(-1,1,-1); 340 if (_is_valid(coords + offset, dims, periods)) { 341 index = to_1d(offset+1); 342 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 343 starts = Index(0, l.End().Y(), 0); 344 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer)); 345 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 346 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer)); 347 _offset.push_back(offset); 348 } 349 349 350 350 /* 1 -1 -1 */ 351 offset = Index(1,-1,-1);352 if (_is_valid(coords + offset, dims, periods)) {353 index = to_1d(offset+1);354 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize1().Z());355 starts = Index(l.End().X(), 0, 0);356 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));357 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z());358 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));359 _offset.push_back(offset);360 }351 offset = Index(1,-1,-1); 352 if (_is_valid(coords + offset, dims, periods)) { 353 index = to_1d(offset+1); 354 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize1().Z()); 355 starts = Index(l.End().X(), 0, 0); 356 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer)); 357 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z()); 358 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer)); 359 _offset.push_back(offset); 360 } 361 361 362 362 /* -1 1 1 */ 363 offset = Index(-1,1,1);364 if (_is_valid(coords + offset, dims, periods)) {365 index = to_1d(offset+1);366 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize2().Z());367 starts = Index(0, l.End().Y(), l.End().Z());368 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));369 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());370 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));371 _offset.push_back(offset);372 }363 offset = Index(-1,1,1); 364 if (_is_valid(coords + offset, dims, periods)) { 365 index = to_1d(offset+1); 366 subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize2().Z()); 367 starts = Index(0, l.End().Y(), l.End().Z()); 368 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer)); 369 starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z()); 370 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer)); 371 _offset.push_back(offset); 372 } 373 373 374 374 /* 1 -1 1 */ 375 offset = Index(1,-1,1);376 if (_is_valid(coords + offset, dims, periods)) {377 index = to_1d(offset+1);378 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize2().Z());379 starts = Index(l.End().X(), 0, l.End().Z());380 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));381 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());382 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));383 _offset.push_back(offset);384 }375 offset = Index(1,-1,1); 376 if (_is_valid(coords + offset, dims, periods)) { 377 index = to_1d(offset+1); 378 subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize2().Z()); 379 starts = Index(l.End().X(), 0, l.End().Z()); 380 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer)); 381 starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z()); 382 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer)); 383 _offset.push_back(offset); 384 } 385 385 386 386 /* 1 1 -1 */ 387 offset = Index(1,1,-1);388 if (_is_valid(coords + offset, dims, periods)) {389 index = to_1d(offset+1);390 subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.HaloSize1().Z());391 starts = Index(l.End().X(), l.End().Y(), 0);392 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));393 starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());394 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));395 _offset.push_back(offset);396 }387 offset = Index(1,1,-1); 388 if (_is_valid(coords + offset, dims, periods)) { 389 index = to_1d(offset+1); 390 subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.HaloSize1().Z()); 391 starts = Index(l.End().X(), l.End().Y(), 0); 392 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer)); 393 starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z()); 394 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer)); 395 _offset.push_back(offset); 396 } 397 397 398 398 /* 1 1 1 */ 399 offset = Index(1,1,1);400 if (_is_valid(coords + offset, dims, periods)) {401 index = to_1d(offset+1);402 subsizes = l.HaloSize2();403 starts = l.End();404 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));405 starts = l.End()-l.HaloSize2();406 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));407 _offset.push_back(offset);408 }399 offset = Index(1,1,1); 400 if (_is_valid(coords + offset, dims, periods)) { 401 index = to_1d(offset+1); 402 subsizes = l.HaloSize2(); 403 starts = l.End(); 404 _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer)); 405 starts = l.End()-l.HaloSize2(); 406 _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer)); 407 _offset.push_back(offset); 408 } 409 409 410 410 } -
src/comm/mpi/key.hpp
rf57182 r8180d8 54 54 end(grid.Global().LocalEnd()), 55 55 size_local(grid.Local().SizeTotal()), 56 size_global(grid.Global().GlobalSize ()),56 size_global(grid.Global().GlobalSizeFinest()), 57 57 level(grid.Level()) 58 58 {} -
src/comm/mpi/settings.cpp
rf57182 r8180d8 96 96 97 97 if (temp_grid->Global().LocalBegin().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) && 98 temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&99 temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&100 temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {98 temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) && 99 temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) && 100 temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) { 101 101 delete temp_grid; 102 102 coarser_grids.insert(std::make_pair(&sol(i), &sol(i-1))); … … 113 113 114 114 if (temp_grid->Global().LocalBegin().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) && 115 temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&116 temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&117 temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {115 temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) && 116 temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) && 117 temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) { 118 118 delete temp_grid; 119 119 coarser_grids.insert(std::make_pair(&rhs(i), &rhs(i-1))); … … 133 133 134 134 if (temp_grid->Global().LocalBegin() == sol(i+1).Global().LocalBegin() && 135 temp_grid->Global().LocalEnd() == sol(i+1).Global().LocalEnd()) {135 temp_grid->Global().LocalEnd() == sol(i+1).Global().LocalEnd()) { 136 136 delete temp_grid; 137 137 finer_grids.insert(std::make_pair(&sol(i), &sol(i+1))); … … 148 148 149 149 if (temp_grid->Global().LocalBegin() == rhs(i+1).Global().LocalBegin() && 150 temp_grid->Global().LocalEnd() == rhs(i+1).Global().LocalEnd()) {150 temp_grid->Global().LocalEnd() == rhs(i+1).Global().LocalEnd()) { 151 151 delete temp_grid; 152 152 finer_grids.insert(std::make_pair(&rhs(i), &rhs(i+1))); … … 220 220 221 221 const bool in_communicator = (grid_1->Global().LocalSize().Product() > 0) || 222 (grid_2 && grid_2->Global().LocalSize().Product() > 0) ||223 (grid_3 && grid_3->Global().LocalSize().Product() > 0);222 (grid_2 && grid_2->Global().LocalSize().Product() > 0) || 223 (grid_3 && grid_3->Global().LocalSize().Product() > 0); 224 224 225 225 MPI_Comm_rank(comm_global, &rank); … … 263 263 for (iter=communicators_local_unique.begin(); iter!=communicators_local_unique.end(); ++iter) { 264 264 if (*iter != MPI_COMM_NULL) { 265 MPI_Comm_compare(comm_new, *iter, &comm_equal);266 assert(comm_equal != MPI_SIMILAR);267 if (comm_equal == MPI_IDENT || comm_equal == MPI_CONGRUENT) {268 MPI_Comm_free(&comm_new);269 comm_new = *iter;270 break;271 }265 MPI_Comm_compare(comm_new, *iter, &comm_equal); 266 assert(comm_equal != MPI_SIMILAR); 267 if (comm_equal == MPI_IDENT || comm_equal == MPI_CONGRUENT) { 268 MPI_Comm_free(&comm_new); 269 comm_new = *iter; 270 break; 271 } 272 272 } 273 273 } … … 283 283 bool dt_is_new = true; 284 284 285 // Insert into map285 // Insert into map 286 286 std::pair< std::map<VMG::MPI::KeyUnsorted, VMG::MPI::DatatypesGlobal>::iterator, bool > insert_result = 287 datatypes_global.insert(std::make_pair(VMG::MPI::KeyUnsorted(grid_old, grid_new, direction), VMG::MPI::DatatypesGlobal()));287 datatypes_global.insert(std::make_pair(VMG::MPI::KeyUnsorted(grid_old, grid_new, direction), VMG::MPI::DatatypesGlobal())); 288 288 VMG::MPI::DatatypesGlobal& dt_global = insert_result.first->second; 289 289 dt_is_new = insert_result.second; … … 310 310 if (&grid_old == &grid_new) { 311 311 for (int i=0; i<6; ++i) 312 buffer[6*rank+i] = 0;312 buffer[6*rank+i] = 0; 313 313 }else { 314 314 for (int i=0; i<3; ++i) { 315 buffer[6*rank+i] = grid_old.Global().LocalBegin()[i];316 buffer[6*rank+i+3] = grid_old.Global().LocalEnd()[i];315 buffer[6*rank+i] = grid_old.Global().LocalBegin()[i]; 316 buffer[6*rank+i+3] = grid_old.Global().LocalEnd()[i]; 317 317 } 318 318 } … … 324 324 // Decide who offers a useful grid part 325 325 for (int i=0; i<size; ++i) { 326 for (int j=0; j<3; ++j) {327 begin[j] = buffer[6*i+j];328 end[j] = buffer[6*i+j+3];329 }330 331 begin = begin.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());332 end = end.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());333 334 if ((end-begin).Product() > 0) {335 // This process has a useful part336 dt_global.Receive().push_back(VMG::MPI::Datatype(grid_new.Local().SizeTotal(),337 end - begin,338 begin - grid_new.Global().LocalBegin() + offset_new,339 i, 0, 0, true));340 }326 for (int j=0; j<3; ++j) { 327 begin[j] = buffer[6*i+j]; 328 end[j] = buffer[6*i+j+3]; 329 } 330 331 begin = begin.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd()); 332 end = end.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd()); 333 334 if ((end-begin).Product() > 0) { 335 // This process has a useful part 336 dt_global.Receive().push_back(VMG::MPI::Datatype(grid_new.Local().SizeTotal(), 337 end - begin, 338 begin - grid_new.Global().LocalBegin() + grid_new.Global().GlobalBegin() + offset_new, 339 i, 0, 0, true)); 340 } 341 341 } 342 342 } … … 355 355 for (int i=0; i<size; ++i) { 356 356 357 if ((i == rank) && (&grid_old == &grid_new))358 continue;359 360 for (int j=0; j<3; ++j) {361 begin[j] = buffer[6*i+j];362 end[j] = buffer[6*i+j+3];363 }364 365 begin = begin.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());366 end = end.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());367 368 if ((end-begin).Product() > 0) {369 // This process needs one of my parts370 dt_global.Send().push_back(VMG::MPI::Datatype(grid_old.Local().SizeTotal(),371 end - begin,372 begin - grid_old.Global().LocalBegin() + offset_old,373 i, 0, 0, true));374 }357 if ((i == rank) && (&grid_old == &grid_new)) 358 continue; 359 360 for (int j=0; j<3; ++j) { 361 begin[j] = buffer[6*i+j]; 362 end[j] = buffer[6*i+j+3]; 363 } 364 365 begin = begin.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd()); 366 end = end.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd()); 367 368 if ((end-begin).Product() > 0) { 369 // This process needs one of my parts 370 dt_global.Send().push_back(VMG::MPI::Datatype(grid_old.Local().SizeTotal(), 371 end - begin, 372 begin - grid_old.Global().LocalBegin() + grid_old.Global().GlobalBegin() + offset_old, 373 i, 0, 0, true)); 374 } 375 375 } 376 376 } … … 379 379 380 380 MPI_Datatype& VMG::MPI::Settings::Datatype(const Index& begin, const Index& end, 381 const Index& size_local, const Index& size_global,382 const int& level)381 const Index& size_local, const Index& size_global, 382 const int& level) 383 383 { 384 384 KeyUnsorted k(begin, end, size_local, size_global, level, 0);
Note:
See TracChangeset
for help on using the changeset viewer.
