Octopus
mpi_lib.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
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
19#include "global.h"
20
22module mpi_lib_oct_m
23 use debug_oct_m
24 use global_oct_m
26 use mpi_oct_m
29
30 implicit none
31
32 private
33
34#if !defined(HAVE_MPI)
35 integer, public :: mpi_lib_dummy
36#else
37 public :: &
44
49
50 interface lmpi_gen_allgatherv
53 end interface lmpi_gen_allgatherv
54
55#endif
56
57contains
58#if defined(HAVE_MPI)
59 ! ---------------------------------------------------------
62 integer function lmpi_translate_rank(from_comm, to_comm, rank)
63 type(MPI_Comm), intent(in) :: from_comm
64 type(MPI_Comm), intent(in) :: to_comm
65 integer, intent(in) :: rank
66
67 type(MPI_Group) :: from_group, to_group
68 integer :: from_rank(1), to_rank(1)
69
70 push_sub(lmpi_translate_rank)
71
72 call mpi_comm_group(from_comm, from_group, mpi_err)
73 call mpi_comm_group(to_comm, to_group, mpi_err)
74
75 from_rank(1) = rank
76 call mpi_group_translate_ranks(from_group, 1, from_rank, to_group, to_rank, mpi_err)
77
78 lmpi_translate_rank = to_rank(1)
79
80 pop_sub(lmpi_translate_rank)
81 end function lmpi_translate_rank
82
83 ! destroy a shared memory segment as an MPI window
84 subroutine lmpi_destroy_shared_memory_window(window)
85 type(MPI_Win), intent(inout) :: window
86
88
89 ! end access epoch
90 call mpi_win_unlock_all(window, mpi_err)
91 ! destroy window
92 call mpi_win_free(window, mpi_err)
93
96
97 ! synchronize a shared memory segment
98 subroutine lmpi_sync_shared_memory_window(window, intranode_grp)
99 type(MPI_Win), intent(in) :: window
100 type(mpi_grp_t), intent(in) :: intranode_grp
101
103
104 call mpi_win_sync(window, mpi_err)
105 call intranode_grp%barrier()
106
108 end subroutine lmpi_sync_shared_memory_window
109
110 subroutine create_intranode_communicator(base_grp, intranode_grp, internode_grp)
111 type(mpi_grp_t), intent(in) :: base_grp
112 type(mpi_grp_t), intent(out) :: intranode_grp
113 type(mpi_grp_t), intent(out) :: internode_grp
114 type(MPI_Comm) :: comm
117
118 ! create communicator for intranode communication
119 ! this is used for MPI-3 shared memory windows
120 call mpi_comm_split_type(base_grp%comm, mpi_comm_type_shared, base_grp%rank, mpi_info_null, comm, mpi_err)
121 call mpi_grp_init(intranode_grp, comm)
122
123 ! create communicator for internode communication
124 ! we have one communicator for each local rank
125 call mpi_comm_split(base_grp%comm, intranode_grp%rank, base_grp%rank, comm, mpi_err)
126 call mpi_grp_init(internode_grp, comm)
127
129 end subroutine create_intranode_communicator
130
131#include "undef.F90"
132#include "real.F90"
133#include "mpi_lib_inc.F90"
134
135#include "undef.F90"
136#include "complex.F90"
137#include "mpi_lib_inc.F90"
139#include "undef.F90"
140#include "integer.F90"
141#include "mpi_lib_inc.F90"
142
143#include "undef.F90"
144#include "integer8.F90"
145#include "mpi_lib_inc.F90"
146#endif
147end module mpi_lib_oct_m
148
149
150!! Local Variables:
151!! mode: f90
152!! coding: utf-8
153!! End:
This module contains some common usage patterns of MPI routines.
Definition: mpi_lib.F90:115
subroutine ilmpi_gen_allgatherv(incount, in, outcount, out, mpi_grp)
Every node has incount (may vary from node to node) items (in array in) to send to everybody else in ...
Definition: mpi_lib.F90:618
subroutine llmpi_gen_allgatherv(incount, in, outcount, out, mpi_grp)
Every node has incount (may vary from node to node) items (in array in) to send to everybody else in ...
Definition: mpi_lib.F90:779
subroutine llmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Definition: mpi_lib.F90:826
subroutine zlmpi_gen_allgatherv(incount, in, outcount, out, mpi_grp)
Every node has incount (may vary from node to node) items (in array in) to send to everybody else in ...
Definition: mpi_lib.F90:458
subroutine dlmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Definition: mpi_lib.F90:345
subroutine dlmpi_gen_allgatherv(incount, in, outcount, out, mpi_grp)
Every node has incount (may vary from node to node) items (in array in) to send to everybody else in ...
Definition: mpi_lib.F90:298
integer function, public lmpi_translate_rank(from_comm, to_comm, rank)
Returns the rank number of the node rank in from_comm for the to_comm communicator.
Definition: mpi_lib.F90:156
subroutine ilmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Definition: mpi_lib.F90:665
subroutine zlmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Definition: mpi_lib.F90:505
subroutine, public lmpi_sync_shared_memory_window(window, intranode_grp)
Definition: mpi_lib.F90:192
subroutine, public lmpi_destroy_shared_memory_window(window)
Definition: mpi_lib.F90:178
subroutine, public create_intranode_communicator(base_grp, intranode_grp, internode_grp)
Definition: mpi_lib.F90:204
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:341
integer, public mpi_err
used to store return values of mpi calls
Definition: mpi.F90:265