----------------------------------------------------------------------------- -----------------------------------------------------------------------------
| 854 | //----------------------------------------------------------------------------- |
| 855 | //----------------------------------------------------------------------------- |
| 856 | IndexMap::IndexMap(MPI_Comm comm, std::int32_t local_size) : _comm(comm, true) |
| 857 | { |
| 858 | // Get global offset (index), using partial exclusive reduction |
| 859 | std::int64_t offset = 0; |
| 860 | const std::int64_t local_size_tmp = local_size; |
| 861 | MPI_Request request_scan; |
| 862 | int ierr = MPI_Iexscan(&local_size_tmp, &offset, 1, MPI_INT64_T, MPI_SUM, |
| 863 | _comm.comm(), &request_scan); |
| 864 | dolfinx::MPI::check_error(_comm.comm(), ierr); |
| 865 | |
| 866 | // Send local size to sum reduction to get global size |
| 867 | MPI_Request request; |
| 868 | ierr = MPI_Iallreduce(&local_size_tmp, &_size_global, 1, MPI_INT64_T, MPI_SUM, |
| 869 | comm, &request); |
| 870 | dolfinx::MPI::check_error(_comm.comm(), ierr); |
| 871 | |
| 872 | ierr = MPI_Wait(&request_scan, MPI_STATUS_IGNORE); |
| 873 | dolfinx::MPI::check_error(_comm.comm(), ierr); |
| 874 | _local_range = {offset, offset + local_size}; |
| 875 | |
| 876 | // Wait for the MPI_Iallreduce to complete |
| 877 | ierr = MPI_Wait(&request, MPI_STATUS_IGNORE); |
| 878 | dolfinx::MPI::check_error(_comm.comm(), ierr); |
| 879 | } |
| 880 | //----------------------------------------------------------------------------- |
| 881 | IndexMap::IndexMap(MPI_Comm comm, std::int32_t local_size, |
| 882 | std::span<const std::int64_t> ghosts, |