From 654c35f70fb0dbc99398c042fcc5094648b2c70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kl=C3=B6fkorn?= <robertk@mathematik.uni-stuttgart.de> Date: Wed, 14 Apr 2010 12:58:09 +0000 Subject: [PATCH] also call STAR_Init and STAR_Finalize git-svn-id: https://dune.mathematik.uni-freiburg.de/svn/alugrid/trunk@1243 0d966ed9-3843-0410-af09-ebfb50bd7c74 --- src/parallel/mpAccess_STAR.cc | 13 +++++++++++++ src/parallel/mpAccess_STAR.h | 6 ++++++ src/starmpi.c | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/parallel/mpAccess_STAR.cc b/src/parallel/mpAccess_STAR.cc index 34ad558eb..c529c06ba 100644 --- a/src/parallel/mpAccess_STAR.cc +++ b/src/parallel/mpAccess_STAR.cc @@ -14,6 +14,9 @@ extern "C" { STAR_Allgatherv(void * send_buff, int send_count, MPI_Datatype send_type, void * recv_buff, int * recv_counts, int * disps, MPI_Datatype recv_type, MPI_Comm comm, int call_site_id); + + extern void InitializeStarMPI(); + extern void FinalizeStarMPI(); } #ifndef NDEBUG @@ -32,6 +35,16 @@ static int getNextCallSiteId() // workarround for old member variable #define _mpiComm (getMPICommunicator(_mpiCommPtr)) +void MpAccessSTAR_MPI :: initStarMPI() +{ + InitializeStarMPI(); +} + +MpAccessSTAR_MPI :: ~MpAccessSTAR_MPI () +{ + FinalizeStarMPI(); +} + // the last parameter is the `call_site_id`. Each call has to have its own unique // call_site_id diff --git a/src/parallel/mpAccess_STAR.h b/src/parallel/mpAccess_STAR.h index a11e61867..d1eae7b20 100644 --- a/src/parallel/mpAccess_STAR.h +++ b/src/parallel/mpAccess_STAR.h @@ -15,6 +15,8 @@ protected: int star_allgather (int *, int , int *, int) const ; int star_allgather (char *, int, char *, int) const ; int star_allgather (double *, int, double *, int ) const ; + + void initStarMPI(); public : // constructor taking MPI_Comm // to avoid MPI types here this is a template constructor @@ -22,8 +24,12 @@ public : inline MpAccessSTAR_MPI (MPICommunicator mpicomm ) : BaseType( mpicomm ) { + initStarMPI(); } + // destructor + ~MpAccessSTAR_MPI(); + // copy constructor inline MpAccessSTAR_MPI (const MpAccessSTAR_MPI &a ) : BaseType( a ) diff --git a/src/starmpi.c b/src/starmpi.c index c200751a4..dd828605e 100644 --- a/src/starmpi.c +++ b/src/starmpi.c @@ -9,6 +9,26 @@ extern "C" { // include STAR-MPI sources to compile object file #include <star-mpi.c> +void InitializeStarMPI() +{ + static int initialized = 0; + if( ! initialized ) + { + STAR_Init(); + initialized = 1; + } +} + +void FinalizeStarMPI() +{ + static int finalized = 0; + if( ! finalized ) + { + STAR_Finalize(); + finalized = 1; + } +} + #if defined(__cplusplus) } #endif -- GitLab