mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#ifndef OPENMC_MESSAGE_PASSING_H
|
|
#define OPENMC_MESSAGE_PASSING_H
|
|
|
|
#include <cstdint>
|
|
|
|
#ifdef OPENMC_MPI
|
|
#include <mpi.h>
|
|
#endif
|
|
|
|
#include "openmc/vector.h"
|
|
|
|
namespace openmc {
|
|
namespace mpi {
|
|
|
|
extern int rank;
|
|
extern int n_procs;
|
|
extern bool master;
|
|
|
|
#ifdef OPENMC_MPI
|
|
extern MPI_Datatype source_site;
|
|
extern MPI_Datatype collision_track_site;
|
|
extern MPI_Comm intracomm;
|
|
#endif
|
|
|
|
//==============================================================================
|
|
// Template struct used to map types to MPI datatypes
|
|
// By having a single static data member, the template can
|
|
// be specialized for each type we know of. The specializations appear in the
|
|
// .cpp file since they are definitions.
|
|
//==============================================================================
|
|
#ifdef OPENMC_MPI
|
|
template<typename T>
|
|
struct MPITypeMap {
|
|
static const MPI_Datatype mpi_type;
|
|
};
|
|
#endif
|
|
|
|
// Calculates global indices of the bank particles
|
|
// across all ranks using a parallel scan. This is used to write
|
|
// the surface source file in parallel runs. It will probably
|
|
// be used in the future for other types of bank like particles
|
|
// in flight used to kick off transient simulations.
|
|
//
|
|
// More abstractly, this just takes a number from each MPI rank,
|
|
// and returns a vector which is the exclusive parallel scan across
|
|
// all of those numbers, having a length of the number of MPI ranks
|
|
// plus one.
|
|
vector<int64_t> calculate_parallel_index_vector(int64_t size);
|
|
|
|
} // namespace mpi
|
|
} // namespace openmc
|
|
|
|
#endif // OPENMC_MESSAGE_PASSING_H
|