Commit 9284b5b6 authored by Praetorius, Simon's avatar Praetorius, Simon

output restricted to process 0 also in openmp mode

parent 31322270
......@@ -12,7 +12,6 @@ set(AMDIS_NEED_PNG @ENABLE_PNG@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)
......@@ -20,10 +19,14 @@ add_library(AMDiS ALIAS amdis_base)
target_compile_definitions(amdis_base INTERFACE)
if (AMDIS_NEED_CXX11)
target_enable_cxx11(AMDIS_NEED_CXX11 amdis_base INTERFACE)
if (NOT AMDIS_NEED_CXX11)
target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE)
if (NOT SUPPORTS_CXX14)
target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE)
endif ()
if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14)
message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
endif (NOT AMDIS_NEED_CXX11)
endif ()
target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1)
else ()
target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0)
......
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
macro(target_enable_cxx14 RESULT_VAR _TARGET_ _SCOPE_)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14_FLAG)
set(CXX14_CODE "
auto f() { return 1; }
int main(){
auto f1 = [](auto const& y) { return y; };
auto y0 = f();
auto y1 = f1(1);
}")
if (COMPILER_SUPPORTS_CXX14_FLAG)
set(CMAKE_REQUIRED_FLAGS "-std=c++14")
check_cxx_source_compiles("${CXX14_CODE}" CXX14_COMPILES_WITH_CXX14_FLAG)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
if (COMPILER_SUPPORTS_CXX14_FLAG AND CXX14_COMPILES_WITH_CXX14_FLAG)
target_compile_options(${_TARGET_} ${_SCOPE_} "-std=c++14")
set(${RESULT_VAR} true CACHE BOOL "Enable C++14 compiler features" FORCE)
else ()
check_cxx_source_compiles("${CXX14_CODE}" CXX14_COMPILES)
if (CXX14_COMPILES)
set(${RESULT_VAR} true CACHE BOOL "Enable C++14 compiler features" FORCE)
else ()
set(${RESULT_VAR} false CACHE BOOL "Enable C++14 compiler features" FORCE)
endif ()
endif ()
endmacro(target_enable_cxx14)
macro(target_enable_cxx11 RESULT_VAR _TARGET_ _SCOPE_)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11_FLAG)
......
......@@ -115,7 +115,7 @@ namespace AMDiS {
Parameters::init(initFileName);
}
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) || defined(HAVE_OPENMP)
Parameters::get("parallel->log main rank", Msg::outputMainRank);
#endif
......
......@@ -75,8 +75,7 @@ namespace AMDiS {
virtual void initialize(Flag initFlag,
ProblemStatSeq *adoptProblem = NULL,
Flag adoptFlag = INIT_NOTHING)
{ FUNCNAME("CouplingProblemStat::initialize()");
{
super::initialize(initFlag - INIT_MESH);
const Flag DEFAULT_INIT = (INIT_FE_SPACE | INIT_MESH | CREATE_MESH | INIT_SYSTEM | INIT_SOLVER | INIT_ESTIMATOR | INIT_MARKER | INIT_FILEWRITER);
......@@ -130,7 +129,7 @@ namespace AMDiS {
problems[i]->componentMeshes.resize(nComponents + nAddComponents);
for (size_t j = 0; j < nComponents + nAddComponents; j++) {
for (int j = 0; j < nComponents + nAddComponents; j++) {
// name of the mesh
std::string meshName("");
Parameters::get(problems[i]->getName() + "->mesh", meshName);
......@@ -186,7 +185,7 @@ namespace AMDiS {
problems[p]->componentSpaces.resize(nComponents + nAddComponents, NULL);
problems[p]->traverseInfo.resize(nComponents);
for (size_t i = 0; i < nComponents + nAddComponents; i++) {
for (int i = 0; i < nComponents + nAddComponents; i++) {
std::string componentString = "[" + to_string(i) + "]";
......
......@@ -32,11 +32,14 @@
#ifdef HAVE_PARALLEL_PETSC
#include "petsc.h"
#endif
#ifdef HAVE_OPENMP
#include <omp.h>
#endif
namespace AMDiS {
const char *funcName = NULL;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) || defined(HAVE_OPENMP)
bool Msg::outputMainRank = true;
#endif
......@@ -133,6 +136,10 @@ namespace AMDiS {
if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
return;
#endif
#ifdef HAVE_OPENMP
if (outputMainRank && omp_get_thread_num() != 0)
return;
#endif
if (!out)
out = &std::cout;
......@@ -224,6 +231,10 @@ namespace AMDiS {
if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
return;
#endif
#ifdef HAVE_OPENMP
if (outputMainRank && omp_get_thread_num() != 0)
return;
#endif
static int old_line = -1;
......@@ -257,6 +268,10 @@ namespace AMDiS {
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) && defined(NDEBUG)
if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
return;
#endif
#ifdef HAVE_OPENMP
if (outputMainRank && omp_get_thread_num() != 0)
return;
#endif
va_list arg;
char buff[255];
......@@ -278,6 +293,10 @@ namespace AMDiS {
if (outputMainRank && MPI::COMM_WORLD.Get_rank() != 0)
return;
#endif
#ifdef HAVE_OPENMP
if (outputMainRank && omp_get_thread_num() != 0)
return;
#endif
va_list arg;
char buff[255];
......
......@@ -133,6 +133,8 @@ namespace AMDiS {
#else
#if HAVE_PARALLEL_DOMAIN_AMDIS
#define PRINT_LINE(stream, line) stream << "[" << MPI::COMM_WORLD.Get_rank() << "] " << line
#elif defined(HAVE_OPENMP)
#define PRINT_LINE(stream, line) stream << "[" << omp_get_thread_num() << "] " << line
#else
#define PRINT_LINE(stream, line) stream << line
#endif
......@@ -331,7 +333,7 @@ namespace AMDiS {
}
public:
#if HAVE_PARALLEL_DOMAIN_AMDIS
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) || defined(HAVE_OPENMP)
/// In parallel computations, when this variable is true, only the 0 rank will
/// print messages to the output stream. Error messages and warnings are always
/// printed from all ranks.
......
......@@ -201,8 +201,7 @@ namespace AMDiS
{
std::tuple<Terms...> term_tuple;
template <class... Terms_>
LazyOperatorTerms(Terms_... terms_)
LazyOperatorTerms(Terms const&... terms_)
: term_tuple(terms_...)
{ }
......@@ -249,8 +248,7 @@ namespace AMDiS
F f; ///< the functor
template <class... Terms_>
FunctionN(F const& f_, Terms_... terms_)
FunctionN(F const& f_, Terms const&... terms_)
: super(terms_...), f(f_) {}
// call f.getDegree() function
......@@ -404,7 +402,7 @@ namespace AMDiS
template<typename F, typename... Terms>
inline typename result_of::FunctionN<F, Terms...>::type
function_(F const& f, Terms... ts)
function_(F const& f, Terms const&... ts)
{
return expressions::FunctionN<F, typename traits::to_expr<Terms>::to::type...>
(f, traits::to_expr<Terms>::to::get(ts)...);
......@@ -412,7 +410,7 @@ namespace AMDiS
template<typename F, typename... Terms>
inline typename result_of::FunctionN<F, Terms...>::type
func(F const& f, Terms... ts)
func(F const& f, Terms const&... ts)
{
return expressions::FunctionN<F, typename traits::to_expr<Terms>::to::type...>
(f, traits::to_expr<Terms>::to::get(ts)...);
......@@ -420,7 +418,7 @@ namespace AMDiS
template<typename F, typename Term0, typename... Terms>
inline typename result_of::FunctionN<F, Term0, Terms...>::type
eval(F const& f, Term0 t0, Terms... ts)
eval(F const& f, Term0 t0, Terms const&... ts)
{
return expressions::FunctionN<F, typename traits::to_expr<Term0>::to::type,
typename traits::to_expr<Terms>::to::type...>
......
......@@ -212,7 +212,7 @@ namespace AMDiS
/// Expressions that extracts the vector-value of a Vector<DOFVector> at QPs
template<template<class> class Vector, typename T, typename Name>
template<template<class...> class Vector, typename T, typename Name>
struct ValueOf<Vector<DOFVector<T>*>, Name,
typename boost::enable_if<typename traits::is_vector<Vector<T> >::type>::type >
: public LazyOperatorTermBase
......@@ -224,7 +224,12 @@ namespace AMDiS
mutable mtl::dense_vector<value_type> vec;
mutable Vector<mtl::dense_vector<T> > coeff;
ValueOf(Vector<DOFVector<T>*>& vector) : vecDV(vector)
ValueOf(Vector<DOFVector<T>*> const& vector) : vecDV(vector)
{
resize(coeff, num_rows(vecDV));
}
ValueOf(Vector<DOFVector<T>*>&& vector) : vecDV(std::move(vector))
{
resize(coeff, num_rows(vecDV));
}
......@@ -232,7 +237,7 @@ namespace AMDiS
template<typename List>
inline void insertFeSpaces(List& feSpaces) const
{
for (size_t i = 0; i < num_rows(vecDV); i++)
for (size_t i = 0; i < size_t(num_rows(vecDV)); i++)
feSpaces.insert(at(vecDV, i)->getFeSpace());
}
......@@ -247,7 +252,7 @@ namespace AMDiS
const BasisFunction *basisFct = NULL)
{
Vector<mtl::dense_vector<T> > helper; resize(helper, num_rows(vecDV));
for (size_t i = 0; i < num_rows(vecDV); i++) {
for (size_t i = 0; i < size_t(num_rows(vecDV)); i++) {
if (ot && subAssembler)
ot->getVectorAtQPs(at(vecDV, i), elInfo, subAssembler, quad, at(helper, i));
else if (quad)
......@@ -269,7 +274,7 @@ namespace AMDiS
vec.change_dim(num_rows(at(helper, 0)));
for (size_t iq = 0; iq < num_rows(at(helper, 0)); iq++) {
value_type tmp; resize(tmp, num_rows(vecDV));
for (size_t i = 0; i < num_rows(vecDV); i++)
for (size_t i = 0; i < size_t(num_rows(vecDV)); i++)
at(tmp, i) = at(helper, i)[iq];
vec[iq] = tmp;
}
......@@ -415,7 +420,7 @@ namespace AMDiS
valueOf(Matrix<DOFVector<T>*> &mat)
{ return expressions::ValueOf<Matrix<DOFVector<T>*>, _unknown >(mat); }
template<template<class> class Vector, typename T>
template<template<class...> class Vector, typename T>
typename boost::enable_if<typename traits::is_vector<Vector<T> >::type,
expressions::ValueOf<Vector<DOFVector<T>*>, _unknown > >::type
valueOf(Vector<DOFVector<T>*> &vector)
......
......@@ -20,7 +20,7 @@ namespace AMDiS { namespace io {
ZLIB = 1, // zlib compression
BZIP2 = 2 // bzip2 compression
} Value;
};
}
namespace Macroformat
{
......@@ -29,7 +29,7 @@ namespace AMDiS { namespace io {
PT_MACROFILE = 1, // pointer to macro file
SELF = 2 // pointer to this file, at the end of this file
} Value;
};
}
typedef enum{SI08, SI16, SI32, SI64, UI08, UI16, UI32, UI64, SF32, SF64} Valformat;
......
......@@ -112,7 +112,7 @@ namespace vector_operations {
{
typename ValueType<Vector>::type value;
nullify(value);
for (size_t i = 0; i < num_rows(b); ++i)
for (size_t i = 0; i < size_t(num_rows(b)); ++i)
value += sqr(b[i]);
return std::sqrt(value);
}
......
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