Skip to content
Snippets Groups Projects
Commit 69250432 authored by Simon Heybrock's avatar Simon Heybrock
Browse files

Re #19246. Initialize MPI environment by default so tests pass.

parent e8aa2793
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,6 @@
#include <boost/mpi/environment.hpp>
#endif
#ifdef MPI_EXPERIMENTAL
#include <boost/mpi/environment.hpp>
#endif
#include "MantidAPI/DllConfig.h"
#include "MantidAPI/FileLoaderRegistry.h"
#include "MantidKernel/SingletonHolder.h"
......@@ -133,9 +129,6 @@ private:
int argc = 0;
char **argv;
#endif
#ifdef MPI_EXPERIMENTAL
boost::mpi::environment m_mpi_environment;
#endif
};
typedef Mantid::Kernel::SingletonHolder<FrameworkManagerImpl> FrameworkManager;
......
......@@ -529,10 +529,7 @@ public:
static AlgorithmMPITest *createSuite() { return new AlgorithmMPITest(); }
static void destroySuite(AlgorithmMPITest *suite) { delete suite; }
AlgorithmMPITest() {
Mantid::API::FrameworkManager::Instance();
AnalysisDataService::Instance();
}
AlgorithmMPITest() { AnalysisDataService::Instance(); }
void testNoParallelism() {
runNoParallelism(Parallel::Communicator{});
......
......@@ -57,6 +57,7 @@ if ( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
endif ( MPI_BUILD )
endif ()
set ( MPI_EXPERIMENTAL OFF CACHE BOOL "Enable MPI options" )
if ( MPI_EXPERIMENTAL )
include ( BoostMPI )
endif ()
......
......@@ -66,9 +66,6 @@ public:
static void destroySuite(TableWorkspacePropertyTest *suite) { delete suite; }
TableWorkspacePropertyTest() {
// Calls MPI_Init if applicable, for running algorithms in MPI builds.
Mantid::API::FrameworkManager::Instance();
t.reset(new TableWorkspace(10));
t->addColumn("str", "Name");
t->addColumn("int", "Nunber");
......
......@@ -93,8 +93,6 @@ public:
static void destroySuite(WorkspaceCreationTest *suite) { delete suite; }
WorkspaceCreationTest() {
// Calls MPI_Init, if applicable.
Mantid::API::FrameworkManager::Instance();
// 1 bank, 2x2 pixels, IDs 4,5,6,7
m_instrument =
ComponentCreationHelper::createTestInstrumentRectangular(1, 2);
......
......@@ -12,10 +12,17 @@
#include <boost/mpi/communicator.hpp>
#endif
namespace boost {
namespace mpi {
class environment;
}
}
namespace Mantid {
namespace Parallel {
#ifdef MPI_EXPERIMENTAL
class ParallelRunner;
extern boost::mpi::environment environment;
#endif
/** Wrapper for boost::mpi::communicator. For non-MPI builds an equivalent
......
#include "MantidParallel/Communicator.h"
#ifdef MPI_EXPERIMENTAL
#include <boost/mpi/environment.hpp>
#endif
namespace Mantid {
namespace Parallel {
#ifdef MPI_EXPERIMENTAL
boost::mpi::environment environment;
#endif
#ifdef MPI_EXPERIMENTAL
Communicator::Communicator(const boost::mpi::communicator &comm)
: m_communicator(comm) {}
......
......@@ -152,12 +152,19 @@ if ( WIN32 ) #.lib -> .dll
string ( REPLACE "/lib/" "/bin/" NEXUSLIB ${NEXUSLIB} )
string ( REPLACE ".lib" ".dll" NEXUSLIB ${NEXUSLIB} )
endif()
set ( MPISETUP_PY mpisetup )
if ( MPI_EXPERIMENTAL )
set ( IMPORT_MPI_IN_PYTHON True )
endif()
# Build version
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGESETUP_PY}.py.in ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGESETUP_PY}.py )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/${MPISETUP_PY}.py.in ${CMAKE_CURRENT_BINARY_DIR}/${MPISETUP_PY}.py )
# Copy py to build directory, taking care of multi-config (MSVC) builds
copy_files_to_dir ( ${PACKAGESETUP_PY}.py ${CMAKE_CURRENT_BINARY_DIR} ${OUTPUT_DIR}
PYTHON_INSTALL_FILES )
copy_files_to_dir ( ${MPISETUP_PY}.py ${CMAKE_CURRENT_BINARY_DIR} ${OUTPUT_DIR}
PYTHON_INSTALL_FILES )
# Package version
if ( WIN32 OR APPLE )
......@@ -166,6 +173,7 @@ if ( WIN32 OR APPLE )
set ( NEXUSLIB ../../${NEXUSLIB_FILE} )
endif()
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGESETUP_PY}.py.in ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGESETUP_PY}.install.py )
configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/${MPISETUP_PY}.py.in ${CMAKE_CURRENT_BINARY_DIR}/${MPISETUP_PY}.install.py )
#############################################################################################
# Create the target for this directory
......
......@@ -8,6 +8,9 @@ Defines Python objects that wrap the C++ Kernel namespace.
from __future__ import (absolute_import, division,
print_function)
# Imports boost.mpi if applicable
from . import mpisetup
###############################################################################
# Load the C++ library
###############################################################################
......
# For MPI builds we need to import boost.mpi to initialize the MPI environment.
# The environment is also instantiated in C++ but that does seem to lead to
# issues (probably related to how Ubuntu builds their MPI and Python packages).
if ${IMPORT_MPI_IN_PYTHON}:
import boost.mpi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment