Commit 9574ac18 authored by Douglas Serson's avatar Douglas Serson
Browse files

Merge branch 'fix/parallel_assert' into 'master'

Fix/parallel assert

This MR fixes a bug in the iterative solver whereby the assertion on exceeding the maximum number of iterations is only effected on the root process. This also updates the NekError class to print messages on the root process only, rather than on all processes.

See merge request !636
parents 4e657335 c17f617c
......@@ -13,6 +13,8 @@ v4.3.2
- Fix minor performance issue with time integration schemes (!632)
- Fix FilterCheckpoint filter to be consistent with `IO_CheckSteps` (!633)
- Fix `IO_CheckSteps` to avoid missing first checkpoint (!639)
- Fix bug in iterative solver where only root process would ASSERT when
exceeding the maximum number of iterations (!636)
**FieldConvert**:
- Fix appearence of duplicate messages when running in parallel (!626)
......
......@@ -41,6 +41,10 @@
#include <boost/optional.hpp>
#include <LibUtilities/LibUtilitiesDeclspec.h>
#if defined(NEKTAR_USE_MPI)
#include <mpi.h>
#endif
#ifndef _WIN32
#include <execinfo.h>
#endif
......@@ -63,7 +67,7 @@ namespace ErrorUtil
{
efatal,
ewarning
};
};
class NekError : public std::runtime_error
{
......@@ -86,6 +90,18 @@ namespace ErrorUtil
#endif
msg;
// Default rank is zero. If MPI used and initialised, populate with
// the correct rank. Messages are only printed on rank zero.
int rank = 0;
#if defined(NEKTAR_USE_MPI)
int flag;
MPI_Initialized(&flag);
if(flag)
{
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
}
#endif
std::string btMessage("");
#if defined(NEKTAR_FULLDEBUG)
#ifndef _WIN32
......@@ -103,10 +119,13 @@ namespace ErrorUtil
free(btStrings);
#endif
#endif
switch(type)
switch (type)
{
case efatal:
if( outStream )
case efatal:
if (!rank)
{
if (outStream)
{
(*outStream) << btMessage;
(*outStream) << "Fatal : " << baseMsg << std::endl;
......@@ -114,14 +133,22 @@ namespace ErrorUtil
else
{
std::cerr << btMessage;
std::cerr << std::endl << "Fatal : " << baseMsg << std::endl;
std::cerr << std::endl << "Fatal : " << baseMsg
<< std::endl;
}
throw NekError(baseMsg);
break;
case ewarning:
if( outStream )
}
#if defined(NEKTAR_USE_MPI)
if (flag)
{
MPI_Barrier(MPI_COMM_WORLD);
}
#endif
throw NekError(baseMsg);
break;
case ewarning:
if (!rank)
{
if (outStream)
{
(*outStream) << btMessage;
(*outStream) << "Warning: " << baseMsg << std::endl;
......@@ -131,10 +158,10 @@ namespace ErrorUtil
std::cerr << btMessage;
std::cerr << "Warning: " << baseMsg << std::endl;
}
break;
default:
std::cerr << "Unknown warning type: " << baseMsg << std::endl;
}
break;
default:
std::cerr << "Unknown warning type: " << baseMsg << std::endl;
}
}
......
......@@ -473,9 +473,9 @@ namespace Nektar
<< " (error = " << sqrt(eps/m_rhs_magnitude)
<< ", rhs_mag = " << sqrt(m_rhs_magnitude) << ")"
<< endl;
ASSERTL0(false,
"Exceeded maximum number of iterations");
}
ASSERTL0(false,
"Exceeded maximum number of iterations");
}
// Compute new search direction p_k, q_k
......
......@@ -53,6 +53,9 @@ IF( ${CMAKE_SYSTEM} MATCHES "Darwin-*")
PROPERTIES LINK_FLAGS "-Wl,-undefined,dynamic_lookup -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${LIB_DIR} -Wl,-rpath,${Boost_LIBRARY_DIRS}")
ENDIF( ${CMAKE_SYSTEM} MATCHES "Darwin-*")
SET_TARGET_PROPERTIES(Tester
PROPERTIES COMPILE_FLAGS "-UNEKTAR_USE_MPI")
INSTALL(TARGETS Tester
RUNTIME DESTINATION ${NEKTAR_BIN_DIR} COMPONENT test OPTIONAL
ARCHIVE DESTINATION ${NEKTAR_LIB_DIR} COMPONENT test OPTIONAL
......
Supports Markdown
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