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_allgatherv_inplace, zmpi_grp_allgatherv_inplace, &
92 impi_grp_allgatherv_inplace, lmpi_grp_allgatherv_inplace
93 generic :: allgatherv_inplace => dmpi_grp_allgatherv_inplace, zmpi_grp_allgatherv_inplace, &
94 impi_grp_allgatherv_inplace, lmpi_grp_allgatherv_inplace
95 procedure :: dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
96 generic :: bcast => dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
97 procedure :: dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
98 generic :: bcast => dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
99 procedure :: dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
100 generic :: bcast => dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
101 procedure :: dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
102 generic :: bcast => dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
103 procedure :: chmpi_grp_bcast_0, lompi_grp_bcast_0
104 generic :: bcast => chmpi_grp_bcast_0, lompi_grp_bcast_0
105 procedure :: dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
106 generic :: bcast => dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
107 procedure :: dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
108 generic :: allreduce => dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
109 procedure :: dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
110 generic :: allreduce => dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
111 procedure :: dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
112 generic :: allreduce => dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
113 procedure :: dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
114 generic :: allreduce => dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
115 procedure :: lompi_grp_allreduce_0
116 generic :: allreduce => lompi_grp_allreduce_0
117 procedure :: dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
118 procedure :: impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
119 procedure :: lompi_grp_allreduce_inplace_0
120 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
121 generic :: allreduce_inplace => impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
122 generic :: allreduce_inplace => lompi_grp_allreduce_inplace_0
123 procedure :: dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
124 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
125 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
126 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
127 procedure :: dmpi_grp_allreduce_inplace_2, zmpi_grp_allreduce_inplace_2, &
128 impi_grp_allreduce_inplace_2, lmpi_grp_allreduce_inplace_2
129 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_2, zmpi_grp_allreduce_inplace_2, &
130 impi_grp_allreduce_inplace_2, lmpi_grp_allreduce_inplace_2
131 procedure :: dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
132 generic :: allgather => dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
133 procedure :: dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
134 generic :: allgather => dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
135 procedure :: dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
136 generic :: recv => dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
137 procedure :: dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
138 generic :: recv => dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
143 procedure :: lompi_grp_recv_0
144 generic :: recv => lompi_grp_recv_0
145 procedure :: dmpi_grp_send, zmpi_grp_send, impi_grp_send, lmpi_grp_send
146 generic :: send => dmpi_grp_send, zmpi_grp_send, impi_grp_send, lmpi_grp_send
153 procedure :: lompi_grp_send_0
154 generic :: send => lompi_grp_send_0
176 generic :: wait => mpi_grp_wait, mpi_grp_waitall
177 procedure :: abort => mpi_grp_abort
178 procedure :: is_root => mpi_grp_is_root
179 end type mpi_grp_t
181 type(mpi_grp_t), public :: mpi_world
183 private :: not_in_openmp
187 abstract interface
189 logical :: omp_region_func
190 end function
191 end interface
193#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
196 integer, parameter :: octopus_mpi_thread_level = mpi_thread_funneled
197 procedure(omp_region_func), pointer :: mpi_call_is_thread_safe => mpi_call_is_thread_funneled_safe
198#elif defined(HAVE_MPI)
200 integer, parameter :: octopus_mpi_thread_level = mpi_thread_single
202#else
205#endif
208contains
213 subroutine mpi_init_comm(comm)
214 type(mpi_comm), intent(out) :: comm
215#if defined(HAVE_MPI)
216#if defined(HAVE_OPENMP)
217 integer :: provided
219 call mpi_init_thread(octopus_mpi_thread_level, provided)
221#else
222 call mpi_init()
223#endif
224 comm = mpi_comm_world
225#else
226 comm = mpi_comm_undefined
227#endif
229 end subroutine mpi_init_comm
234 subroutine check_threading_support(comm)
235 type(mpi_comm), intent(in) :: comm
237#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
238 integer :: provided, ierr, rank
240 call mpi_query_thread(provided)
241 if (provided < octopus_mpi_thread_level) then
242 call mpi_comm_rank(comm, rank)
243 if (rank == 0) write(*, '(a)') 'MPI library threading support is less than required by Octopus'
244 call mpi_abort(comm, 1, ierr)
245 end if
246#else
247 return
248#endif
254 subroutine blacs_init()
255#if defined(HAVE_MPI)
256#ifdef HAVE_SCALAPACK
257 integer :: iam, nprocs
258 integer :: blacs_default_system_context
260 ! Determine my process number and the number of processes in machine
261 call blacs_pinfo(iam, nprocs)
263 ! If machine needs additional set up, do it now
264 if (nprocs < 1) then
265 call blacs_setup(iam, mpi_world%size)
266 end if
268 ! blacs_gridinit() or blacs_gridmap() must be called, else
269 ! blacs_exit() triggers an error with openmpi:
270 ! *** An error occurred in MPI_Type_free
271 ! *** MPI_ERR_TYPE: invalid datatype
272 call blacs_get(0, 0, blacs_default_system_context)
273 call blacs_gridinit(blacs_default_system_context, 'R', mpi_world%size, 1)
274 call blacs_gridexit(blacs_default_system_context)
275#endif
276#endif
277 end subroutine blacs_init
278
279
281 subroutine mpi_mod_end()
282
283#ifdef HAVE_SCALAPACK
284 if (mpi_world%comm /= mpi_comm_undefined) call blacs_exit(1)
285#endif
286
288
289#if defined(HAVE_MPI)
290 if (mpi_world%comm /= mpi_comm_undefined) call mpi_finalize()
291#endif
292
293 end subroutine mpi_mod_end
294
295
300 subroutine mpi_grp_init(grp, comm)
301 type(mpi_grp_t), intent(out) :: grp
302 type(mpi_comm), intent(in) :: comm
303
304 grp%comm = comm
305#if defined(HAVE_MPI)
306 if (grp%comm == mpi_comm_null) grp%comm = mpi_comm_undefined
307#endif
308
309 if (grp%comm == mpi_comm_undefined) then
310 grp%rank = 0
311 grp%size = 1
312#if defined(HAVE_MPI)
313 else
314 call mpi_comm_rank(grp%comm, grp%rank)
315
316 call mpi_comm_size(grp%comm, grp%size)
317#endif
318 end if
320 end subroutine mpi_grp_init
321
322
324 logical &
325#ifndef HAVE_OPENMP
326 pure &
327#endif
328 function not_in_openmp()
329
330#ifdef HAVE_OPENMP
331 not_in_openmp = .not. omp_in_parallel()
332#else
334#endif
335
336 end function not_in_openmp
337
338
341#if defined(HAVE_MPI) && defined(HAVE_OPENMP)
342 logical function mpi_call_is_thread_funneled_safe()
343 mpi_call_is_thread_funneled_safe = &
344 not_in_openmp() .or. (omp_get_thread_num() == 0)
345 end function mpi_call_is_thread_funneled_safe
346#endif
347
348
349 subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
350 type(mpi_grp_t), intent(out) :: mpi_grp_out
351 type(mpi_grp_t), intent(in) :: mpi_grp_in
352
353 mpi_grp_out%comm = mpi_grp_in%comm
354 mpi_grp_out%size = mpi_grp_in%size
355 mpi_grp_out%rank = mpi_grp_in%rank
356 end subroutine mpi_grp_copy
357
358 ! ---------------------------------------------------------
359 subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
360 type(mpi_grp_t), intent(out) :: mpi_grp_out
361 type(mpi_grp_t), intent(in) :: mpi_grp_in
362
363#if defined(HAVE_MPI)
364 call mpi_comm_dup(mpi_grp_in%comm, mpi_grp_out%comm)
365 call mpi_comm_rank(mpi_grp_out%comm, mpi_grp_out%rank)
366 call mpi_comm_size(mpi_grp_out%comm, mpi_grp_out%size)
367#else
368 call mpi_grp_copy(mpi_grp_out, mpi_grp_in)
369#endif
370 end subroutine mpi_grp_duplicate
371
373 logical function mpi_grp_is_root(grp)
374 class(mpi_grp_t), intent(in) :: grp
375
376 mpi_grp_is_root = (grp%rank == root_process)
377 end function mpi_grp_is_root
378
379 ! ---------------------------------------------------------
380 subroutine mpi_grp_barrier(mpi_grp)
381 class(mpi_grp_t), intent(in) :: mpi_grp
382
383 if (mpi_grp%comm == mpi_comm_undefined) return
384#if defined(HAVE_MPI)
387 call mpi_debug_in(mpi_grp%comm, c_mpi_barrier)
388 call mpi_barrier(mpi_grp%comm)
389 call mpi_debug_out(mpi_grp%comm, c_mpi_barrier)
390#endif
391 end subroutine mpi_grp_barrier
392
393 ! ---------------------------------------------------------
394 subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
395 class(mpi_grp_t), intent(in) :: mpi_grp
396 character(len=*), intent(inout) :: buf
397 integer, intent(in) :: cnt
398 type(mpi_datatype), intent(in) :: sendtype
399 integer, intent(in) :: root
400
401#if defined(HAVE_MPI)
403
404 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
405 if (mpi_grp%comm /= mpi_comm_undefined) then
406 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
407 end if
408 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
409#endif
410 end subroutine chmpi_grp_bcast_0
411
412 ! ---------------------------------------------------------
413 subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
414 class(mpi_grp_t), intent(in) :: mpi_grp
415 logical, intent(inout) :: buf
416 integer, intent(in) :: cnt
417 type(mpi_datatype), intent(in) :: sendtype
418 integer, intent(in) :: root
419
420#if defined(HAVE_MPI)
422
423 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
424 if (mpi_grp%comm /= mpi_comm_undefined) then
425 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm)
426 end if
427 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
428#endif
429 end subroutine lompi_grp_bcast_0
430
431 ! ---------------------------------------------------------
432 ! copy routine for serial case
433 subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
434 use iso_c_binding
435 logical, target, intent(in) :: sendbuf
436 logical, target, intent(out) :: recvbuf
437 integer, intent(in) :: count
438 integer :: ii
439 logical, pointer :: send(:), recv(:)
440
441 call c_f_pointer(c_loc(sendbuf), send, [count])
442 call c_f_pointer(c_loc(recvbuf), recv, [count])
443 do ii = 1, count
444 recv(ii) = send(ii)
445 end do
446 end subroutine lompi_grp_copy_0
447
448 ! ---------------------------------------------------------
449 subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
450 class(mpi_grp_t), intent(in) :: mpi_grp
451 logical, intent(in) :: sendbuf
452 logical, intent(out) :: recvbuf
453 integer, intent(in) :: count
454 type(mpi_datatype), intent(in):: datatype
455 type(mpi_op), intent(in) :: op
456
457#if defined(HAVE_MPI)
459
460 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
461 if (mpi_grp%comm /= mpi_comm_undefined) then
462 call mpi_allreduce(sendbuf, recvbuf, count, datatype, op, &
463 mpi_grp%comm)
464 else
465 call lompi_grp_copy_0(sendbuf, recvbuf, count)
466 end if
467 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
468#else
469 call lompi_grp_copy_0(sendbuf, recvbuf, count)
470#endif
471 end subroutine lompi_grp_allreduce_0
472
473 ! ---------------------------------------------------------
474 subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
475 class(mpi_grp_t), intent(in) :: mpi_grp
476 logical, intent(inout) :: recvbuf
477 integer, intent(in) :: count
478 type(mpi_datatype), intent(in) :: datatype
479 type(mpi_op), intent(in) :: op
480
481#if defined(HAVE_MPI)
483
484 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
485 if (mpi_grp%comm /= mpi_comm_undefined) then
486 call mpi_allreduce(mpi_in_place, recvbuf, count, datatype, op, &
487 mpi_grp%comm)
488 end if
489 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
490#endif
492
493 ! ---------------------------------------------------------
494 subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
495 class(mpi_grp_t), intent(in) :: mpi_grp
496 logical, intent(out) :: recvbuf
497 integer, intent(in) :: recvcount
498 type(mpi_datatype),intent(in) :: recvtype
499 integer, intent(in) :: source
500 integer, optional, intent(in) :: tag
501
502 integer :: tag_
503
504 tag_ = 0
505 if (present(tag)) tag_ = tag
506 if (mpi_grp%comm == mpi_comm_undefined) return
507#if defined(HAVE_MPI)
509
510 call mpi_debug_in(mpi_grp%comm, c_mpi_recv)
511 call mpi_recv(recvbuf, recvcount, recvtype, source, tag_, mpi_grp%comm, mpi_status_ignore)
512 call mpi_debug_out(mpi_grp%comm, c_mpi_recv)
513#endif
514 end subroutine lompi_grp_recv_0
515
516 ! ---------------------------------------------------------
517 subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
518 class(mpi_grp_t), intent(in) :: mpi_grp
519 logical, intent(in) :: sendbuf
520 integer, intent(in) :: sendcount
521 type(mpi_datatype),intent(in) :: sendtype
522 integer, intent(in) :: dest
523 integer, optional, intent(in) :: tag
524
525 integer :: tag_
526
527 tag_ = 0
528 if (present(tag)) tag_ = tag
529 if (mpi_grp%comm == mpi_comm_undefined) return
530#if defined(HAVE_MPI)
532
533 call mpi_debug_in(mpi_grp%comm, c_mpi_send)
534 call mpi_send(sendbuf, sendcount, sendtype, dest, tag_, mpi_grp%comm)
535 call mpi_debug_out(mpi_grp%comm, c_mpi_send)
536#endif
537 end subroutine lompi_grp_send_0
538
539 ! ---------------------------------------------------------
540 subroutine mpi_grp_wait(mpi_grp, request)
541 class(mpi_grp_t), intent(in) :: mpi_grp
542 type(mpi_request), intent(inout) :: request
543
544 if (mpi_grp%comm == mpi_comm_undefined) return
545#if defined(HAVE_MPI)
547
548 call mpi_debug_in(mpi_grp%comm, c_mpi_wait)
549 call mpi_wait(request, mpi_status_ignore)
550 call mpi_debug_out(mpi_grp%comm, c_mpi_wait)
551#endif
552 end subroutine mpi_grp_wait
553
554 ! ---------------------------------------------------------
555 subroutine mpi_grp_waitall(mpi_grp, count, requests)
556 class(mpi_grp_t), intent(in) :: mpi_grp
557 integer, intent(in) :: count
558 type(mpi_request), intent(inout) :: requests(:)
559
560 if (mpi_grp%comm == mpi_comm_undefined) return
561#if defined(HAVE_MPI)
563
564 call mpi_debug_in(mpi_grp%comm, c_mpi_waitall)
565 call mpi_waitall(count, requests, mpi_statuses_ignore)
566 call mpi_debug_out(mpi_grp%comm, c_mpi_waitall)
567#endif
568 end subroutine mpi_grp_waitall
569
570 ! ---------------------------------------------------------
571 subroutine mpi_grp_abort(mpi_grp)
572 class(mpi_grp_t), intent(in) :: mpi_grp
573
574 if (mpi_grp%comm /= mpi_comm_undefined) then
575#if defined(HAVE_MPI)
577
578 ! Abort with an arbitrary error code
579 call mpi_abort(mpi_grp%comm, 999)
580#endif
581 end if
582
583 error stop 1
584
585 end subroutine mpi_grp_abort
587 ! ---------------------------------------------------------
589 real(real64) function mpi_get_wtime() result(now)
590#if defined(HAVE_MPI)
591 now = mpi_wtime()
592#else
593 now = loct_clock()
594#endif
595 end function mpi_get_wtime
596
597#include "undef.F90"
598#include "real.F90"
599#include "mpi_inc.F90"
600
601#include "undef.F90"
602#include "complex.F90"
603#include "mpi_inc.F90"
604
605#include "undef.F90"
606#include "integer.F90"
607#include "mpi_inc.F90"
608
609#include "undef.F90"
610#include "integer8.F90"
611#include "mpi_inc.F90"
612
613end module mpi_oct_m
614
615
616!! Local Variables:
617!! mode: f90
618!! coding: utf-8
619!! End:
Interface for function returned by mpi_call_is_thread_safe_factory
Definition: mpi.F90:283
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:569
subroutine impi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3313
subroutine dmpi_grp_recv_2(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:1126
subroutine zmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2415
subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:397
subroutine impi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3288
subroutine lmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4439
subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
Definition: mpi.F90:453
subroutine zmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2263
subroutine zmpi_grp_recv_3(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:2148
subroutine blacs_init()
Initialize BLACS to enable use of SCALAPACK.
Definition: mpi.F90:320
subroutine impi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3239
real(real64) function, public mpi_get_wtime()
. Returns an elapsed time on the calling processor.
Definition: mpi.F90:587
subroutine dmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1365
subroutine zmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2440
subroutine dmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1491
subroutine zmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2364
subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:442
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:411
subroutine impi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3338
subroutine zmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2314
procedure(omp_region_func), pointer mpi_call_is_thread_safe
Single-threaded without MPI.
Definition: mpi.F90:289
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:387
subroutine zmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2490
subroutine impi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3464
subroutine lmpi_grp_recv_3(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:4147
subroutine impi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3439
subroutine impi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3170
subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
Definition: mpi.F90:482
subroutine impi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3388
subroutine impi_grp_recv_2(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:3124
subroutine zmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2339
subroutine dmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1416
subroutine zmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2171
subroutine dmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1315
subroutine lmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4262
subroutine dmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1218
subroutine impi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3262
subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:492
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:310
subroutine dmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1172
subroutine lmpi_grp_recv_2(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:4124
subroutine mpi_grp_wait(mpi_grp, request)
Definition: mpi.F90:538
subroutine lmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4313
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:276
subroutine impi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3414
subroutine mpi_mod_end()
Finalize MPI, and conditionally BLACS.
Definition: mpi.F90:326
logical pure function, private not_in_openmp()
Not in an OpenMP region.
Definition: mpi.F90:373
subroutine dmpi_grp_recv_3(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:1149
subroutine lmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4464
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:345
subroutine zmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2217
subroutine dmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1290
subroutine impi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3363
subroutine impi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3489
subroutine dmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1441
subroutine dmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1466
subroutine zmpi_grp_recv_2(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:2125
subroutine zmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2389
subroutine lmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4363
subroutine mpi_grp_barrier(mpi_grp)
Definition: mpi.F90:418
subroutine impi_grp_recv_3(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:3147
subroutine zmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:2289
subroutine lmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4216
subroutine mpi_init_comm(comm)
Wrapper for MPI_COMM_WORLD initialisation.
Definition: mpi.F90:299
subroutine impi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:3216
subroutine dmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1340
subroutine lmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4388
subroutine dmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1264
subroutine lmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4170
subroutine lmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4414
subroutine dmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1390
subroutine dmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1241
subroutine zmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:2465
subroutine lmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4239
subroutine zmpi_grp_send_3(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2240
subroutine mpi_grp_waitall(mpi_grp, count, requests)
Definition: mpi.F90:553
subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
Definition: mpi.F90:469
subroutine lmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4288
subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:515
subroutine lmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4489
subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:432
subroutine lmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4338
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)