Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
parallel_progress.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3 * Author: Martin Rupp
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef PARALLEL_PROGRESS_H_
34#define PARALLEL_PROGRESS_H_
35
36#ifdef UG_PARALLEL
37
38#include <iostream>
40#include "common/log.h"
41#include <ctime>
42#include <string>
43#include <sstream>
44
45#include "common/stopwatch.h"
47
48namespace ug
49{
50
52{
53// int m_minSecondsUntilProgress;
54 double startS;
55public:
57
59 {
60 stop();
61 }
62 void set_length(int l)
63 {
64 m_length = l;
65 }
66
72 void start(double total, std::string msg, size_t numProc);
73
74 inline void set(size_t now)
75 {
76 if(now < iNextValueToUpdate) return;
77 setD(now);
78 }
79 inline void set(int now)
80 {
81 if(now < 0 || (size_t)now < iNextValueToUpdate) return;
82 setD(now);
83 }
84
85 inline void set(double now)
86 {
87 if(now < dNextValueToUpdate) return;
88 setD(now);
89 }
90 void setD(double now);
91
92 void stop();
93private:
96 int posNow;
97 double m_total;
98 double m_now;
100 std::string m_msg;
101};
102
103}
104
105#define PARALLEL_PROGRESS_START(progVarName, dSize, msg, numProcs) \
106 ug::ParallelProgress progVarName; { std::stringstream ss; ss << msg; progVarName.start(dSize, ss.str(), numProcs); }
107
108#define PARALLEL_PROGRESS_UPDATE(progVarName, d) progVarName.set(d);
109#define PARALLEL_PROGRESS_FINISH(progVarName) progVarName.stop();
110
111
112#endif
113
114#endif /* PARALLEL_PROGRESS_H_ */
Definition parallel_progress.h:52
void stop()
Definition parallel_progress.cpp:70
int m_length
Definition parallel_progress.h:99
void set(size_t now)
Definition parallel_progress.h:74
void start(double total, std::string msg, size_t numProc)
Definition parallel_progress.cpp:75
double m_now
Definition parallel_progress.h:98
ParallelProgress()
Definition parallel_progress.cpp:40
double startS
Definition parallel_progress.h:54
void set(int now)
Definition parallel_progress.h:79
size_t iNextValueToUpdate
Definition parallel_progress.h:95
double dNextValueToUpdate
Definition parallel_progress.h:94
void setD(double now)
Definition parallel_progress.cpp:55
std::string m_msg
Definition parallel_progress.h:100
void set_length(int l)
Definition parallel_progress.h:62
void calc_next_value()
Definition parallel_progress.h:67
double m_total
Definition parallel_progress.h:97
~ParallelProgress()
Definition parallel_progress.h:58
void set(double now)
Definition parallel_progress.h:85
int posNow
Definition parallel_progress.h:96
the ug namespace
stopwatch class for quickly taking times