Zoltan2
Toggle main menu visibility
Loading...
Searching...
No Matches
Zoltan2_MetricOutputManager.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
13
#ifndef _ZOLTAN2_METRICOUTPUT_MANAGER_CPP_
14
#define _ZOLTAN2_METRICOUTPUT_MANAGER_CPP_
15
16
#include <string>
17
#include <iostream>
18
#include <fstream>
19
20
namespace
Zoltan2
21
{
36
37
template
<
typename
T>
38
class
MetricOutputManager
39
{
40
public
:
41
53
54
MetricOutputManager
(
int
rank,
bool
doPrinting, std::ofstream &Os,
55
bool
metricsOn, std::string units=std::string(
""
),
int
width=10):
56
me_(rank),
57
os_(static_cast<std::ostream *>(&Os)), osFile_(&Os),
58
iPrint_(doPrinting), wePrint_(metricsOn),
59
units_(units), width_(width){}
60
61
70
71
MetricOutputManager
(
int
rank,
bool
doPrinting, std::ostream &Os,
72
bool
metricsOn, std::string units=std::string(
""
),
int
width=10):
73
me_(rank), os_(&Os), osFile_(NULL),
74
iPrint_(doPrinting), wePrint_(metricsOn),
75
units_(units), width_(width){}
76
79
~MetricOutputManager
() {}
80
83
inline
std::ostream *
getOStream
()
const
{
return
os_; }
84
87
inline
bool
getMetricsOn
()
const
{
return
wePrint_; }
88
93
inline
void
print
(
const
std::string &msg,
const
T val){
94
if
(iPrint_){
95
if
(os_){
96
os_->width(10); os_->fill(
'*'
);
97
*os_ << me_ <<
": "
<< val <<
" "
<< units_ <<
", "
<< msg << std::endl;
98
os_->width(0); os_->fill(
' '
);
99
}
100
else
{
101
osFile_->width(10); osFile_->fill(
'*'
);
102
*osFile_ << me_ <<
": "
<< val <<
" "
<< units_ <<
", "
<< msg << std::endl;
103
osFile_->width(0); osFile_->fill(
' '
);
104
}
105
}
106
}
107
114
inline
void
print
(
const
char
*msg, T val){
115
if
(iPrint_){
116
if
(os_){
117
os_->width(10); os_->fill(
'*'
);
118
*os_ << me_ <<
": "
<< val <<
" "
<< units_ <<
", "
<< msg << std::endl;
119
os_->width(0); os_->fill(
' '
);
120
}
121
else
{
122
osFile_->width(10); osFile_->fill(
'*'
);
123
*osFile_ << me_ <<
": "
<< val <<
" "
<< units_ <<
", "
<< msg << std::endl;
124
osFile_->width(0); osFile_->fill(
' '
);
125
}
126
}
127
}
128
129
private
:
130
131
int
me_;
132
std::ostream *os_;
133
std::ofstream *osFile_;
134
bool
iPrint_;
// I am printing metrics
135
bool
wePrint_;
// at least one process is printing metrics
136
std::string units_;
137
int
width_;
138
};
139
140
}
//namespace Zoltan2
141
142
#endif
MetricOutputManager::MetricOutputManager
MetricOutputManager(int rank, bool doPrinting, std::ofstream &Os, bool metricsOn, std::string units=std::string(""), int width=10)
Constructor for output to a file.
Definition
Zoltan2_MetricOutputManager.hpp:54
Zoltan2::MetricOutputManager::getMetricsOn
bool getMetricsOn() const
Return true if any process outputs metrics.
Definition
Zoltan2_MetricOutputManager.hpp:87
Zoltan2::MetricOutputManager::print
void print(const char *msg, T val)
A version of print that takes char to avoid the cost of converting char * to string.
Definition
Zoltan2_MetricOutputManager.hpp:114
Zoltan2::MetricOutputManager::MetricOutputManager
MetricOutputManager(int rank, bool doPrinting, std::ostream &Os, bool metricsOn, std::string units=std::string(""), int width=10)
Constructor for output to a stream.
Definition
Zoltan2_MetricOutputManager.hpp:71
Zoltan2::MetricOutputManager::~MetricOutputManager
~MetricOutputManager()
Destructor.
Definition
Zoltan2_MetricOutputManager.hpp:79
Zoltan2::MetricOutputManager::MetricOutputManager
MetricOutputManager(int rank, bool doPrinting, std::ofstream &Os, bool metricsOn, std::string units=std::string(""), int width=10)
Constructor for output to a file.
Definition
Zoltan2_MetricOutputManager.hpp:54
Zoltan2::MetricOutputManager::getOStream
std::ostream * getOStream() const
Return the output stream for messages.
Definition
Zoltan2_MetricOutputManager.hpp:83
Zoltan2::MetricOutputManager::print
void print(const std::string &msg, const T val)
Print a line of information.
Definition
Zoltan2_MetricOutputManager.hpp:93
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:47
core
src
environment
Zoltan2_MetricOutputManager.hpp
Generated by
1.17.0