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
27 use mpi_oct_m
30
31 implicit none
32
33 private
34
35#if !defined(HAVE_MPI)
36 integer, public :: mpi_lib_dummy
37#else
38 public :: &
45
50
51 interface lmpi_gen_allgatherv
54 end interface lmpi_gen_allgatherv
55
56#endif
57
58contains
59#if defined(HAVE_MPI)
60 ! ---------------------------------------------------------
63 integer function lmpi_translate_rank(from_comm, to_comm, rank)
64 type(MPI_Comm), intent(in) :: from_comm
65 type(MPI_Comm), intent(in) :: to_comm
66 integer, intent(in) :: rank
67
68 type(MPI_Group) :: from_group, to_group
69 integer :: from_rank(1), to_rank(1)
70
71 push_sub(lmpi_translate_rank)
72
73 call mpi_comm_group(from_comm, from_group, mpi_err)
74 call mpi_comm_group(to_comm, to_group, mpi_err)
75
76 from_rank(1) = rank
77 call mpi_group_translate_ranks(from_group, 1, from_rank, to_group, to_rank, mpi_err)
78
79 lmpi_translate_rank = to_rank(1)
80
81 pop_sub(lmpi_translate_rank)
82 end function lmpi_translate_rank
83
84 ! destroy a shared memory segment as an MPI window
85 subroutine lmpi_destroy_shared_memory_window(window)
86 type(MPI_Win), intent(inout) :: window
87
89
90 ! end access epoch
91 call mpi_win_unlock_all(window, mpi_err)
92 ! destroy window
93 call mpi_win_free(window, mpi_err)
94
97
98 ! synchronize a shared memory segment
99 subroutine lmpi_sync_shared_memory_window(window, intranode_grp)
100 type(MPI_Win), intent(in) :: window
101 type(mpi_grp_t), intent(in) :: intranode_grp
102
104
105 call mpi_win_sync(window, mpi_err)
106 call intranode_grp%barrier()
107
109 end subroutine lmpi_sync_shared_memory_window
110
111 subroutine create_intranode_communicator(base_grp, intranode_grp, internode_grp)
112 type(mpi_grp_t), intent(in) :: base_grp
113 type(mpi_grp_t), intent(out) :: intranode_grp
114 type(mpi_grp_t), intent(out) :: internode_grp
115 type(MPI_Comm) :: comm
116
118
119 ! create communicator for intranode communication
120 ! this is used for MPI-3 shared memory windows
121 call mpi_comm_split_type(base_grp%comm, mpi_comm_type_shared, base_grp%rank, mpi_info_null, comm, mpi_err)
122 call mpi_grp_init(intranode_grp, comm)
123
124 ! create communicator for internode communication
125 ! we have one communicator for each local rank
126 call mpi_comm_split(base_grp%comm, intranode_grp%rank, base_grp%rank, comm, mpi_err)
127 call mpi_grp_init(internode_grp, comm)
128
130 end subroutine create_intranode_communicator
131
132#include "undef.F90"
133#include "real.F90"
134#include "mpi_lib_inc.F90"
135
136#include "undef.F90"
137#include "complex.F90"
138#include "mpi_lib_inc.F90"
140#include "undef.F90"
141#include "integer.F90"
142#include "mpi_lib_inc.F90"
143
144#include "undef.F90"
145#include "integer8.F90"
146#include "mpi_lib_inc.F90"
147#endif
148end module mpi_lib_oct_m
149
150
151!! Local Variables:
152!! mode: f90
153!! coding: utf-8
154!! 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:598
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:749
subroutine llmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Create a shared memory segment as an MPI window.
Definition: mpi_lib.F90:787
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:448
subroutine dlmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Create a shared memory segment as an MPI window.
Definition: mpi_lib.F90:336
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:157
subroutine ilmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Create a shared memory segment as an MPI window.
Definition: mpi_lib.F90:636
subroutine zlmpi_create_shared_memory_window(number_of_elements, intranode_grp, window, array)
Create a shared memory segment as an MPI window.
Definition: mpi_lib.F90:486
subroutine, public lmpi_sync_shared_memory_window(window, intranode_grp)
Definition: mpi_lib.F90:193
subroutine, public lmpi_destroy_shared_memory_window(window)
Definition: mpi_lib.F90:179
subroutine, public create_intranode_communicator(base_grp, intranode_grp, internode_grp)
Definition: mpi_lib.F90:205
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:346
integer, public mpi_err
used to store return values of mpi calls
Definition: mpi.F90:269