Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jakub.both/dune-common
  • samuel.burbulla/dune-common
  • patrick.jaap/dune-common
  • tobias.leibner/dune-common
  • alexander.mueller/dune-common
  • pipping/dune-common
  • Xinyun.Li/dune-common
  • felix.schindler/dune-common
  • simon.praetorius/dune-common
  • ani.anciaux-sedrakian/dune-common
  • henrik.stolzmann/dune-common
  • matthew.t.collins/dune-common
  • liam.keegan/dune-common
  • felix.mueller/dune-common
  • ansgar/dune-common
  • dominic/dune-common
  • lars.lubkoll/dune-common
  • exadune/dune-common
  • felix.gruber/dune-common
  • govind.sahai/dune-common
  • michael.sghaier/dune-common
  • core/dune-common
  • kilian.weishaupt/dune-common
  • markus.blatt/dune-common
  • joscha.podlesny/dune-common
  • tobias.meyer.andersen/dune-common
  • andreas.thune/dune-common
  • lars.bilke/dune-common
  • daniel.kienle/dune-common
  • lukas.renelt/dune-common
  • smuething/dune-common
  • stephan.hilb/dune-common
  • tkoch/dune-common
  • nils.dreier/dune-common
  • rene.milk/dune-common
  • lasse.hinrichsen/dune-common
  • yunus.sevinchan/dune-common
  • lisa_julia.nebel/dune-common
  • claus-justus.heine/dune-common
  • lorenzo.cerrone/dune-common
  • eduardo.bueno/dune-common
41 results
Show changes
Commits on Source (28)
{
"analyze": [
"--disable", "default",
"--analyzers=clang-tidy",
"--file=*/dune-common/*.cc",
"--skip", ".codechecker/skipfile",
"--disable", "clang-diagnostic-deprecated-copy",
"--disable", "clang-diagnostic-unused"
],
"parse": [
"--file=*/dune-common/*"
]
}
SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
-*/densematrixassignmenttest.cc
-*/genericiterator_compile_fail.cc
-*/check_fvector_size_fail.cc
-*/assertandreturntest.cc
SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
......@@ -8,6 +8,17 @@ DuneModuleDependencies
Macros to extract dependencies between Dune modules by inspecting the
``dune.module`` files.
.. cmake:command:: dune_check_module_version
.. code-block:: cmake
dune_check_module_version(<dune-module> VERSION <version-requirement>)
Check that the version of a dune module `<dune-module>` is compatible with
`<version-requirement>`. Notice that the `dune_module_information` macro is
invoked with the dune.module file of `<dune-module>`, thus, the variables for
`<dune-module>_VERSION` are populated here.
.. cmake:command:: dune_create_dependency_tree
.. code-block:: cmake
......@@ -34,6 +45,60 @@ include(DuneEnableAllPackages)
include(DuneModuleInformation)
include(DuneUtilities)
# checks that a module version is compatible with the found version of a module
# notice that this has the side effect of populating the ${module}_VERSION information
macro(dune_check_module_version module)
cmake_parse_arguments(DUNE_VCHECK "" "VERSION" "" ${ARGN})
if(DUNE_VCHECK_VERSION MATCHES "(>=|=|<=).*")
string(REGEX REPLACE "(>=|=|<=)(.*)" "\\1" DUNE_VCHECK_VERSION_OP ${DUNE_VCHECK_VERSION})
string(REGEX REPLACE "(>=|=|<=)(.*)" "\\2" DUNE_VCHECK_VERSION_NUMBER ${DUNE_VCHECK_VERSION})
string(STRIP ${DUNE_VCHECK_VERSION_NUMBER} DUNE_VCHECK_VERSION_NUMBER)
extract_major_minor_version("${DUNE_VCHECK_VERSION_NUMBER}" DUNE_VCHECK_VERSION)
set(DUNE_VCHECK_VERSION_STRING "${DUNE_VCHECK_VERSION_MAJOR}.${DUNE_VCHECK_VERSION_MINOR}.${DUNE_VCHECK_VERSION_REVISION}")
else()
set(DUNE_VCHECK_VERSION_STRING "0.0.0")
endif()
unset(${module}_dune_module)
foreach(_dune_module_file
${${module}_PREFIX}/dune.module
${${module}_PREFIX}/lib/dunecontrol/${module}/dune.module
${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module)
if(EXISTS ${_dune_module_file})
get_filename_component(_dune_module_file_path ${_dune_module_file} PATH)
dune_module_information(${_dune_module_file_path})# QUIET)
set(${module}_dune_module 1)
set(DUNE_VCHECK_MOD_VERSION_STRING "${DUNE_VERSION_MAJOR}.${DUNE_VERSION_MINOR}.${DUNE_VERSION_REVISION}")
# check whether dependency matches version requirement
unset(module_version_wrong)
if(DUNE_VCHECK_VERSION_OP MATCHES ">=")
if(NOT (DUNE_VCHECK_MOD_VERSION_STRING VERSION_EQUAL DUNE_VCHECK_VERSION_STRING OR
DUNE_VCHECK_MOD_VERSION_STRING VERSION_GREATER DUNE_VCHECK_VERSION_STRING))
set(module_version_wrong 1)
endif()
elseif(DUNE_VCHECK_VERSION_OP MATCHES "<=")
if(NOT (DUNE_VCHECK_MOD_VERSION_STRING VERSION_EQUAL DUNE_VCHECK_VERSION_STRING OR
DUNE_VCHECK_MOD_VERSION_STRING VERSION_LESS DUNE_VCHECK_VERSION_STRING))
set(module_version_wrong 1)
endif()
elseif(DUNE_VCHECK_VERSION_OP MATCHES "=" AND
NOT (DUNE_VCHECK_MOD_VERSION_STRING VERSION_EQUAL DUNE_VCHECK_VERSION_STRING))
set(module_version_wrong 1)
endif()
endif()
endforeach()
if(NOT ${module}_dune_module)
message(${_warning_level} "Could not find dune.module file for module ${module} "
"in ${${module}_PREFIX}, ${${module}_PREFIX}/lib/dunecontrol/${module}/, "
"${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module")
set(${module}_FOUND OFF)
endif()
if(module_version_wrong)
message(${_warning_level} "Could not find requested version of module ${module}. "
"Requested version was ${DUNE_FIND_VERSION}, found version is ${DUNE_FIND_MOD_VERSION_STRING}")
set(${module}_FOUND OFF)
endif()
endmacro(dune_check_module_version module)
macro(dune_create_dependency_tree)
if(dune-common_MODULE_PATH)
......@@ -152,15 +217,6 @@ macro(find_dune_package module)
set(_warning_level "WARNING")
set_package_properties(${module} PROPERTIES TYPE OPTIONAL)
endif()
if(DUNE_FIND_VERSION MATCHES "(>=|=|<=).*")
string(REGEX REPLACE "(>=|=|<=)(.*)" "\\1" DUNE_FIND_VERSION_OP ${DUNE_FIND_VERSION})
string(REGEX REPLACE "(>=|=|<=)(.*)" "\\2" DUNE_FIND_VERSION_NUMBER ${DUNE_FIND_VERSION})
string(STRIP ${DUNE_FIND_VERSION_NUMBER} DUNE_FIND_VERSION_NUMBER)
extract_major_minor_version("${DUNE_FIND_VERSION_NUMBER}" DUNE_FIND_VERSION)
set(DUNE_FIND_VERSION_STRING "${DUNE_FIND_VERSION_MAJOR}.${DUNE_FIND_VERSION_MINOR}.${DUNE_FIND_VERSION_REVISION}")
else()
set(DUNE_FIND_VERSION_STRING "0.0.0")
endif()
if(NOT ${module}_FOUND)
if(NOT (${module}_DIR OR ${module}_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*${module}.*"))
......@@ -219,45 +275,7 @@ macro(find_dune_package module)
endif()
if(${module}_FOUND)
# parse other module's dune.module file to generate variables for config.h
unset(${module}_dune_module)
foreach(_dune_module_file
${${module}_PREFIX}/dune.module
${${module}_PREFIX}/lib/dunecontrol/${module}/dune.module
${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module)
if(EXISTS ${_dune_module_file})
get_filename_component(_dune_module_file_path ${_dune_module_file} PATH)
dune_module_information(${_dune_module_file_path})# QUIET)
set(${module}_dune_module 1)
set(DUNE_FIND_MOD_VERSION_STRING "${DUNE_VERSION_MAJOR}.${DUNE_VERSION_MINOR}.${DUNE_VERSION_REVISION}")
# check whether dependency matches version requirement
unset(module_version_wrong)
if(DUNE_FIND_VERSION_OP MATCHES ">=")
if(NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING OR
DUNE_FIND_MOD_VERSION_STRING VERSION_GREATER DUNE_FIND_VERSION_STRING))
set(module_version_wrong 1)
endif()
elseif(DUNE_FIND_VERSION_OP MATCHES "<=")
if(NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING OR
DUNE_FIND_MOD_VERSION_STRING VERSION_LESS DUNE_FIND_VERSION_STRING))
set(module_version_wrong 1)
endif()
elseif(DUNE_FIND_VERSION_OP MATCHES "=" AND
NOT (DUNE_FIND_MOD_VERSION_STRING VERSION_EQUAL DUNE_FIND_VERSION_STRING))
set(module_version_wrong 1)
endif()
endif()
endforeach()
if(NOT ${module}_dune_module)
message(${_warning_level} "Could not find dune.module file for module ${module} "
"in ${${module}_PREFIX}, ${${module}_PREFIX}/lib/dunecontrol/${module}/, "
"${${module}_PREFIX}/lib64/dunecontrol/${module}/dune.module")
set(${module}_FOUND OFF)
endif()
if(module_version_wrong)
message(${_warning_level} "Could not find requested version of module ${module}. "
"Requested version was ${DUNE_FIND_VERSION}, found version is ${DUNE_FIND_MOD_VERSION_STRING}")
set(${module}_FOUND OFF)
endif()
dune_check_module_version(${module} VERSION ${DUNE_FIND_VERSION})
else(${module}_FOUND)
if(required)
message(FATAL_ERROR "Could not find required module ${module}.")
......
......@@ -62,6 +62,11 @@ include(OverloadCompilerFlags)
# Don't forget to call finalize_dune_project afterwards.
macro(dune_project)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
message(DEPRECATION "The function `dune_project` shall only be called on CMake project root directory.
Note that CMake projects may be nested: https://cmake.org/cmake/help/latest/command/project.html.")
endif()
# check if CXX flag overloading has been enabled (see OverloadCompilerFlags.cmake)
initialize_compiler_script()
......
......@@ -82,17 +82,19 @@ namespace Dune
void sync();
/**
* @brief Synce the index set and assign local numbers to new indices
* @brief Sync the index set and assign local numbers to new indices
*
* Computes the missing indices in the local and the remote index list and adds them.
* No global communication is necessary!
* @param numberer Functor providing the local indices for the added global indices.
* has to provide a function size_t operator()(const TG& global) that provides the
* local index to a global one. It will be called for ascending global indices.
* @param useFixedOrder Flag indicating if the new indices should be created
* in a fixed order. If set to true, this makes the runs reproducible but might slow down performance.
*
*/
template<typename T1>
void sync(T1& numberer);
void sync(T1& numberer, bool useFixedOrder = false);
private:
......@@ -358,9 +360,11 @@ namespace Dune
/**
* @brief Recv and unpack the message from another process and add the indices.
* @param numberer Functor providing local indices for added global indices.
* @param hardSource process of message to be received.
* @param useHardSource Flag indicating if hardSource should be used or not. If set to true, this makes the runs reproducible but might slow down performance.
*/
template<typename T1>
void recvAndUnpack(T1& numberer);
void recvAndUnpack(T1& numberer, int hardSource, bool useHardSource);
/**
* @brief Register the MPI datatype for the MessageInformation.
......@@ -733,7 +737,7 @@ namespace Dune
template<typename T>
template<typename T1>
void IndicesSyncer<T>::sync(T1& numberer)
void IndicesSyncer<T>::sync(T1& numberer, bool useFixedOrder)
{
// The pointers to the local indices in the remote indices
// will become invalid due to the resorting of the index set.
......@@ -805,7 +809,7 @@ namespace Dune
// Probe for incoming messages, receive and unpack them
for(std::size_t i = 0; i<noOldNeighbours; ++i)
recvAndUnpack(numberer);
recvAndUnpack(numberer, oldNeighbours[i], useFixedOrder);
// }else{
// recvAndUnpack(oldNeighbours[i], numberer);
// packAndSend(oldNeighbours[i]);
......@@ -1003,7 +1007,7 @@ namespace Dune
template<typename T>
template<typename T1>
void IndicesSyncer<T>::recvAndUnpack(T1& numberer)
void IndicesSyncer<T>::recvAndUnpack(T1& numberer, int hardSource, bool useHardSource)
{
const ParallelIndexSet& constIndexSet = indexSet_;
auto iEnd = constIndexSet.end();
......@@ -1016,7 +1020,8 @@ namespace Dune
MPI_Status status;
// We have to determine the message size and source before the receive
MPI_Probe(MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status);
MPI_Probe(useHardSource ? hardSource : MPI_ANY_SOURCE, 345, remoteIndices_.communicator(), &status);
int source=status.MPI_SOURCE;
int count;
......
......@@ -240,26 +240,50 @@ namespace Dune
* ...
* }
* \endcode
*
* The MPIHelper will be globally initialized on its first call.
* Afterwards, all arguments to this function will be ignored.
*
* @param argc The number of arguments provided to main.
* @param argv The arguments provided to main.
*/
DUNE_EXPORT static MPIHelper& instance(int& argc, char**& argv)
{
// create singleton instance
if (!instance_){
static std::mutex mutex;
std::lock_guard<std::mutex> guard(mutex);
if(!instance_)
instance_.reset(new MPIHelper(argc,argv));
}
return *instance_;
return instance(&argc, &argv);
}
DUNE_EXPORT static MPIHelper& instance()
/**
* @brief Get the singleton instance of the helper.
*
* This method can be called either without any arguments,
* or with the same arguments that the main method of the
* program was called, passed as pointer:
* \code
* int main(int argc, char** argv){
* MPIHelper::instance();
* // or: MPIHelper::instance(&argc, &argv);
* // program code comes here
* ...
* }
* \endcode
*
* The MPIHelper will be globally initialized on its first call.
* Afterwards, all arguments to this function will be ignored.
*
* @note This overload accepts all arguments by pointer similar
* to the `MPI_Init` function and allows to pass `nullptr` for
* all arguments.
*
* @relates instance(int&, char**&)
*
* @param argc The number of arguments provided to main.
* @param argv The arguments provided to main.
*/
DUNE_EXPORT static MPIHelper& instance(int* argc = nullptr, char*** argv = nullptr)
{
if(!instance_)
DUNE_THROW(InvalidStateException, "MPIHelper not initialized! Call MPIHelper::instance(argc, argv) with arguments first.");
return *instance_;
assert((argc == nullptr) == (argv == nullptr));
static MPIHelper instance{argc, argv};
return instance;
}
/**
......@@ -289,10 +313,9 @@ namespace Dune
int size_;
bool initializedHere_;
void prevent_warning(int){}
static inline std::unique_ptr<MPIHelper> instance_ = {};
//! \brief calls MPI_Init with argc and argv as parameters
MPIHelper(int& argc, char**& argv)
MPIHelper(int* argc, char*** argv)
: initializedHere_(false)
{
int wasInitialized = -1;
......@@ -301,7 +324,7 @@ namespace Dune
{
rank_ = -1;
size_ = -1;
static int is_initialized = MPI_Init(&argc, &argv);
static int is_initialized = MPI_Init(argc, argv);
prevent_warning(is_initialized);
initializedHere_ = true;
}
......
......@@ -274,7 +274,7 @@ find_modules_in_path() {
while read m; do
test -n "$m" && parse_control "$m"
done <<EOFM
$(find -H "$dir" -name $CONTROL | $GREP -v 'dune-[-_a-zA-Z]/dune-[-a-zA-Z_]*-[0-9]\{1,\}.[0-9]\{1,\}/')
$(find -H "$dir" -type d -name .git -prune -o -name $CONTROL -print | $GREP -v 'dune-[-_a-zA-Z]/dune-[-a-zA-Z_]*-[0-9]\{1,\}.[0-9]\{1,\}/')
EOFM
else
parse_control "$dir"
......
......@@ -26,8 +26,6 @@ PYBIND11_MODULE( _common, module )
Dune::Python::registerDynamicVector<double>(module);
Dune::Python::registerDynamicMatrix<double>(module);
int argc = 0;
char **argv = NULL;
Dune::MPIHelper::instance(argc,argv);
Dune::MPIHelper::instance();
Dune::Python::registerCommunication(module);
}