Move mpi-related definitions into message_passing.h

This commit is contained in:
Paul Romano 2018-04-20 07:02:59 -05:00
parent 9b8cb2e0f1
commit 25b1001558
6 changed files with 39 additions and 15 deletions

View file

@ -437,6 +437,7 @@ set(LIBOPENMC_CXX_SRC
src/initialize.cpp
src/hdf5_interface.h
src/hdf5_interface.cpp
src/message_passing.cpp
src/random_lcg.cpp
src/random_lcg.h
src/simulation.cpp

View file

@ -4,9 +4,6 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef OPENMC_MPI
#include "mpi.h"
#endif
#ifdef __cplusplus
extern "C" {
@ -150,11 +147,6 @@ extern "C" {
extern bool openmc_simulation_initialized;
extern int openmc_verbosity;
#ifdef OPENMC_MPI
// MPI variables
extern MPI_Comm openmc_intracomm;
#endif
// Run modes
constexpr int RUN_MODE_FIXEDSOURCE {1};
constexpr int RUN_MODE_EIGENVALUE {2};

View file

@ -9,7 +9,7 @@
#include "hdf5_hl.h"
#ifdef OPENMC_MPI
#include "mpi.h"
#include "openmc.h"
#include "message_passing.h"
#endif
#include "error.h"
@ -163,7 +163,7 @@ file_open(const char* filename, char mode, bool parallel)
if (parallel) {
// Setup file access property list with parallel I/O access
plist = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_fapl_mpio(plist, openmc_intracomm, MPI_INFO_NULL);
H5Pset_fapl_mpio(plist, openmc::mpi::intracomm, MPI_INFO_NULL);
}
#endif

View file

@ -1,17 +1,15 @@
#include "openmc.h"
#ifdef OPENMC_MPI
MPI_Comm openmc_intracomm;
#endif
#include "message_passing.h"
int
openmc_init(const void* intracomm)
{
#ifdef OPENMC_MPI
openmc_intracomm = *static_cast<const MPI_Comm *>(intracomm);
openmc::mpi::intracomm = *static_cast<const MPI_Comm *>(intracomm);
MPI_Fint fcomm = MPI_Comm_c2f(openmc_intracomm);
MPI_Fint fcomm = MPI_Comm_c2f(openmc::mpi::intracomm);
openmc_init_f(&fcomm);
#else
openmc_init_f(nullptr);

15
src/message_passing.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "message_passing.h"
namespace openmc {
namespace mpi {
int rank;
int n_procs;
#ifdef OPENMC_MPI
MPI_Comm intracomm;
MPI_Datatype bank;
#endif
} // namespace mpi
} // namespace openmc

18
src/message_passing.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef MESSAGE_PASSING_H
#define MESSAGE_PASSING_H
namespace openmc {
namespace mpi {
extern int rank;
extern int n_procs;
#ifdef OPENMC_MPI
extern MPI_Datatype bank;
extern MPI_Comm intracomm;
#endif
} // namespace mpi
} // namespace openmc
#endif // MESSAGE_PASSING_H