MADNESS  0.10.1
worldinit.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 /**
33  \file worldinit.h
34  \brief Declares the functions that initialize the parallel runtime.
35  \ingroup world
36 */
37 
38 #ifndef MADNESS_WORLD_WORLDINIT_H__INCLUDED
39 #define MADNESS_WORLD_WORLDINIT_H__INCLUDED
40 
41 // Madness world header files needed by world
42 #include <madness/world/worldmpi.h>
43 
44 /// \addtogroup world
45 /// @{
46 
47 namespace madness {
48 
49  class World;
50  class WorldTaskQueue;
51  class WorldAmInterface;
52  class WorldGopInterface;
53 
54  /// redirects standard output and error to rank-specific files
55 
56  /// @param[in] world the World object that determines rank of this process
57  /// @param[in] split if true, write standard output to log.<rank> and standard error to err.<rank>,
58  /// otherwise write both standard output and error to log.<rank>. The default is false.
59  void redirectio(const World& world, bool split = false);
60 
61  /// Initializes the MADNESS runtime with default MPI communicator and
62  /// default number of compute threads
63 
64  /// Call this once at the very top of your main program to initialize the
65  /// MADNESS runtime. This function should be called instead of \c MPI_Init()
66  /// or \c MPI_Init_thread().
67  /// \param[in,out] argc Application argument count.
68  /// \param[in,out] argv Application argument values.
69  /// \param[in] quiet If false, will announce to \c std::cout on rank 0 when
70  /// the runtime has been initialized.
71  /// \return A reference to the default \c World, which is constructed with
72  /// \c MPI_COMM_WORLD.
73  /// \note The default number of compute threads is read from the environment variable `MAD_NUM_THREADS`;
74  /// if the environment variable is not given the number of compute thread is set to the system-defined number of hardware threads.
75  World& initialize(int& argc, char**& argv, bool quiet = false);
76 
77  /// Initializes the MADNESS runtime with default MPI communicator and
78  /// the given number of compute threads
79 
80  /// Call this once at the very top of your main program to initialize the
81  /// MADNESS runtime. This function should be called instead of \c MPI_Init()
82  /// or \c MPI_Init_thread().
83  /// \param[in,out] argc Application argument count.
84  /// \param[in,out] argv Application argument values.
85  /// \param[in] nthread The total number of compute threads to create
86  /// (the main thread is counted among the compute threads)
87  /// if a negative value is given then the default number of compute threads
88  /// will be used.
89  /// \param[in] quiet If false, will announce to \c std::cout on rank 0 when
90  /// the runtime has been initialized.
91  /// \return A reference to the default \c World, which is constructed with
92  /// \c MPI_COMM_WORLD.
93  /// \note The default number of compute threads is read from the environment variable `MAD_NUM_THREADS`;
94  /// if the environment variable is not given the number of compute thread is set to the system-defined number of hardware threads.
95  World& initialize(int& argc, char**& argv, int nthread, bool quiet = false);
96 
97  /// Initializes the MADNESS runtime with the given MPI communicator and
98  /// the default number of compute threads
99 
100  /// Call this once at the very top of your main program to initialize the
101  /// MADNESS runtime. This function should be called instead of \c MPI_Init()
102  /// or \c MPI_Init_thread().
103  /// \param[in,out] argc Application argument count.
104  /// \param[in,out] argv Application argument values.
105  /// \param comm The communicator that should be used to construct the
106  /// \c World object.
107  /// \param[in] quiet If false, will announce to \c std::cout on rank 0 when
108  /// the runtime has been initialized.
109  /// \return A reference to the \c World constructed with \c comm.
110  /// \note The default number of compute threads is read from the environment variable `MAD_NUM_THREADS`;
111  /// if the environment variable is not given the number of compute thread is set to the system-defined number of hardware threads.
112  World& initialize(int& argc, char**& argv, const SafeMPI::Intracomm& comm,
113  bool quiet = false);
114 
115  /// Initializes the MADNESS runtime with the given MPI communicator and
116  /// the given number of compute threads
117 
118  /// Call this once at the very top of your main program to initialize the
119  /// MADNESS runtime. This function should be called instead of \c MPI_Init()
120  /// or \c MPI_Init_thread().
121  /// \param[in,out] argc Application argument count.
122  /// \param[in,out] argv Application argument values.
123  /// \param comm The communicator that should be used to construct the
124  /// \c World object.
125  /// \param[in] nthread The total number of compute threads to create
126  /// (the main thread is counted among the compute threads);
127  /// if a negative value is given then the default number of compute threads
128  /// will be used.
129  /// \param[in] quiet If false, will announce to \c std::cout on rank 0 when
130  /// the runtime has been initialized.
131  /// \return A reference to the \c World constructed with \c comm.
132  /// \note The default number of compute threads is read from the environment variable `MAD_NUM_THREADS`;
133  /// if the environment variable is not given the number of compute thread is set to the system-defined number of hardware threads.
134  World& initialize(int& argc, char**& argv, const SafeMPI::Intracomm& comm,
135  int nthread,
136  bool quiet = false);
137 
138  /// Initializes the MADNESS runtime with the given MPI communicator and
139  /// the given number of compute threads
140 
141  /// Call this once at the very top of your main program to initialize the
142  /// MADNESS runtime. This function should be called instead of \c MPI_Init()
143  /// or \c MPI_Init_thread().
144  /// \param[in,out] argc Application argument count.
145  /// \param[in,out] argv Application argument values.
146  /// \param comm The MPI communicator that should be used to construct the
147  /// \c World object.
148  /// \param[in] nthread The total number of compute threads to create
149  /// (the main thread is counted among the compute threads)
150  /// if a negative value is given then the default number of compute threads
151  /// will be used.
152  /// \param[in] quiet If false, will announce to \c std::cout on rank 0 when
153  /// the runtime has been initialized.
154  /// \return A reference to the World constructed with \c comm.
155  /// \note The default number of compute threads is read from the environment variable `MAD_NUM_THREADS`;
156  /// if the environment variable is not given the number of compute thread is set to the system-defined number of hardware threads.
157  World& initialize(int& argc, char**& argv, const MPI_Comm& comm,
158  int nthread,
159  bool quiet = false);
160 
161  /// Call this once at the very end of your main program instead of MPI_Finalize().
162  void finalize();
163 
164  /// Check if the MADNESS runtime has been initialized (and not subsequently finalized).
165 
166  /// @return true if \c madness::initialize had been called more recently than \c madness::finalize, false otherwise.
167  bool initialized();
168 
169  /// Check if the MADNESS runtime was initialized for quiet operation.
170 
171  /// @return true if \c madness::initialize was called with \c quiet=true .
172  bool quiet();
173 
174 } // namespace madness
175 
176 /// @}
177 
178 #endif // MADNESS_WORLD_WORLDINIT_H__INCLUDED
Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy.
Definition: safempi.h:490
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
void finalize()
Call this once at the very end of your main program instead of MPI_Finalize().
Definition: world.cc:232
bool initialized()
Check if the MADNESS runtime has been initialized (and not subsequently finalized).
Definition: world.cc:74
bool quiet()
Check if the MADNESS runtime was initialized for quiet operation.
Definition: world.cc:77
World & initialize(int &argc, char **&argv, bool quiet)
Definition: world.cc:145
void redirectio(const World &world, bool split)
redirects standard output and error to rank-specific files
Definition: redirectio.cc:42
int MPI_Comm
Definition: stubmpi.h:23
void split(const Range< ConcurrentHashMap< int, int >::iterator > &range)
Definition: test_hashthreaded.cc:63
Implements WorldMpiInterface.