Commit 59499f1a by Christophe Geuzaine

restore progress meter for meshing (and simply disable it for now when multi-threaded)

parent f51de010
Pipeline #271 passed with stage
in 8 minutes 50 seconds
......@@ -230,9 +230,7 @@ std::map<std::string, std::string> &Msg::GetCommandLineStrings()
void Msg::SetProgressMeterStep(int step)
{
#if defined(_OPENMP)
#pragma omp critical
#endif
if(GetCommRank() || GetNumThreads() > 1) return;
_progressMeterStep = step;
}
......@@ -243,7 +241,8 @@ int Msg::GetProgressMeterStep()
void Msg::ResetProgressMeter()
{
if (!_commRank) _progressMeterCurrent = 0;
if(GetCommRank() || GetNumThreads() > 1) return;
_progressMeterCurrent = 0;
}
void Msg::SetInfoCpu(bool val)
......@@ -295,10 +294,13 @@ onelab::client *Msg::GetOnelabClient()
void Msg::Exit(int level)
{
if (GModel::current())
if(GModel::current())
delete GModel::current();
// delete the temp file
if(!_commRank) UnlinkFile(CTX::instance()->homeDir + CTX::instance()->tmpFileName);
if(!GetCommRank())
UnlinkFile(CTX::instance()->homeDir + CTX::instance()->tmpFileName);
if(_logFile){
fclose(_logFile);
_logFile = 0;
......@@ -330,7 +332,7 @@ void Msg::Exit(int level)
#if defined(HAVE_FLTK)
// if we exit cleanly (level==0) and we are in full GUI mode, save
// the persistent info to disk
if(FlGui::available() && !_commRank) {
if(FlGui::available() && !GetCommRank()) {
if(CTX::instance()->sessionSave)
PrintOptions(0, GMSH_SESSIONRC, 0, 0,
(CTX::instance()->homeDir + CTX::instance()->sessionFileName).c_str());
......@@ -479,7 +481,7 @@ void Msg::Fatal(const char *fmt, ...)
c0 = "\33[1m\33[31m"; c1 = "\33[0m"; // bold red
}
if(_commSize > 1)
fprintf(stderr, "%sFatal : [rank %3d] %s%s\n", c0, _commRank, str, c1);
fprintf(stderr, "%sFatal : [rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
else
fprintf(stderr, "%sFatal : %s%s\n", c0, str, c1);
fflush(stderr);
......@@ -494,7 +496,7 @@ void Msg::Error(const char *fmt, ...)
_errorCount++;
_atLeastOneErrorInRun = 1;
if(_verbosity < 1) return;
if(GetVerbosity() < 1) return;
char str[5000];
va_list args;
......@@ -524,7 +526,7 @@ void Msg::Error(const char *fmt, ...)
c0 = "\33[1m\33[31m"; c1 = "\33[0m"; // bold red
}
if(_commSize > 1)
fprintf(stderr, "%sError : [rank %3d] %s%s\n", c0, _commRank, str, c1);
fprintf(stderr, "%sError : [rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
else
fprintf(stderr, "%sError : %s%s\n", c0, str, c1);
fflush(stderr);
......@@ -535,7 +537,7 @@ void Msg::Warning(const char *fmt, ...)
{
_warningCount++;
if(_verbosity < 2) return;
if(GetVerbosity() < 2) return;
char str[5000];
va_list args;
......@@ -564,7 +566,7 @@ void Msg::Warning(const char *fmt, ...)
c0 = "\33[35m"; c1 = "\33[0m"; // magenta
}
if(_commSize > 1)
fprintf(stderr, "%sWarning : [rank %3d] %s%s\n", c0, _commRank, str, c1);
fprintf(stderr, "%sWarning : [rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
else
fprintf(stderr, "%sWarning : %s%s\n", c0, str, c1);
fflush(stderr);
......@@ -573,7 +575,7 @@ void Msg::Warning(const char *fmt, ...)
void Msg::Info(const char *fmt, ...)
{
if(_verbosity < 4) return;
if(GetVerbosity() < 4) return;
char str[5000];
va_list args;
......@@ -600,7 +602,7 @@ void Msg::Info(const char *fmt, ...)
if(CTX::instance()->terminal){
if(_commSize > 1)
fprintf(stdout, "Info : [rank %3d] %s\n", _commRank, str);
fprintf(stdout, "Info : [rank %3d] %s\n", GetCommRank(), str);
else
fprintf(stdout, "Info : %s\n", str);
fflush(stdout);
......@@ -614,7 +616,7 @@ void Msg::RequestRender()
void Msg::Direct(const char *fmt, ...)
{
if(_verbosity < 3) return;
if(GetVerbosity() < 3) return;
char str[5000];
va_list args;
......@@ -641,7 +643,7 @@ void Msg::Direct(const char *fmt, ...)
c0 = "\33[34m"; c1 = "\33[0m"; // blue
}
if(_commSize > 1)
fprintf(stdout, "%s[rank %3d] %s%s\n", c0, _commRank, str, c1);
fprintf(stdout, "%s[rank %3d] %s%s\n", c0, GetCommRank(), str, c1);
else
fprintf(stdout, "%s%s%s\n", c0, str, c1);
fflush(stdout);
......@@ -650,7 +652,7 @@ void Msg::Direct(const char *fmt, ...)
void Msg::StatusBar(bool log, const char *fmt, ...)
{
if(_verbosity < 4) return;
if(GetVerbosity() < 4) return;
char str[5000];
va_list args;
......@@ -664,13 +666,13 @@ void Msg::StatusBar(bool log, const char *fmt, ...)
}
if(_logFile) fprintf(_logFile, "Info: %s\n", str);
if(_callback && log) (*_callback)("Info", str);
if(_callback && log) (*_callback)("Progress", str);
if(_client && log) _client->Info(str);
#if defined(HAVE_FLTK)
if(FlGui::available()){
if(log) FlGui::instance()->check();
if(!log || _verbosity > 4)
if(!log || GetVerbosity() > 4)
FlGui::instance()->setStatus(str);
if(log){
std::string tmp = std::string("Info : ") + str;
......@@ -681,7 +683,7 @@ void Msg::StatusBar(bool log, const char *fmt, ...)
if(log && CTX::instance()->terminal){
if(_commSize > 1)
fprintf(stdout, "Info : [rank %3d] %s\n", _commRank, str);
fprintf(stdout, "Info : [rank %3d] %s\n", GetCommRank(), str);
else
fprintf(stdout, "Info : %s\n", str);
fflush(stdout);
......@@ -691,7 +693,7 @@ void Msg::StatusBar(bool log, const char *fmt, ...)
void Msg::StatusGl(const char *fmt, ...)
{
#if defined(HAVE_FLTK)
if(_commRank) return;
if(GetCommRank()) return;
char str[5000];
va_list args;
va_start(args, fmt);
......@@ -713,7 +715,7 @@ void Msg::SetWindowTitle(const std::string &title)
void Msg::Debug(const char *fmt, ...)
{
if(_verbosity < 99) return;
if(GetVerbosity() < 99) return;
char str[5000];
va_list args;
......@@ -734,7 +736,7 @@ void Msg::Debug(const char *fmt, ...)
if(CTX::instance()->terminal){
if(_commSize > 1)
fprintf(stdout, "Debug : [rank %3d] %s\n", _commRank, str);
fprintf(stdout, "Debug : [rank %3d] %s\n", GetCommRank(), str);
else
fprintf(stdout, "Debug : %s\n", str);
fflush(stdout);
......@@ -743,7 +745,7 @@ void Msg::Debug(const char *fmt, ...)
void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...)
{
if(_commRank || _verbosity < 4 ||
if(GetCommRank() || GetNumThreads() > 1 || GetVerbosity() < 4 ||
_progressMeterStep <= 0 || _progressMeterStep >= 100) return;
double percent = 100. * (double)n/(double)N;
......@@ -761,7 +763,7 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...)
if(_client) _client->Progress(str2);
#if defined(HAVE_FLTK)
if(FlGui::available() && _verbosity > 4){
if(FlGui::available() && GetVerbosity() > 4){
FlGui::instance()->check();
FlGui::instance()->setProgress(str, (n > N - 1) ? 0 : n, 0, N);
}
......@@ -773,9 +775,6 @@ void Msg::ProgressMeter(int n, int N, bool log, const char *fmt, ...)
(n > N - 1) ? "" : str2);
fflush(stdout);
}
//#if defined(_OPENMP)
//#pragma omp barrier
//#endif
}
}
......@@ -794,7 +793,7 @@ void Msg::PrintTimers()
if(CTX::instance()->terminal){
if(_commSize > 1)
fprintf(stdout, "Timers : [rank %3d] %s\n", _commRank, str.c_str());
fprintf(stdout, "Timers : [rank %3d] %s\n", GetCommRank(), str.c_str());
else
fprintf(stdout, "Timers : %s\n", str.c_str());
fflush(stdout);
......@@ -812,19 +811,19 @@ void Msg::ResetErrorCounter()
void Msg::PrintErrorCounter(const char *title)
{
if(_commRank || _verbosity < 1) return;
if(!_warningCount && !_errorCount) return;
if(GetCommRank() || GetVerbosity() < 1) return;
if(!GetWarningCount() && !GetErrorCount()) return;
std::string prefix = _errorCount ? "Error : " : "Warning : ";
std::string prefix = GetErrorCount() ? "Error : " : "Warning : ";
std::string help("Check the full log for details");
std::string line(std::max(strlen(title), help.size()), '-');
char warn[128], err[128];
sprintf(warn, "%5d warning%s", _warningCount, _warningCount == 1 ? "" : "s");
sprintf(err, "%5d error%s", _errorCount, _errorCount == 1 ? "" : "s");
sprintf(warn, "%5d warning%s", GetWarningCount(), GetWarningCount() == 1 ? "" : "s");
sprintf(err, "%5d error%s", GetErrorCount(), GetErrorCount() == 1 ? "" : "s");
#if defined(HAVE_FLTK)
if(FlGui::available()){
std::string col = _errorCount ?
std::string col = GetErrorCount() ?
std::string(CTX::instance()->guiColorScheme ? "@B72@." : "@C1@.") :
std::string(CTX::instance()->guiColorScheme ? "@B152@." : "@C5@.");
FlGui::instance()->addMessage((col + prefix + line).c_str());
......@@ -833,14 +832,14 @@ void Msg::PrintErrorCounter(const char *title)
FlGui::instance()->addMessage((col + prefix + err).c_str());
FlGui::instance()->addMessage((col + prefix + help).c_str());
FlGui::instance()->addMessage((col + prefix + line).c_str());
if(_errorCount) fl_beep();
if(GetErrorCount()) fl_beep();
}
#endif
if(CTX::instance()->terminal){
const char *c0 = "", *c1 = "";
if(!streamIsFile(stderr) && streamIsVT100(stderr)){
c0 = _errorCount ? "\33[1m\33[31m" : "\33[35m"; // bold red or magenta
c0 = GetErrorCount() ? "\33[1m\33[31m" : "\33[35m"; // bold red or magenta
c1 = "\33[0m";
}
fprintf(stderr, "%s%s\n%s\n%s\n%s\n%s\n%s%s\n", c0, (prefix + line).c_str(),
......@@ -1575,6 +1574,8 @@ MsgProgressStatus::~MsgProgressStatus()
void MsgProgressStatus::next()
{
if(Msg::GetCommRank() || Msg::GetNumThreads() > 1) return;
++_currentI;
if (_currentI < _nextIToCheck) return;
......
......@@ -319,13 +319,13 @@ static void Mesh1D(GModel *m)
Msg::StatusBar(true, "Meshing 1D...");
double t1 = Cpu();
std::vector<GEdge*> temp;
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it){
(*it)->meshStatistics.status = GEdge::PENDING;
temp.push_back(*it);
}
Msg::ResetProgressMeter();
int nIter = 0, nTot = m->getNumEdges();
......@@ -346,9 +346,9 @@ static void Mesh1D(GModel *m)
nPending++;
}
}
// if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 1D...");
if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 1D...");
}
if(!nPending) break;
if(nIter++ > 10) break;
}
......@@ -486,7 +486,7 @@ static void Mesh2D(GModel *m)
nPending++;
}
}
// if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 2D...");
if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 2D...");
}
#if defined(_OPENMP)
#pragma omp master
......@@ -519,7 +519,7 @@ static void Mesh2D(GModel *m)
#endif
nPending++;
}
// if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 2D...");
if(!nIter) Msg::ProgressMeter(nPending, nTot, false, "Meshing 2D...");
}
if(!nPending) break;
if(nIter++ > 10) break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment