MpiHelper.cc 1.23 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


13
14
#include "MpiHelper.h"

15
16
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS

17
18
19
20
21
22
23
24
25
namespace AMDiS {

  namespace mpi {

    void globalAdd(double &value)
    {
      double valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_DOUBLE, MPI_SUM);
    }
26
27
28
29
30
31

    void globalAdd(int &value)
    {
      int valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_INT, MPI_SUM);
    }
32
33
34
35
36
37
    
    void globalMin(double &value)
    {
      double valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_DOUBLE, MPI_MIN);
    }
38
39
40
41
42
43

    void globalMin(int &value)
    {
      int valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_INT, MPI_MIN);
    }
44
45
46
47
48
49
50
    
    void globalMax(double &value)
    {
      double valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_DOUBLE, MPI_MAX);
    }

51
52
53
54
55
56
    void globalMax(int &value)
    {
      int valCopy = value;
      MPI::COMM_WORLD.Allreduce(&valCopy, &value, 1, MPI_INT, MPI_MAX);
    }

57
58
  }
}
59
60

#endif