2
/// This file is part of Rheolef.
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
6
/// Rheolef is free software; you can redistribute it and/or modify
7
/// it under the terms of the GNU General Public License as published by
8
/// the Free Software Foundation; either version 2 of the License, or
9
/// (at your option) any later version.
11
/// Rheolef is distributed in the hope that it will be useful,
12
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
/// GNU General Public License for more details.
16
/// You should have received a copy of the GNU General Public License
17
/// along with Rheolef; if not, write to the Free Software
18
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
/// =========================================================================
21
#include "rheolef/config.h"
22
#ifndef _RHEOLEF_HAVE_MPI
23
int main() {return 0;}
24
#else // _RHEOLEF_HAVE_MPI
26
#include <rheolef/distributor.h>
27
using namespace rheolef;
29
// -------------------------------------------------------------
30
// send a pair<size_t,T> via mpi & serialization
31
// -------------------------------------------------------------
32
// non-intrusive version of serialization for pair<size_t,T>
34
namespace serialization {
35
template<class T, class Archive>
36
void serialize (Archive & ar, std::pair<size_t, T>& g, const unsigned int version) {
40
} // namespace serialization
42
// -------------------------------------------------------------
44
// -------------------------------------------------------------
45
typedef pair<size_t,double> pair_t;
46
int main(int argc, char* argv[]) {
47
environment parallel(argc, argv);
48
mpi::communicator comm;
49
if (comm.size() != 2) return 0;
50
if (comm.rank() == 0) {
51
pair_t p_send (1,1.1);
52
comm.send(1, 0, p_send);
54
comm.recv(1, 1, p_recv);
55
cout << "[0]{" << p_recv.first << "," << p_recv.second << "}" << endl << flush;
58
comm.recv(0, 0, p_recv);
59
cout << "[1]{" << p_recv.first << "," << p_recv.second << "}" << endl << flush;
60
pair_t p_send (2,2.2);
61
comm.send(0, 1, p_send);
64
#endif // _RHEOLEF_HAVE_MPI