| 582 | } |
| 583 | |
| 584 | ObjectHandle MPIDistributedDevice::allocateHandle() |
| 585 | { |
| 586 | mpicommon::barrier(mpicommon::worker.comm).wait(); |
| 587 | ObjectHandle handle = ObjectHandle::allocateLocalHandle(); |
| 588 | |
| 589 | // For debugging check that all ranks did in fact allocate the same handle. |
| 590 | // Typically we assume this is the case, as the app should be creating |
| 591 | // distributed objects in lock-step, even if their local objects differ. |
| 592 | if (logLevel == OSP_LOG_DEBUG) { |
| 593 | int maxID = handle.i32.ID; |
| 594 | int minID = handle.i32.ID; |
| 595 | |
| 596 | auto reduceMax = mpicommon::reduce( |
| 597 | &handle.i32.ID, &maxID, 1, MPI_INT, MPI_MAX, 0, mpicommon::worker.comm); |
| 598 | auto reduceMin = mpicommon::reduce( |
| 599 | &handle.i32.ID, &minID, 1, MPI_INT, MPI_MIN, 0, mpicommon::worker.comm); |
| 600 | reduceMax.wait(); |
| 601 | reduceMin.wait(); |
| 602 | |
| 603 | if (maxID != minID) { |
| 604 | // Log it, but this is a fatal error |
| 605 | postStatusMsg( |
| 606 | "Error allocating distributed handles: Ranks do not all have the same handle!"); |
| 607 | throw std::runtime_error( |
| 608 | "Error allocating distributed handles: Ranks do not all have the same handle!"); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | return handle; |
| 613 | } |
| 614 | |
| 615 | } // namespace mpi |
| 616 | } // namespace ospray |
nothing calls this directly
no test coverage detected