Debian Codegraph @

dune/uggrid/parallel/ddd/basic/reduct.cc

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 /****************************************************************************/
6 /* */
7 /* File: reduct.c */
8 /* */
9 /* Purpose: standard parallel routines not supported by ddd */
10 /* reduction operations (GlobalSum, GlobalMax etc) */
11 /* */
12 /* Author: Klaus Birken */
13 /* Rechenzentrum Uni Stuttgart */
14 /* Universitaet Stuttgart */
15 /* Allmandring 30 */
16 /* 70550 Stuttgart */
17 /* internet: [email protected] */
18 /* */
19 /* History: 940128 kb begin */
20 /* 960902 kb copied from fedemo, adapted */
21 /* */
22 /* Remarks: */
23 /* */
24 /****************************************************************************/
25
26 /****************************************************************************/
27 /* */
28 /* include files */
29 /* system include files */
30 /* application include files */
31 /* */
32 /****************************************************************************/
33
34 #include "config.h"
35
36 #include <mpi.h>
37
38 #include <dune/uggrid/parallel/ddd/dddcontext.hh>
39 #include <dune/uggrid/parallel/ppif/ppifcontext.hh>
40
41 #include <dune/uggrid/low/namespace.h>
42
43 namespace DDD {
44
45 /****************************************************************************/
46 /* */
47 /* routines */
48 /* */
49 /****************************************************************************/
50
51
52 /* some useful functions by Peter Bastian, from ugp/ug/ugcom.c */
53
54
55 int ddd_GlobalMaxInt(const DDD::DDDContext& context, int i)
56 {
57 MPI_Allreduce(MPI_IN_PLACE, &i, 1, MPI_INT, MPI_MAX, context.ppifContext().comm());
58 return i;
59 }
60
61 int ddd_GlobalMinInt(const DDD::DDDContext& context, int i)
62 {
63 MPI_Allreduce(MPI_IN_PLACE, &i, 1, MPI_INT, MPI_MIN, context.ppifContext().comm());
64 return i;
65 }
66
67 int ddd_GlobalSumInt(const DDD::DDDContext& context, int x)
68 {
69 MPI_Allreduce(MPI_IN_PLACE, &x, 1, MPI_INT, MPI_SUM, context.ppifContext().comm());
70 return x;
71 }
72
73 } /* namespace DDD */