diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake index da3225866785c75a8cf73e6aa78b6e3e0eea42f9..91e48d73f4c79ccc6a7258071dbbfeaf8a27a1c6 100644 --- a/cmake/modules/DuneCodegenMacros.cmake +++ b/cmake/modules/DuneCodegenMacros.cmake @@ -116,6 +116,11 @@ function(dune_add_generated_executable) message(FATAL_ERROR "Unrecognized arguments in dune_add_generated_executable. This usually indicates a typo.") endif() + set(MPI_OPTION "0") + if(MPI_FOUND) + set(MPI_OPTION "1") + endif() + # Apply defaults and enforce requirements if(NOT GEN_TARGET) message(FATAL_ERROR "Need to specify the TARGET parameter for dune_add_generated_executable") @@ -139,6 +144,7 @@ function(dune_add_generated_executable) --target-name ${GEN_TARGET} --driver-file ${GEN_SOURCE} --project-basedir ${CMAKE_BINARY_DIR} + --with-mpi ${MPI_OPTION} ${GEN_FORM_COMPILER_ARGS} DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_CODEGEN_ADDITIONAL_PYTHON_SOURCES} COMMENT "Generating driver for the target ${GEN_TARGET}" @@ -199,6 +205,7 @@ function(dune_add_generated_executable) --ini-file ${GEN_INIFILE} --target-name ${GEN_TARGET} --operator-to-build ${op} + --with-mpi ${MPI_OPTION} ${ANALYZE_GRID_OPTION} DEPENDS ${GEN_UFLFILE} ${UFL2PDELAB_SOURCES} ${GEN_DEPENDS} ${DUNE_CODEGEN_ADDITIONAL_PYTHON_SOURCES} ${ANALYZE_GRID_FILE} COMMENT "Generating operator file ${depdata___${op}} for the target ${GEN_TARGET}" diff --git a/python/dune/codegen/options.py b/python/dune/codegen/options.py index 97f3ce47af0d543141672b08f1e837cbc2ff0cc6..4f743d6485038a570cba0a55f26538d7e6f53765 100644 --- a/python/dune/codegen/options.py +++ b/python/dune/codegen/options.py @@ -58,6 +58,7 @@ class CodegenGlobalOptionsArray(ImmutableRecord): debug_interpolate_input = CodegenOption(default=False, helpstr="Should the input for printresidual and printmatix be interpolated (instead of random input).") use_likwid = CodegenOption(default=False, helpstr="Use likwid instead of own performance measurements.") autotune_google_benchmark = CodegenOption(default=False, helpstr="Use google-benchmark library for autotuning (when autotuning is activated).") + with_mpi = CodegenOption(default=True, helpstr="The module was configured with mpi") # Arguments that are mainly to be set by logic depending on other options max_vector_width = CodegenOption(default=256, helpstr=None) diff --git a/python/dune/codegen/pdelab/driver/__init__.py b/python/dune/codegen/pdelab/driver/__init__.py index 50effdf1f6730c8a6241292b3dd8375e7d472f4c..0b8058ed4a516c0340bc0e61d2ddd969b813761d 100644 --- a/python/dune/codegen/pdelab/driver/__init__.py +++ b/python/dune/codegen/pdelab/driver/__init__.py @@ -215,7 +215,10 @@ def name_initree(): @preamble(section="init") def define_mpihelper(name): include_file("dune/common/parallel/mpihelper.hh", filetag="driver") - return "Dune::MPIHelper& {} = Dune::MPIHelper::instance(argc, argv);".format(name) + if get_option("with_mpi"): + return "Dune::MPIHelper& {} = Dune::MPIHelper::instance(argc, argv);".format(name) + else: + return "Dune::FakeMPIHelper& {} = Dune::FakeMPIHelper::instance(argc, argv);".format(name) def name_mpihelper():