Octopus
mpi_distribute.F90
Go to the documentation of this file.
1!! Copyright (C) 2024 A. Buccheri
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18#include "global.h"
19
21 use debug_oct_m
22 use global_oct_m
25 implicit none
26 private
27
28 public :: mpi_displacements
29
30 interface mpi_displacements
32 end interface mpi_displacements
33
34contains
35
37 subroutine mpi_displacements_int32(recvcounts, displs)
38 integer, intent(in ) :: recvcounts(:)
39 integer, intent(out) :: displs(:)
40 ! at which to place the incoming data from process i-1
41 integer :: n_processes, i
42
43 push_sub(mpi_displacements)
44
45 n_processes = size(displs)
46 assert(size(recvcounts) == n_processes)
47
48 displs(1) = 0
49 do i = 2, n_processes
50 displs(i) = displs(i-1) + recvcounts(i-1)
51 enddo
52
53 pop_sub(mpi_displacements)
54 end subroutine mpi_displacements_int32
55
56
58 subroutine mpi_displacements_int64(recvcounts, displs)
59 integer, intent(in ) :: recvcounts(:)
60 integer(int64), intent(out) :: displs(:)
61 ! at which to place the incoming data from process i-1
62 integer :: n_processes, i
63
64 push_sub(mpi_displacements)
65
66 n_processes = size(displs)
67 assert(size(recvcounts) == n_processes)
68
69 displs(1) = 0
70 do i = 2, n_processes
71 displs(i) = displs(i-1) + recvcounts(i-1)
72 enddo
73
74 pop_sub(mpi_displacements)
75 end subroutine mpi_displacements_int64
76
77end module mpi_distribute_oct_m
subroutine mpi_displacements_int64(recvcounts, displs)
Compute the displacements required for (all)gather(v) and (all)scatter(v).
subroutine mpi_displacements_int32(recvcounts, displs)
Compute the displacements required for (all)gather(v) and (all)scatter(v).