| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: ppif.h */ |
| 8 |
/* */ |
| 9 |
/* Purpose: header file for parallel processor interface */ |
| 10 |
/* */ |
| 11 |
/* Author: Peter Bastian / Klaus Birken */ |
| 12 |
/* */ |
| 13 |
/* History: 17 Aug 1992 begin */ |
| 14 |
/* 14 Sep 1993 pass argc, argv from main to InitPPIF */ |
| 15 |
/* 16 Sep 1993 async send/recv return msgid now */ |
| 16 |
/* 951106 kb changed parameters for InitPPIF() */ |
| 17 |
/* 970213 kb added C++ class interface */ |
| 18 |
/* */ |
| 19 |
/* Remarks: */ |
| 20 |
/* */ |
| 21 |
/****************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
/****************************************************************************/ |
| 25 |
/* */ |
| 26 |
/* auto include mechanism and other include files */ |
| 27 |
/* */ |
| 28 |
/****************************************************************************/ |
| 29 |
|
| 30 |
#ifndef __PPIF__ |
| 31 |
#define __PPIF__ |
| 32 |
|
| 33 |
#include <memory> |
| 34 |
|
| 35 |
#include <dune/uggrid/parallel/ppif/ppiftypes.hh> |
| 36 |
|
| 37 |
/****************************************************************************/ |
| 38 |
/* */ |
| 39 |
/* data structures exported by the corresponding source file */ |
| 40 |
/* */ |
| 41 |
/****************************************************************************/ |
| 42 |
|
| 43 |
using VChannelPtr = PPIF::VChannelPtr; |
| 44 |
using msgid = PPIF::msgid; |
| 45 |
|
| 46 |
namespace PPIF { |
| 47 |
|
| 48 |
enum directions {north,east,south,west,up,down}; |
| 49 |
|
| 50 |
#define PPIF_SUCCESS 0 /* Return value for success */ |
| 51 |
#define PPIF_FAILURE 1 /* Return value for failure */ |
| 52 |
|
| 53 |
/****************************************************************************/ |
| 54 |
/* */ |
| 55 |
/* definition of exported global variables */ |
| 56 |
/* */ |
| 57 |
/****************************************************************************/ |
| 58 |
|
| 59 |
/* id's */ |
| 60 |
extern int me; /* my processor id */ |
| 61 |
extern int master; /* id of master processor */ |
| 62 |
extern int procs; /* number of processors in the network */ |
| 63 |
|
| 64 |
/****************************************************************************/ |
| 65 |
/* */ |
| 66 |
/* function declarations */ |
| 67 |
/* */ |
| 68 |
/****************************************************************************/ |
| 69 |
|
| 70 |
/** |
| 71 |
* set context used by PPIF. |
| 72 |
* |
| 73 |
* This also updates the legacy global variables `me`, `master`, and `procs`. |
| 74 |
* |
| 75 |
* \warn context should be managed by the caller |
| 76 |
*/ |
| 77 |
void ppifContext(const std::shared_ptr<PPIFContext>& context); |
| 78 |
|
| 79 |
/** |
| 80 |
* reset context used by PPIF. |
| 81 |
*/ |
| 82 |
void ppifContext(std::nullptr_t); |
| 83 |
|
| 84 |
/** |
| 85 |
* get context used by PPIF |
| 86 |
* |
| 87 |
* \warn context should be managed by the called |
| 88 |
*/ |
| 89 |
const std::shared_ptr<PPIFContext>& ppifContext(); |
| 90 |
|
| 91 |
/* initialization & shutdown */ |
| 92 |
void InitPPIF (PPIFContext& context); |
| 93 |
int InitPPIF (int *argcp, char ***argvp); |
| 94 |
void ExitPPIF (PPIFContext& context); |
| 95 |
int ExitPPIF (void); |
| 96 |
|
| 97 |
/* tree oriented functions */ |
| 98 |
int Broadcast (const PPIFContext& context, void* data, int size); |
| 99 |
int Concentrate (const PPIFContext& context, void *data, int size); |
| 100 |
int GetConcentrate (const PPIFContext& context, int slave, void *data, int size); |
| 101 |
int Spread (const PPIFContext& context, int slave, void *data, int size); |
| 102 |
int GetSpread (const PPIFContext& context, void *data, int size); |
| 103 |
int Synchronize (const PPIFContext& context); |
| 104 |
|
| 105 |
/* synchronous communication */ |
| 106 |
VChannelPtr ConnSync (const PPIFContext& context, int p, int id); |
| 107 |
int DiscSync (const PPIFContext& context, VChannelPtr vc); |
| 108 |
int SendSync (const PPIFContext& context, VChannelPtr vc, void *data, int size); |
| 109 |
int RecvSync (const PPIFContext& context, VChannelPtr vc, void *data, int size); |
| 110 |
|
| 111 |
/* asynchronous communication */ |
| 112 |
VChannelPtr ConnASync (const PPIFContext& context, int p, int id); |
| 113 |
int DiscASync (const PPIFContext& context, VChannelPtr vc); |
| 114 |
msgid SendASync (const PPIFContext& context, VChannelPtr vc, void *data, int size, int *error); |
| 115 |
msgid RecvASync (const PPIFContext& context, VChannelPtr vc, void *data, int size, int *error); |
| 116 |
int InfoAConn (const PPIFContext& context, VChannelPtr vc); |
| 117 |
int InfoADisc (const PPIFContext& context, VChannelPtr vc); |
| 118 |
int InfoASend (const PPIFContext& context, VChannelPtr vc, msgid m); |
| 119 |
int InfoARecv (const PPIFContext& context, VChannelPtr vc, msgid m); |
| 120 |
|
| 121 |
} // end namespace PPIF |
| 122 |
|
| 123 |
|
| 124 |
/****************************************************************************/ |
| 125 |
|
| 126 |
#endif |