b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2comm.H
1//------------------------------------------------------------------------
2// b2comm.H
3//
4// written by Harald Klimach <harald.klimach@dlr.de>
5// Neda Ebrahimi Pour <neda.ebrahimipour@dlr.de>
6//
7// (c) 2021 Deutsches Zentrum für Luft- und Raumfahrt (DLR) e.V.
8// Linder Höhe, 51147 Köln
9//
10// All Rights Reserved. Proprietary source code. The contents of
11// this file may not be disclosed to third parties, copied or
12// duplicated in any form, in whole or in part, without the prior
13// written permission of DLR.
14//
15//------------------------------------------------------------------------
16
17#ifndef B2COMM_H_
18#define B2COMM_H_
19
20//------------------------------------------------------------------------
21//
22// \file
23// Communicator system for b2000 to deal with communication between
24// processes.
25//
26//------------------------------------------------------------------------
27
28#include <memory>
29
30#include "b2ppconfig.h"
31#include "utils/b2cmdline.H"
32#include "utils/b2object.H"
33
34// \file
35//
36// Abstract definition of the API for distributed memory parallelization.
37
38namespace b2000 {
39
40// Abstract class defining the communication strategy for distributed
41// memory parallelization.
42class Communicator {
43public:
44 virtual ~Communicator(){};
45
46 // Rank of the running process
47 virtual int rank() const = 0;
48
49 // Number of processes in this communicator
50 virtual int NumRanks() const = 0;
51
52 // Is the running process root of the communicator?
53 virtual bool IsRoot() const = 0;
54
55 // Additional command line options for the communication
56 virtual void CmdOpts(cmdline::CmdLine& cmdline) = 0;
57
58 // Get a communicator handle for Fortran, needed by MUMPS.
59 virtual int GetFcomm() const = 0;
60
61 // Abort the parallel execution.
62 virtual void Abort(int errorcode) = 0;
63
64 // Synchronize all processes in the communicator
65 virtual void Barrier() = 0;
66
67 // Receive a message from rank source with tag within the communicator.
68 virtual void Recv(char buffer[], uint64_t length, int source, int tag) = 0;
69
70 // Send a message to rank target with tag within the communicator.
71 virtual void Send(char buffer[], uint64_t length, int target, int tag) = 0;
72
73 // Broadcast a buffer from the root process to all in the communicator
74 virtual void Bcast(uint64_t buffer[], uint64_t length, int root = 0) = 0;
75 virtual void Bcast(int buffer[], uint64_t length, int root = 0) = 0;
76 virtual void Bcast(double buffer[], uint64_t length, int root = 0) = 0;
77
78 // Probe an incoming message for its size in bytes (before calling
79 // the corresponding receive).
80 virtual uint64_t ProbeByteCount(int source, int tag) = 0;
81}; // class Communicator
82
83// Creator function to decide on the actual communicator to be used.
84// This depends on the compile-time environment, depending on the available
85// communication layers, the appropriate Communicator implementation will
86// be returned.
87std::shared_ptr<Communicator> CreateComm(int argc, char* argv[]);
88
89} // namespace b2000
90
91#endif // B2COMM_H_
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32