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#else
197#endif
200contains
205 subroutine mpi_init_comm(comm)
206 type(mpi_comm), intent(out) :: comm
207#if defined(HAVE_MPI)
208#if defined(HAVE_OPENMP)
209 integer :: provided
211 call mpi_init_thread(octopus_mpi_thread_level, provided)
213#else
214 call mpi_init()
215#endif
216 comm = mpi_comm_world
217#else
218 comm = mpi_comm_undefined
219#endif
221 end subroutine mpi_init_comm
226 subroutine check_threading_support(comm)
227 type(mpi_comm), intent(in) :: comm
229#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
230 integer :: provided, ierr, rank
232 call mpi_query_thread(provided)
233 if (provided < octopus_mpi_thread_level) then
234 call mpi_comm_rank(comm, rank)
235 if (rank == 0) write(*, '(a)') 'MPI library threading support is less than required by Octopus'
236 call mpi_abort(comm, 1, ierr)
237 end if
238#else
239 return
240#endif
246 subroutine blacs_init()
247#if defined(HAVE_MPI)
248#ifdef HAVE_SCALAPACK
249 integer :: iam, nprocs
250 integer :: blacs_default_system_context
252 ! Determine my process number and the number of processes in machine
253 call blacs_pinfo(iam, nprocs)
255 ! If machine needs additional set up, do it now
256 if (nprocs < 1) then
257 call blacs_setup(iam, mpi_world%size)
258 end if
260 ! blacs_gridinit() or blacs_gridmap() must be called, else
261 ! blacs_exit() triggers an error with openmpi:
262 ! *** An error occurred in MPI_Type_free
263 ! *** MPI_ERR_TYPE: invalid datatype
264 call blacs_get(0, 0, blacs_default_system_context)
265 call blacs_gridinit(blacs_default_system_context, 'R', mpi_world%size, 1)
266 call blacs_gridexit(blacs_default_system_context)
267#endif
268#endif
269 end subroutine blacs_init
270
271
273 subroutine mpi_mod_end()
274
275#ifdef HAVE_SCALAPACK
276 if (mpi_world%comm /= mpi_comm_undefined) call blacs_exit(1)
277#endif
278
280
281#if defined(HAVE_MPI)
282 if (mpi_world%comm /= mpi_comm_undefined) call mpi_finalize()
283#endif
284
285 end subroutine mpi_mod_end
286
287
292 subroutine mpi_grp_init(grp, comm)
293 type(mpi_grp_t), intent(out) :: grp
294 type(mpi_comm), intent(in) :: comm
295
296 grp%comm = comm
297#if defined(HAVE_MPI)
298 if (grp%comm == mpi_comm_null) grp%comm = mpi_comm_undefined
299#endif
301 if (grp%comm == mpi_comm_undefined) then
302 grp%rank = 0
303 grp%size = 1
304#if defined(HAVE_MPI)
305 else
306 call mpi_comm_rank(grp%comm, grp%rank)
307
308 call mpi_comm_size(grp%comm, grp%size)
309#endif
310 end if
312 end subroutine mpi_grp_init
313
314
316 logical &
317#ifndef HAVE_OPENMP
318 pure &
319#endif
320 function not_in_openmp()
322#ifdef HAVE_OPENMP
323 not_in_openmp = .not. omp_in_parallel()
324#else
326#endif
328 end function not_in_openmp
329
330
333#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
334 logical function mpi_call_is_thread_funneled_safe()
335 mpi_call_is_thread_funneled_safe = &
336 not_in_openmp() .or. (omp_get_thread_num() == 0)
337 end function mpi_call_is_thread_funneled_safe
338#endif
339
340
341 subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
342 type(mpi_grp_t), intent(out) :: mpi_grp_out
343 type(mpi_grp_t), intent(in) :: mpi_grp_in
344
345 mpi_grp_out%comm = mpi_grp_in%comm
346 mpi_grp_out%size = mpi_grp_in%size
347 mpi_grp_out%rank = mpi_grp_in%rank
348 end subroutine mpi_grp_copy
349
350 ! ---------------------------------------------------------
351 subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
352 type(mpi_grp_t), intent(out) :: mpi_grp_out
353 type(mpi_grp_t), intent(in) :: mpi_grp_in
354
355#if defined(HAVE_MPI)
356 call mpi_comm_dup(mpi_grp_in%comm, mpi_grp_out%comm)
357 call mpi_comm_rank(mpi_grp_out%comm, mpi_grp_out%rank)
358 call mpi_comm_size(mpi_grp_out%comm, mpi_grp_out%size)
359#else
360 call mpi_grp_copy(mpi_grp_out, mpi_grp_in)
361#endif
362 end subroutine mpi_grp_duplicate
363
365 logical function mpi_grp_is_root(grp)
366 class(mpi_grp_t), intent(in) :: grp
367
368 mpi_grp_is_root = (grp%rank == root_process)
369 end function mpi_grp_is_root
371 ! ---------------------------------------------------------
372 subroutine mpi_grp_barrier(mpi_grp)
373 class(mpi_grp_t), intent(in) :: mpi_grp
374
375 if (mpi_grp%comm == mpi_comm_undefined) return
376#if defined(HAVE_MPI)
378
379 call mpi_debug_in(mpi_grp%comm, c_mpi_barrier)
380 call mpi_barrier(mpi_grp%comm)
381 call mpi_debug_out(mpi_grp%comm, c_mpi_barrier)
382#endif
383 end subroutine mpi_grp_barrier
384
385 ! ---------------------------------------------------------
386 subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
387 class(mpi_grp_t), intent(in) :: mpi_grp
388 character(len=*), intent(inout) :: buf
389 integer, intent(in) :: cnt
390 type(mpi_datatype), intent(in) :: sendtype
391 integer, intent(in) :: root
392
393#if defined(HAVE_MPI)
395
396 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
397 if (mpi_grp%comm /= mpi_comm_undefined) then
398 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
399 end if
400 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
401#endif
402 end subroutine chmpi_grp_bcast_0
403
404 ! ---------------------------------------------------------
405 subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
406 class(mpi_grp_t), intent(in) :: mpi_grp
407 logical, intent(inout) :: buf
408 integer, intent(in) :: cnt
409 type(mpi_datatype), intent(in) :: sendtype
410 integer, intent(in) :: root
411
412#if defined(HAVE_MPI)
414
415 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
416 if (mpi_grp%comm /= mpi_comm_undefined) then
417 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
418 end if
419 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
420#endif
421 end subroutine lompi_grp_bcast_0
422
423 ! ---------------------------------------------------------
424 ! copy routine for serial case
425 subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
426 use iso_c_binding
427 logical, target, intent(in) :: sendbuf
428 logical, target, intent(out) :: recvbuf
429 integer, intent(in) :: count
430 integer :: ii
431 logical, pointer :: send(:), recv(:)
432
433 call c_f_pointer(c_loc(sendbuf), send, [count])
434 call c_f_pointer(c_loc(recvbuf), recv, [count])
435 do ii = 1, count
436 recv(ii) = send(ii)
437 end do
438 end subroutine lompi_grp_copy_0
439
440 ! ---------------------------------------------------------
441 subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
442 class(mpi_grp_t), intent(in) :: mpi_grp
443 logical, intent(in) :: sendbuf
444 logical, intent(out) :: recvbuf
445 integer, intent(in) :: count
446 type(mpi_datatype), intent(in):: datatype
447 type(mpi_op), intent(in) :: op
448
449#if defined(HAVE_MPI)
451
452 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
453 if (mpi_grp%comm /= mpi_comm_undefined) then
454 call mpi_allreduce(sendbuf, recvbuf, count, datatype, op, &
455 mpi_grp%comm)
456 else
457 call lompi_grp_copy_0(sendbuf, recvbuf, count)
458 end if
459 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
460#else
461 call lompi_grp_copy_0(sendbuf, recvbuf, count)
462#endif
463 end subroutine lompi_grp_allreduce_0
464
465 ! ---------------------------------------------------------
466 subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
467 class(mpi_grp_t), intent(in) :: mpi_grp
468 logical, intent(inout) :: recvbuf
469 integer, intent(in) :: count
470 type(mpi_datatype), intent(in) :: datatype
471 type(mpi_op), intent(in) :: op
472
473#if defined(HAVE_MPI)
475
476 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
477 if (mpi_grp%comm /= mpi_comm_undefined) then
478 call mpi_allreduce(mpi_in_place, recvbuf, count, datatype, op, &
479 mpi_grp%comm)
480 end if
481 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
482#endif
484
485 ! ---------------------------------------------------------
486 subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
487 class(mpi_grp_t), intent(in) :: mpi_grp
488 logical, intent(out) :: recvbuf
489 integer, intent(in) :: recvcount
490 type(mpi_datatype),intent(in) :: recvtype
491 integer, intent(in) :: source
492 integer, optional, intent(in) :: tag
494 integer :: tag_
495
496 tag_ = 0
497 if (present(tag)) tag_ = tag
498 if (mpi_grp%comm == mpi_comm_undefined) return
499#if defined(HAVE_MPI)
501
502 call mpi_debug_in(mpi_grp%comm, c_mpi_recv)
503 call mpi_recv(recvbuf, recvcount, recvtype, source, tag_, mpi_grp%comm, mpi_status_ignore)
504 call mpi_debug_out(mpi_grp%comm, c_mpi_recv)
505#endif
506 end subroutine lompi_grp_recv_0
507
508 ! ---------------------------------------------------------
509 subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
510 class(mpi_grp_t), intent(in) :: mpi_grp
511 logical, intent(out) :: sendbuf
512 integer, intent(in) :: sendcount
513 type(mpi_datatype),intent(in) :: sendtype
514 integer, intent(in) :: dest
515 integer, optional, intent(in) :: tag
517 integer :: tag_
518
519 tag_ = 0
520 if (present(tag)) tag_ = tag
521 if (mpi_grp%comm == mpi_comm_undefined) return
522#if defined(HAVE_MPI)
524
525 call mpi_debug_in(mpi_grp%comm, c_mpi_send)
526 call mpi_send(sendbuf, sendcount, sendtype, dest, tag_, mpi_grp%comm)
527 call mpi_debug_out(mpi_grp%comm, c_mpi_send)
528#endif
529 end subroutine lompi_grp_send_0
530
531 ! ---------------------------------------------------------
532 subroutine mpi_grp_wait(mpi_grp, request)
533 class(mpi_grp_t), intent(in) :: mpi_grp
534 type(mpi_request), intent(inout) :: request
535
536 if (mpi_grp%comm == mpi_comm_undefined) return
537#if defined(HAVE_MPI)
540 call mpi_debug_in(mpi_grp%comm, c_mpi_wait)
541 call mpi_wait(request, mpi_status_ignore)
542 call mpi_debug_out(mpi_grp%comm, c_mpi_wait)
543#endif
544 end subroutine mpi_grp_wait
545
546 ! ---------------------------------------------------------
547 subroutine mpi_grp_waitall(mpi_grp, count, requests)
548 class(mpi_grp_t), intent(in) :: mpi_grp
549 integer, intent(in) :: count
550 type(mpi_request), intent(inout) :: requests(:)
551
552 if (mpi_grp%comm == mpi_comm_undefined) return
553#if defined(HAVE_MPI)
555
556 call mpi_debug_in(mpi_grp%comm, c_mpi_waitall)
557 call mpi_waitall(count, requests, mpi_statuses_ignore)
558 call mpi_debug_out(mpi_grp%comm, c_mpi_waitall)
559#endif
560 end subroutine mpi_grp_waitall
561
562 ! ---------------------------------------------------------
563 subroutine mpi_grp_abort(mpi_grp)
564 class(mpi_grp_t), intent(in) :: mpi_grp
565
566 if (mpi_grp%comm /= mpi_comm_undefined) then
567#if defined(HAVE_MPI)
569
570 ! Abort with an arbitrary error code
571 call mpi_abort(mpi_grp%comm, 999)
572#endif
573 end if
574
575 error stop 1
576
577 end subroutine mpi_grp_abort
578
579 ! ---------------------------------------------------------
581 real(real64) function mpi_get_Wtime() result(now)
582#if defined(HAVE_MPI)
583 now = mpi_wtime()
584#else
585 now = loct_clock()
586#endif
587 end function mpi_get_wtime
589#include "undef.F90"
590#include "real.F90"
591#include "mpi_inc.F90"
592
593#include "undef.F90"
594#include "complex.F90"
595#include "mpi_inc.F90"
596
597#include "undef.F90"
598#include "integer.F90"
599#include "mpi_inc.F90"
600
601#include "undef.F90"
602#include "integer8.F90"
603#include "mpi_inc.F90"
604
605end module mpi_oct_m
606
607
608!! Local Variables:
609!! mode: f90
610!! coding: utf-8
611!! 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:571
subroutine impi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3258
subroutine zmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2377
subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:399
subroutine impi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3234
subroutine lmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4118
subroutine lmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4356
subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
Definition: mpi.F90:455
subroutine zmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2232
subroutine blacs_init()
Initialize BLACS to enable use of SCALAPACK.
Definition: mpi.F90:322
subroutine impi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3186
real(real64) function, public mpi_get_wtime()
. Returns an elapsed time on the calling processor.
Definition: mpi.F90:589
subroutine dmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1352
subroutine zmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2401
subroutine dmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1472
subroutine zmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2329
subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:444
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:413
subroutine impi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3282
subroutine zmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2281
procedure(omp_region_func), pointer mpi_call_is_thread_safe
Single-threaded.
Definition: mpi.F90:291
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:389
subroutine zmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2449
subroutine impi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3402
subroutine impi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3378
subroutine impi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3117
subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
Definition: mpi.F90:484
subroutine impi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3329
subroutine zmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2305
subroutine dmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1400
subroutine zmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2140
subroutine dmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1304
subroutine lmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4187
subroutine impi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3209
subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:494
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:312
subroutine dmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1163
subroutine mpi_grp_wait(mpi_grp, request)
Definition: mpi.F90:540
subroutine lmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4236
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:3354
subroutine mpi_mod_end()
Finalize MPI, and conditionally BLACS.
Definition: mpi.F90:328
subroutine dmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1186
logical pure function, private not_in_openmp()
Not in an OpenMP region.
Definition: mpi.F90:375
subroutine zmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2163
subroutine lmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4380
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:347
subroutine dmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1280
subroutine impi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3306
subroutine impi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3426
subroutine dmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1424
subroutine dmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1448
subroutine zmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2352
subroutine lmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4284
subroutine mpi_grp_barrier(mpi_grp)
Definition: mpi.F90:420
subroutine zmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2257
subroutine mpi_init_comm(comm)
Wrapper for MPI_COMM_WORLD initialisation.
Definition: mpi.F90:301
subroutine dmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1328
subroutine lmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4307
subroutine dmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1255
subroutine lmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4095
subroutine lmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4332
subroutine dmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1375
subroutine dmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1232
subroutine zmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2425
subroutine lmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4164
subroutine zmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2209
subroutine mpi_grp_waitall(mpi_grp, count, requests)
Definition: mpi.F90:555
subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
Definition: mpi.F90:471
subroutine lmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4212
subroutine impi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3140
subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:517
subroutine lmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4404
subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:434
subroutine lmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4260
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)