Changeset 422:91f0799329d5
- Timestamp:
- 11/12/2012 09:20:30 PM (7 months ago)
- Author:
- Andreas Schaefer <gentryx@…>
- Branch:
- default
- Message:
-
adding dirty interim wrapper for MPI_Gatherv()
- Location:
- src
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r342
|
r422
|
|
| 19 | 19 | template<typename CELL_TYPE, typename SELECTOR_TYPE> |
| 20 | 20 | class BOVWriter : public ParallelWriter<CELL_TYPE> |
| 21 | | { |
| | 21 | { |
| 22 | 22 | public: |
| 23 | 23 | friend class BOVWriterTest; |
-
|
r245
|
r422
|
|
| 35 | 35 | const std::string& _prefix, |
| 36 | 36 | DistributedSimulator<CELL_TYPE> *_distSim, |
| 37 | | const unsigned& _period = 1): |
| | 37 | const unsigned& _period = 1) : |
| 38 | 38 | prefix(_prefix), distSim(_distSim), period(_period) |
| 39 | 39 | { |
-
|
r366
|
r422
|
|
| 324 | 324 | SuperVector<int> displacements(size()); |
| 325 | 325 | displacements[0] = 0; |
| 326 | | for (int i = 0; i < size() - 1; ++i) |
| | 326 | for (int i = 0; i < size() - 1; ++i) { |
| 327 | 327 | displacements[i + 1] = displacements[i] + lengths[i]; |
| | 328 | } |
| 328 | 329 | comm->Allgatherv(source, lengths[rank()], datatype, &(target->front()), &(lengths.front()), &(displacements.front()), datatype); |
| 329 | 330 | } |
| … |
… |
|
| 342 | 343 | return SuperVector<T>(); |
| 343 | 344 | } |
| | 345 | } |
| | 346 | |
| | 347 | // fixme: needs test |
| | 348 | template<typename T> |
| | 349 | inline void gatherV( |
| | 350 | const T *source, |
| | 351 | const int num, |
| | 352 | const SuperVector<int>& lengths, |
| | 353 | const unsigned& root, |
| | 354 | SuperVector<T> *target, |
| | 355 | const MPI::Datatype& datatype = Typemaps::lookup<T>()) const |
| | 356 | { |
| | 357 | SuperVector<int> displacements(size()); |
| | 358 | if (rank() == root) { |
| | 359 | displacements[0] = 0; |
| | 360 | for (int i = 0; i < size() - 1; ++i) { |
| | 361 | displacements[i + 1] = displacements[i] + lengths[i]; |
| | 362 | } |
| | 363 | } |
| | 364 | |
| | 365 | // std::cout << "num[" << rank() << "]: " << num << "\n"; |
| | 366 | // std::cout << "lengths[" << rank() << "]: " << lengths << "\n"; |
| | 367 | // std::cout << "displacements[" << rank() << "]: " << displacements << "\n"; |
| | 368 | // std::cout << "targetsize[" << rank() << "]: " << target->size() << "\n"; |
| | 369 | |
| | 370 | comm->Gatherv(source, num, datatype, |
| | 371 | &(*target)[0], &lengths[0], &displacements[0], datatype, |
| | 372 | root); |
| 344 | 373 | } |
| 345 | 374 | |