MADNESS 0.10.1
print_seq.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program 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.
10
11 This program 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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30*/
31
32#ifndef MADNESS_WORLD_PRINT_SEQ_H__INCLUDED
33#define MADNESS_WORLD_PRINT_SEQ_H__INCLUDED
34
35/**
36 \file print_seq.h
37 \brief Implements \c print_seq.
38 \ingroup libraries
39 \todo Can these functions be replaced by a variadic template?
40*/
41
42namespace madness {
43 /// Sequentially ordered printing of (serializable) data from every process.
44
45 /// Collective, no fence.
46 /// \tparam A Type of data 1.
47 /// \tparam B Type of data 2.
48 /// \tparam C Type of data 3.
49 /// \tparam D Type of data 4.
50 /// \param[in] world The \c World object.
51 /// \param[in] a Data 1.
52 /// \param[in] b Data 2.
53 /// \param[in] c Data 3.
54 /// \param[in] d Data 4.
55 template <typename A, typename B, typename C, typename D>
56 void print_seq(World& world, const A& a, const B& b, const C& c, const D& d) {
57 if (world.rank() == 0) {
58 printf("%6d : ",0);
59 print(a, b, c, d);
60 for (int p=1; p<world.size(); ++p) {
61 A aa;
62 B bb;
63 C cc;
64 D dd;
66 archive::MPIInputArchive(world, p) & aa & bb & cc & dd;
67 printf("%6d : ",p);
68 print(aa, bb, cc, dd);
69 }
70 }
71 else {
72 int i;
73 archive::MPIInputArchive(world, 0) & i;
74 archive::MPIOutputArchive(world, 0) & a & b & c & d;
75 }
76 }
77
78 /// Sequentially ordered printing of (serializable) data from every process.
79
80 /// Collective, no fence.
81 /// \tparam A Type of data 1.
82 /// \tparam B Type of data 2.
83 /// \tparam C Type of data 3.
84 /// \param[in] world The \c World object.
85 /// \param[in] a Data 1.
86 /// \param[in] b Data 2.
87 /// \param[in] c Data 3.
88 template <typename A, typename B, typename C>
89 void print_seq(World& world, const A& a, const B& b, const C& c) {
90 if (world.rank() == 0) {
91 printf("%6d : ",0);
92 print(a, b, c);
93 for (int p=1; p<world.size(); ++p) {
94 A aa;
95 B bb;
96 C cc;
98 archive::MPIInputArchive(world, p) & aa & bb & cc;
99 printf("%6d : ",p);
100 print(aa, bb, cc);
101 }
102 }
103 else {
104 int i;
105 archive::MPIInputArchive(world, 0) & i;
106 archive::MPIOutputArchive(world, 0) & a & b & c;
107 }
108 }
109
110 /// Sequentially ordered printing of (serializable) data from every process.
111
112 /// Collective, no fence.
113 /// \tparam A Type of data 1.
114 /// \tparam B Type of data 2.
115 /// \param[in] world The \c World object.
116 /// \param[in] a Data 1.
117 /// \param[in] b Data 2.
118 template <typename A, typename B>
119 void print_seq(World& world, const A& a, const B& b) {
120 if (world.rank() == 0) {
121 printf("%6d : ",0);
122 print(a, b);
123 for (int p=1; p<world.size(); ++p) {
124 A aa;
125 B bb;
126 archive::MPIOutputArchive(world,p) & 1;
127 archive::MPIInputArchive(world, p) & aa & bb;
128 printf("%6d : ",p);
129 print(aa, bb);
130 }
131 }
132 else {
133 int i;
134 archive::MPIInputArchive(world, 0) & i;
135 archive::MPIOutputArchive(world, 0) & a & b;
136 }
137 }
138
139 /// Sequentially ordered printing of (serializable) data from every process.
140
141 /// Collective, no fence.
142 /// \tparam A Type of data 1.
143 /// \param[in] world The \c World object.
144 /// \param[in] a Data 1.
145 template <typename A>
146 void print_seq(World& world, const A& a) {
147 if (world.rank() == 0) {
148 printf("%6d : ",0);
149 print(a);
150 for (int p=1; p<world.size(); ++p) {
151 A aa;
152 archive::MPIOutputArchive(world,p) & 1;
153 archive::MPIInputArchive(world, p) & aa;
154 printf("%6d : ",p);
155 print(aa);
156 }
157 }
158 else {
159 int i;
160 archive::MPIInputArchive(world, 0) & i;
161 archive::MPIOutputArchive(world, 0) & a;
162 }
163 }
164}
165
166#endif // MADNESS_WORLD_PRINT_SEQ_H__INCLUDED
Definition test_ar.cc:118
Definition test_ar.cc:141
Definition test_ar.cc:170
A parallel world class.
Definition world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:320
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:330
Archive allowing buffering, deserialization of data, and point-to-point communication between process...
Definition mpi_archive.h:180
Archive allowing buffering, serialization of data, and point-to-point communication between processes...
Definition mpi_archive.h:118
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
void print_seq(World &world, const A &a, const B &b, const C &c, const D &d)
Sequentially ordered printing of (serializable) data from every process.
Definition print_seq.h:56
const double cc
Definition navstokes_cosines.cc:107
static const double b
Definition nonlinschro.cc:119
static const double d
Definition nonlinschro.cc:121
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
Definition test_ar.cc:204
double aa
Definition testbsh.cc:68