Zoltan2
Toggle main menu visibility
Loading...
Searching...
No Matches
Zoltan2_DebugManager.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Zoltan2: A package of combinatorial algorithms for scientific computing
4
//
5
// Copyright 2012 NTESS and the Zoltan2 contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
14
#ifndef ZOLTAN2_DEBUGMANAGER_HPP
15
#define ZOLTAN2_DEBUGMANAGER_HPP
16
17
#include <
Zoltan2_Parameters.hpp
>
18
#include <string>
19
#include <iostream>
20
#include <fstream>
21
22
namespace
Zoltan2
23
{
44
45
class
DebugManager
46
{
47
public
:
48
59
DebugManager
(
int
rank,
bool
doPrinting, std::ofstream &debugOs,
60
MessageOutputLevel
debugLevel) : myPID_(rank), debugLevel_(debugLevel),
61
myOS_(static_cast<std::ostream *>(&debugOs)), fileOS_(&debugOs),
62
iPrint_(doPrinting) {}
63
71
DebugManager
(
int
rank,
bool
doPrinting, std::ostream &debugOs,
72
MessageOutputLevel
debugLevel) : myPID_(rank), debugLevel_(debugLevel),
73
myOS_(&debugOs), fileOS_(NULL), iPrint_(doPrinting) {}
74
77
virtual
~DebugManager
()
78
{
79
myOS_->flush();
80
if
(fileOS_)
81
fileOS_->close();
82
}
83
86
inline
std::ostream *
getOStream
()
const
{
return
myOS_; };
87
90
inline
MessageOutputLevel
getDebugLevel
()
const
{
return
debugLevel_; };
91
100
inline
void
print
(
MessageOutputLevel
debugLevel,
const
std::string &output){
101
#ifndef Z2_OMIT_ALL_STATUS_MESSAGES
102
if
(debugLevel <= debugLevel_ && iPrint_)
103
*myOS_ << myPID_ <<
": "
<< output << std::endl;
104
#endif
105
}
106
116
inline
void
printInAllTasks
(
MessageOutputLevel
debugLevel,
const
std::string &output){
117
#ifndef Z2_OMIT_ALL_STATUS_MESSAGES
118
if
(debugLevel <= debugLevel_)
119
*myOS_ << myPID_ <<
": "
<< output << std::endl;
120
#endif
121
}
122
131
inline
void
print
(
MessageOutputLevel
debugLevel,
const
char
*output){
132
#ifndef Z2_OMIT_ALL_STATUS_MESSAGES
133
if
(debugLevel <= debugLevel_ && iPrint_)
134
*myOS_ << myPID_ <<
": "
<< output << std::endl;
135
#endif
136
}
137
146
inline
void
printInAllTasks
(
MessageOutputLevel
debugLevel,
const
char
*output) {
147
#ifndef Z2_OMIT_ALL_STATUS_MESSAGES
148
if
(debugLevel <= debugLevel_)
149
*myOS_ <<
"PID ="
<< myPID_ <<
" "
<< output << std::endl;
150
#endif
151
}
152
153
private
:
154
155
int
myPID_;
156
MessageOutputLevel
debugLevel_;
157
std::ostream *myOS_;
158
std::ofstream *fileOS_;
159
bool
iPrint_;
160
};
161
162
}
//namespace Zoltan2
163
164
#endif
Zoltan2_Parameters.hpp
Defines Parameter related enumerators, declares functions.
DebugManager::DebugManager
DebugManager(int rank, bool doPrinting, std::ofstream &debugOs, MessageOutputLevel debugLevel)
Constructor for output to an ofstream.
Definition
Zoltan2_DebugManager.hpp:59
Zoltan2::DebugManager::print
void print(MessageOutputLevel debugLevel, const std::string &output)
Print a debug or status message, if this process is one of those that is supposed to be doing output.
Definition
Zoltan2_DebugManager.hpp:100
Zoltan2::DebugManager::DebugManager
DebugManager(int rank, bool doPrinting, std::ofstream &debugOs, MessageOutputLevel debugLevel)
Constructor for output to an ofstream.
Definition
Zoltan2_DebugManager.hpp:59
Zoltan2::DebugManager::~DebugManager
virtual ~DebugManager()
Destructor.
Definition
Zoltan2_DebugManager.hpp:77
Zoltan2::DebugManager::printInAllTasks
void printInAllTasks(MessageOutputLevel debugLevel, const std::string &output)
Print a debug or status message regardless of whether this process is one of those that is supposed t...
Definition
Zoltan2_DebugManager.hpp:116
Zoltan2::DebugManager::getDebugLevel
MessageOutputLevel getDebugLevel() const
Return the highest level of message that will be printed.
Definition
Zoltan2_DebugManager.hpp:90
Zoltan2::DebugManager::print
void print(MessageOutputLevel debugLevel, const char *output)
The const char * versions of print functions are needed to avoid the expensive conversion to string.
Definition
Zoltan2_DebugManager.hpp:131
Zoltan2::DebugManager::getOStream
std::ostream * getOStream() const
Return the output stream for debug/status messages.
Definition
Zoltan2_DebugManager.hpp:86
Zoltan2::DebugManager::DebugManager
DebugManager(int rank, bool doPrinting, std::ostream &debugOs, MessageOutputLevel debugLevel)
Constructor for output to an iostream.
Definition
Zoltan2_DebugManager.hpp:71
Zoltan2::DebugManager::printInAllTasks
void printInAllTasks(MessageOutputLevel debugLevel, const char *output)
The const char * versions of print functions are needed to avoid the expensive conversion to string.
Definition
Zoltan2_DebugManager.hpp:146
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:47
Zoltan2::MessageOutputLevel
MessageOutputLevel
The amount of debugging or status output to print.
Definition
Zoltan2_Parameters.hpp:68
core
src
environment
Zoltan2_DebugManager.hpp
Generated by
1.17.0