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 ! Free MPI group resources
82 call mpi_group_free(from_group)
83 call mpi_group_free(to_group)
84
85 pop_sub(lmpi_translate_rank)
86 end function lmpi_translate_rank
87
88 ! destroy a shared memory segment as an MPI window
89 subroutine lmpi_destroy_shared_memory_window(window)
90 type(MPI_Win), intent(inout) :: window
91
93
94 ! end access epoch
95 call mpi_win_unlock_all(window, mpi_err)
96 ! destroy window
97 call mpi_win_free(window, mpi_err)
98
101
102 ! synchronize a shared memory segment
103 subroutine lmpi_sync_shared_memory_window(window, intranode_grp)
104 type(MPI_Win), intent(in) :: window
105 type(mpi_grp_t), intent(in) :: intranode_grp
106
108
109 call mpi_win_sync(window, mpi_err)
110 call intranode_grp%barrier()
111
113 end subroutine lmpi_sync_shared_memory_window
114
115 subroutine create_intranode_communicator(base_grp, intranode_grp, internode_grp)
116 type(mpi_grp_t), intent(in) :: base_grp
117 type(mpi_grp_t), intent(out) :: intranode_grp
118 type(mpi_grp_t), intent(out) :: internode_grp
119 type(MPI_Comm) :: comm
120
122
123 ! create communicator for intranode communication
124 ! this is used for MPI-3 shared memory windows
125 call mpi_comm_split_type(base_grp%comm, mpi_comm_type_shared, base_grp%rank, mpi_info_null, comm, mpi_err)
126 call mpi_grp_init(intranode_grp, comm)
127
128 ! create communicator for internode communication
129 ! we have one communicator for each local rank
130 call mpi_comm_split(base_grp%comm, intranode_grp%rank, base_grp%rank, comm, mpi_err)
131 call mpi_grp_init(internode_grp, comm)
132
134 end subroutine create_intranode_communicator
135
136#include "undef.F90"
137#include "real.F90"
138#include "mpi_lib_inc.F90"
140#include "undef.F90"
141#include "complex.F90"
142#include "mpi_lib_inc.F90"
143
144#include "undef.F90"
145#include "integer.F90"
146#include "mpi_lib_inc.F90"
147
148#include "undef.F90"
149#include "integer8.F90"
150#include "mpi_lib_inc.F90"
151#endif
152end module mpi_lib_oct_m
153
154
155!! Local Variables:
156!! mode: f90
157!! coding: utf-8
158!! 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:608
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:762
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:801
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:455
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:341
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:302
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:647
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:494
subroutine, public lmpi_sync_shared_memory_window(window, intranode_grp)
Definition: mpi_lib.F90:197
subroutine, public lmpi_destroy_shared_memory_window(window)
Definition: mpi_lib.F90:183
subroutine, public create_intranode_communicator(base_grp, intranode_grp, internode_grp)
Definition: mpi_lib.F90:209
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