Octopus
mpi.F90
Go to the documentation of this file.
1!! Copyright (C) 2005-2006 Heiko Appel, Florian Lorenzen
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
21module mpi_oct_m
22#ifdef HAVE_MPI
23 use mpi_f08
24#else
26#endif
27 use blacs_oct_m
28 use loct_oct_m
30 use iso_c_binding
31 use, intrinsic :: iso_fortran_env
32#ifdef HAVE_OPENMP
33 use omp_lib
34#endif
35
36
37 implicit none
38
39 ! I do not make this module private on purpose, so that the symbols defined either in
40 ! module mpi, or in mpif.h are exported
41
43 type(MPI_Comm), parameter, public :: MPI_COMM_UNDEFINED = mpi_comm(-1)
44
46 integer, parameter, private :: ROOT_PROCESS = 0
47
49 type mpi_grp_t
50 ! Components are public by default
51 type(MPI_Comm) :: comm = mpi_comm_undefined
52 integer :: size = 0
53 integer :: rank = 0
54 contains
55 ! Wrapper functions for common MPI calls
56 ! We do not check the error code in any of those wrappers because the behavior of
57 ! an application is undefined after an MPI error according to the standard. The
58 ! default is to let the application crash in such a case with an error message
59 ! from the MPI runtime.
60 procedure :: barrier => mpi_grp_barrier
61 procedure :: dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
62 generic :: scatterv => dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
63 procedure :: dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
64 generic :: scatterv => dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
65 procedure :: dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
66 generic :: gatherv => dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
67 procedure :: dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
68 generic :: gather => dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
69 procedure :: dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
70 generic :: gatherv => dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
71 procedure :: dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
72 generic :: alltoallv => dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
73 procedure :: dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
74 generic :: alltoallv => dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
75 procedure :: dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
76 generic :: alltoallv => dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
77 procedure :: dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
78 generic :: alltoallv => dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
79 procedure :: dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
80 generic :: alltoall => dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
81 procedure :: dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
82 generic :: allgatherv => dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
83 procedure :: dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
84 generic :: allgatherv => dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
85 procedure :: dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
86 generic :: allgatherv => dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
87 procedure :: dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
88 generic :: allgatherv => dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
89 procedure :: dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
90 generic :: allgatherv => dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
91 procedure :: dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
92 generic :: bcast => dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
93 procedure :: dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
94 generic :: bcast => dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
95 procedure :: dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
96 generic :: bcast => dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
97 procedure :: dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
98 generic :: bcast => dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
99 procedure :: chmpi_grp_bcast_0, lompi_grp_bcast_0
100 generic :: bcast => chmpi_grp_bcast_0, lompi_grp_bcast_0
101 procedure :: dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
102 generic :: bcast => dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
103 procedure :: dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
104 generic :: allreduce => dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
105 procedure :: dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
106 generic :: allreduce => dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
107 procedure :: dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
108 generic :: allreduce => dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
109 procedure :: dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
110 generic :: allreduce => dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
111 procedure :: lompi_grp_allreduce_0
112 generic :: allreduce => lompi_grp_allreduce_0
113 procedure :: dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
114 procedure :: impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
115 procedure :: lompi_grp_allreduce_inplace_0
116 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
117 generic :: allreduce_inplace => impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
118 generic :: allreduce_inplace => lompi_grp_allreduce_inplace_0
119 procedure :: dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
120 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
121 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
122 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
123 procedure :: dmpi_grp_allreduce_inplace_2, zmpi_grp_allreduce_inplace_2, &
124 impi_grp_allreduce_inplace_2, lmpi_grp_allreduce_inplace_2
125 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_2, zmpi_grp_allreduce_inplace_2, &
126 impi_grp_allreduce_inplace_2, lmpi_grp_allreduce_inplace_2
127 procedure :: dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
128 generic :: allgather => dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
129 procedure :: dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
130 generic :: allgather => dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
131 procedure :: dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
132 generic :: recv => dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
133 procedure :: dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
134 generic :: recv => dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
135 procedure :: dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
136 generic :: recv => dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
137 procedure :: dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
138 generic :: recv => dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
139 procedure :: lompi_grp_recv_0
140 generic :: recv => lompi_grp_recv_0
145 procedure :: dmpi_grp_send_2, zmpi_grp_send_2, impi_grp_send_2, lmpi_grp_send_2
146 generic :: send => dmpi_grp_send_2, zmpi_grp_send_2, impi_grp_send_2, lmpi_grp_send_2
149 procedure :: lompi_grp_send_0
150 generic :: send => lompi_grp_send_0
172 generic :: wait => mpi_grp_wait, mpi_grp_waitall
173 procedure :: abort => mpi_grp_abort
174 procedure :: is_root => mpi_grp_is_root
175 end type mpi_grp_t
177 type(mpi_grp_t), public :: mpi_world
179 private :: not_in_openmp
183 abstract interface
186 end function
187 end interface
189#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
192 integer, parameter :: octopus_mpi_thread_level = mpi_thread_funneled
193 procedure(omp_region_func), pointer :: mpi_call_is_thread_safe => mpi_call_is_thread_funneled_safe
194#elif defined(HAVE_MPI)
196 integer, parameter :: octopus_mpi_thread_level = mpi_thread_single
198#else
201#endif
204contains
209 subroutine mpi_init_comm(comm)
210 type(mpi_comm), intent(out) :: comm
211#if defined(HAVE_MPI)
212#if defined(HAVE_OPENMP)
213 integer :: provided
215 call mpi_init_thread(octopus_mpi_thread_level, provided)
217#else
218 call mpi_init()
219#endif
220 comm = mpi_comm_world
221#else
222 comm = mpi_comm_undefined
223#endif
225 end subroutine mpi_init_comm
230 subroutine check_threading_support(comm)
231 type(mpi_comm), intent(in) :: comm
233#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
234 integer :: provided, ierr, rank
236 call mpi_query_thread(provided)
237 if (provided < octopus_mpi_thread_level) then
238 call mpi_comm_rank(comm, rank)
239 if (rank == 0) write(*, '(a)') 'MPI library threading support is less than required by Octopus'
240 call mpi_abort(comm, 1, ierr)
241 end if
242#else
243 return
244#endif
250 subroutine blacs_init()
251#if defined(HAVE_MPI)
252#ifdef HAVE_SCALAPACK
253 integer :: iam, nprocs
254 integer :: blacs_default_system_context
256 ! Determine my process number and the number of processes in machine
257 call blacs_pinfo(iam, nprocs)
259 ! If machine needs additional set up, do it now
260 if (nprocs < 1) then
261 call blacs_setup(iam, mpi_world%size)
262 end if
264 ! blacs_gridinit() or blacs_gridmap() must be called, else
265 ! blacs_exit() triggers an error with openmpi:
266 ! *** An error occurred in MPI_Type_free
267 ! *** MPI_ERR_TYPE: invalid datatype
268 call blacs_get(0, 0, blacs_default_system_context)
269 call blacs_gridinit(blacs_default_system_context, 'R', mpi_world%size, 1)
270 call blacs_gridexit(blacs_default_system_context)
271#endif
272#endif
273 end subroutine blacs_init
274
275
277 subroutine mpi_mod_end()
278
279#ifdef HAVE_SCALAPACK
280 if (mpi_world%comm /= mpi_comm_undefined) call blacs_exit(1)
281#endif
282
284
285#if defined(HAVE_MPI)
286 if (mpi_world%comm /= mpi_comm_undefined) call mpi_finalize()
287#endif
288
289 end subroutine mpi_mod_end
290
291
296 subroutine mpi_grp_init(grp, comm)
297 type(mpi_grp_t), intent(out) :: grp
298 type(mpi_comm), intent(in) :: comm
299
300 grp%comm = comm
301#if defined(HAVE_MPI)
302 if (grp%comm == mpi_comm_null) grp%comm = mpi_comm_undefined
303#endif
304
305 if (grp%comm == mpi_comm_undefined) then
306 grp%rank = 0
307 grp%size = 1
308#if defined(HAVE_MPI)
309 else
310 call mpi_comm_rank(grp%comm, grp%rank)
311
312 call mpi_comm_size(grp%comm, grp%size)
313#endif
314 end if
316 end subroutine mpi_grp_init
317
318
320 logical &
321#ifndef HAVE_OPENMP
322 pure &
323#endif
324 function not_in_openmp()
325
326#ifdef HAVE_OPENMP
327 not_in_openmp = .not. omp_in_parallel()
328#else
330#endif
331
332 end function not_in_openmp
333
334
337#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
338 logical function mpi_call_is_thread_funneled_safe()
339 mpi_call_is_thread_funneled_safe = &
340 not_in_openmp() .or. (omp_get_thread_num() == 0)
341 end function mpi_call_is_thread_funneled_safe
342#endif
343
344
345 subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
346 type(mpi_grp_t), intent(out) :: mpi_grp_out
347 type(mpi_grp_t), intent(in) :: mpi_grp_in
348
349 mpi_grp_out%comm = mpi_grp_in%comm
350 mpi_grp_out%size = mpi_grp_in%size
351 mpi_grp_out%rank = mpi_grp_in%rank
352 end subroutine mpi_grp_copy
353
354 ! ---------------------------------------------------------
355 subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
356 type(mpi_grp_t), intent(out) :: mpi_grp_out
357 type(mpi_grp_t), intent(in) :: mpi_grp_in
358
359#if defined(HAVE_MPI)
360 call mpi_comm_dup(mpi_grp_in%comm, mpi_grp_out%comm)
361 call mpi_comm_rank(mpi_grp_out%comm, mpi_grp_out%rank)
362 call mpi_comm_size(mpi_grp_out%comm, mpi_grp_out%size)
363#else
364 call mpi_grp_copy(mpi_grp_out, mpi_grp_in)
365#endif
366 end subroutine mpi_grp_duplicate
367
369 logical function mpi_grp_is_root(grp)
370 class(mpi_grp_t), intent(in) :: grp
371
372 mpi_grp_is_root = (grp%rank == root_process)
373 end function mpi_grp_is_root
374
375 ! ---------------------------------------------------------
376 subroutine mpi_grp_barrier(mpi_grp)
377 class(mpi_grp_t), intent(in) :: mpi_grp
378
379 if (mpi_grp%comm == mpi_comm_undefined) return
380#if defined(HAVE_MPI)
383 call mpi_debug_in(mpi_grp%comm, c_mpi_barrier)
384 call mpi_barrier(mpi_grp%comm)
385 call mpi_debug_out(mpi_grp%comm, c_mpi_barrier)
386#endif
387 end subroutine mpi_grp_barrier
388
389 ! ---------------------------------------------------------
390 subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
391 class(mpi_grp_t), intent(in) :: mpi_grp
392 character(len=*), intent(inout) :: buf
393 integer, intent(in) :: cnt
394 type(mpi_datatype), intent(in) :: sendtype
395 integer, intent(in) :: root
396
397#if defined(HAVE_MPI)
399
400 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
401 if (mpi_grp%comm /= mpi_comm_undefined) then
402 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
403 end if
404 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
405#endif
406 end subroutine chmpi_grp_bcast_0
407
408 ! ---------------------------------------------------------
409 subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
410 class(mpi_grp_t), intent(in) :: mpi_grp
411 logical, intent(inout) :: buf
412 integer, intent(in) :: cnt
413 type(mpi_datatype), intent(in) :: sendtype
414 integer, intent(in) :: root
415
416#if defined(HAVE_MPI)
418
419 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
420 if (mpi_grp%comm /= mpi_comm_undefined) then
421 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
422 end if
423 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
424#endif
425 end subroutine lompi_grp_bcast_0
426
427 ! ---------------------------------------------------------
428 ! copy routine for serial case
429 subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
430 use iso_c_binding
431 logical, target, intent(in) :: sendbuf
432 logical, target, intent(out) :: recvbuf
433 integer, intent(in) :: count
434 integer :: ii
435 logical, pointer :: send(:), recv(:)
436
437 call c_f_pointer(c_loc(sendbuf), send, [count])
438 call c_f_pointer(c_loc(recvbuf), recv, [count])
439 do ii = 1, count
440 recv(ii) = send(ii)
441 end do
442 end subroutine lompi_grp_copy_0
443
444 ! ---------------------------------------------------------
445 subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
446 class(mpi_grp_t), intent(in) :: mpi_grp
447 logical, intent(in) :: sendbuf
448 logical, intent(out) :: recvbuf
449 integer, intent(in) :: count
450 type(mpi_datatype), intent(in):: datatype
451 type(mpi_op), intent(in) :: op
452
453#if defined(HAVE_MPI)
455
456 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
457 if (mpi_grp%comm /= mpi_comm_undefined) then
458 call mpi_allreduce(sendbuf, recvbuf, count, datatype, op, &
459 mpi_grp%comm)
460 else
461 call lompi_grp_copy_0(sendbuf, recvbuf, count)
462 end if
463 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
464#else
465 call lompi_grp_copy_0(sendbuf, recvbuf, count)
466#endif
467 end subroutine lompi_grp_allreduce_0
468
469 ! ---------------------------------------------------------
470 subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
471 class(mpi_grp_t), intent(in) :: mpi_grp
472 logical, intent(inout) :: recvbuf
473 integer, intent(in) :: count
474 type(mpi_datatype), intent(in) :: datatype
475 type(mpi_op), intent(in) :: op
476
477#if defined(HAVE_MPI)
479
480 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
481 if (mpi_grp%comm /= mpi_comm_undefined) then
482 call mpi_allreduce(mpi_in_place, recvbuf, count, datatype, op, &
483 mpi_grp%comm)
484 end if
485 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
486#endif
488
489 ! ---------------------------------------------------------
490 subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
491 class(mpi_grp_t), intent(in) :: mpi_grp
492 logical, intent(out) :: recvbuf
493 integer, intent(in) :: recvcount
494 type(mpi_datatype),intent(in) :: recvtype
495 integer, intent(in) :: source
496 integer, optional, intent(in) :: tag
497
498 integer :: tag_
499
500 tag_ = 0
501 if (present(tag)) tag_ = tag
502 if (mpi_grp%comm == mpi_comm_undefined) return
503#if defined(HAVE_MPI)
505
506 call mpi_debug_in(mpi_grp%comm, c_mpi_recv)
507 call mpi_recv(recvbuf, recvcount, recvtype, source, tag_, mpi_grp%comm, mpi_status_ignore)
508 call mpi_debug_out(mpi_grp%comm, c_mpi_recv)
509#endif
510 end subroutine lompi_grp_recv_0
511
512 ! ---------------------------------------------------------
513 subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
514 class(mpi_grp_t), intent(in) :: mpi_grp
515 logical, intent(out) :: sendbuf
516 integer, intent(in) :: sendcount
517 type(mpi_datatype),intent(in) :: sendtype
518 integer, intent(in) :: dest
519 integer, optional, intent(in) :: tag
520
521 integer :: tag_
522
523 tag_ = 0
524 if (present(tag)) tag_ = tag
525 if (mpi_grp%comm == mpi_comm_undefined) return
526#if defined(HAVE_MPI)
528
529 call mpi_debug_in(mpi_grp%comm, c_mpi_send)
530 call mpi_send(sendbuf, sendcount, sendtype, dest, tag_, mpi_grp%comm)
531 call mpi_debug_out(mpi_grp%comm, c_mpi_send)
532#endif
533 end subroutine lompi_grp_send_0
534
535 ! ---------------------------------------------------------
536 subroutine mpi_grp_wait(mpi_grp, request)
537 class(mpi_grp_t), intent(in) :: mpi_grp
538 type(mpi_request), intent(inout) :: request
539
540 if (mpi_grp%comm == mpi_comm_undefined) return
541#if defined(HAVE_MPI)
543
544 call mpi_debug_in(mpi_grp%comm, c_mpi_wait)
545 call mpi_wait(request, mpi_status_ignore)
546 call mpi_debug_out(mpi_grp%comm, c_mpi_wait)
547#endif
548 end subroutine mpi_grp_wait
549
550 ! ---------------------------------------------------------
551 subroutine mpi_grp_waitall(mpi_grp, count, requests)
552 class(mpi_grp_t), intent(in) :: mpi_grp
553 integer, intent(in) :: count
554 type(mpi_request), intent(inout) :: requests(:)
555
556 if (mpi_grp%comm == mpi_comm_undefined) return
557#if defined(HAVE_MPI)
559
560 call mpi_debug_in(mpi_grp%comm, c_mpi_waitall)
561 call mpi_waitall(count, requests, mpi_statuses_ignore)
562 call mpi_debug_out(mpi_grp%comm, c_mpi_waitall)
563#endif
564 end subroutine mpi_grp_waitall
565
566 ! ---------------------------------------------------------
567 subroutine mpi_grp_abort(mpi_grp)
568 class(mpi_grp_t), intent(in) :: mpi_grp
569
570 if (mpi_grp%comm /= mpi_comm_undefined) then
571#if defined(HAVE_MPI)
573
574 ! Abort with an arbitrary error code
575 call mpi_abort(mpi_grp%comm, 999)
576#endif
577 end if
578
579 error stop 1
580
581 end subroutine mpi_grp_abort
583 ! ---------------------------------------------------------
585 real(real64) function mpi_get_wtime() result(now)
586#if defined(HAVE_MPI)
587 now = mpi_wtime()
588#else
589 now = loct_clock()
590#endif
591 end function mpi_get_wtime
592
593#include "undef.F90"
594#include "real.F90"
595#include "mpi_inc.F90"
596
597#include "undef.F90"
598#include "complex.F90"
599#include "mpi_inc.F90"
600
601#include "undef.F90"
602#include "integer.F90"
603#include "mpi_inc.F90"
604
605#include "undef.F90"
606#include "integer8.F90"
607#include "mpi_inc.F90"
608
609end module mpi_oct_m
610
611
612!! Local Variables:
613!! mode: f90
614!! coding: utf-8
615!! End:
Interface for function returned by mpi_call_is_thread_safe_factory
Definition: mpi.F90:279
This module contains interfaces for BLACS routines Interfaces are from http:
Definition: blacs.F90:27
System information (time, memory, sysname)
Definition: loct.F90:117
integer, parameter, public c_mpi_allreduce
Definition: mpi_debug.F90:139
integer, parameter, public c_mpi_recv
Definition: mpi_debug.F90:139
subroutine, public mpi_debug_in(comm, index)
Definition: mpi_debug.F90:233
integer, parameter, public c_mpi_send
Definition: mpi_debug.F90:139
integer, parameter, public c_mpi_waitall
Definition: mpi_debug.F90:139
integer, parameter, public c_mpi_bcast
Definition: mpi_debug.F90:139
integer, parameter, public c_mpi_barrier
Definition: mpi_debug.F90:139
integer, parameter, public c_mpi_wait
Definition: mpi_debug.F90:139
subroutine, public mpi_debug_out(comm, index)
Definition: mpi_debug.F90:257
subroutine mpi_grp_abort(mpi_grp)
Definition: mpi.F90:565
subroutine impi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3252
subroutine zmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2371
subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:393
subroutine impi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3228
subroutine lmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4112
subroutine lmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4350
subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
Definition: mpi.F90:449
subroutine zmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2226
subroutine blacs_init()
Initialize BLACS to enable use of SCALAPACK.
Definition: mpi.F90:316
subroutine impi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3180
real(real64) function, public mpi_get_wtime()
. Returns an elapsed time on the calling processor.
Definition: mpi.F90:583
subroutine dmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1346
subroutine zmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2395
subroutine dmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1466
subroutine zmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2323
subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:438
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:407
subroutine impi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3276
subroutine zmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2275
procedure(omp_region_func), pointer mpi_call_is_thread_safe
Single-threaded without MPI.
Definition: mpi.F90:285
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
MPI_THREAD_FUNNELED allows for calls to MPI from an OMP region if the thread is the team master.
Definition: mpi.F90:383
subroutine zmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2443
subroutine impi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3396
subroutine impi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3372
subroutine impi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3111
subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
Definition: mpi.F90:478
subroutine impi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3323
subroutine zmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2299
subroutine dmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1394
subroutine zmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2134
subroutine dmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1298
subroutine lmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4181
subroutine impi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3203
subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:488
subroutine check_threading_support(comm)
Check that the threading support of the MPI library is consistent with the requested support from Oct...
Definition: mpi.F90:306
subroutine dmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1157
subroutine mpi_grp_wait(mpi_grp, request)
Definition: mpi.F90:534
subroutine lmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4230
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:272
subroutine impi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3348
subroutine mpi_mod_end()
Finalize MPI, and conditionally BLACS.
Definition: mpi.F90:322
subroutine dmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1180
logical pure function, private not_in_openmp()
Not in an OpenMP region.
Definition: mpi.F90:369
subroutine zmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2157
subroutine lmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4374
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:341
subroutine dmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1274
subroutine impi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3300
subroutine impi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3420
subroutine dmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1418
subroutine dmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1442
subroutine zmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2346
subroutine lmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4278
subroutine mpi_grp_barrier(mpi_grp)
Definition: mpi.F90:414
subroutine zmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2251
subroutine mpi_init_comm(comm)
Wrapper for MPI_COMM_WORLD initialisation.
Definition: mpi.F90:295
subroutine dmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1322
subroutine lmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4301
subroutine dmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1249
subroutine lmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4089
subroutine lmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4326
subroutine dmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1369
subroutine dmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1226
subroutine zmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2419
subroutine lmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4158
subroutine zmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2203
subroutine mpi_grp_waitall(mpi_grp, count, requests)
Definition: mpi.F90:549
subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
Definition: mpi.F90:465
subroutine lmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4206
subroutine impi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3134
subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:511
subroutine lmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4398
subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:428
subroutine lmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4254
type(mpi_comm), parameter mpi_comm_null
type(mpi_op), parameter mpi_in_place
This is defined even when running serial.
Definition: mpi.F90:144
int true(void)