Skip to content

Commit

Permalink
consolidate global_parallel with global.
Browse files Browse the repository at this point in the history
  • Loading branch information
mabruzzo committed Nov 3, 2023
1 parent 4c84b31 commit 023a35d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 45 deletions.
20 changes: 20 additions & 0 deletions src/global/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ int Sgn(Real x)
}
}

// global mpi-related variables (they are declared here because they are initialized even when
// the MPI_CHOLLA variable is not defined)

int procID; /*process rank*/
int nproc; /*number of processes in global comm*/
int root; /*rank of root process*/

/* Used when MPI_CHOLLA is not defined to initialize a subset of the global mpi-related variables
* that still meaningful in non-mpi simulations.
*/
void Init_Global_Parallel_Vars_No_MPI()
{
#ifdef MPI_CHOLLA
CHOLLA_ERROR("This function should not be executed when compiled with MPI");
#endif
procID = 0;
nproc = 1;
root = 0;
}

/*! \fn char Trim(char *s)
* \brief Gets rid of trailing and leading whitespace. */
char *Trim(char *s)
Expand Down
14 changes: 14 additions & 0 deletions src/global/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ extern double Get_Time(void);
* \brief Mathematical sign function. Returns sign of x. */
extern int Sgn(Real x);

/* Global variables for mpi (but they are also initialized to sensible defaults when not using mpi)
*
* It may make sense to move these back into mpi_routines (but reorganizing the ifdef statements
* would take some work). It may make sense to also put these into their own namespace.
*/
extern int procID; /*process rank*/
extern int nproc; /*number of processes executing simulation*/
extern int root; /*rank of root process*/

/* Used when MPI_CHOLLA is not defined to initialize a subset of the global mpi-related variables
* that still meaningful in non-mpi simulations.
*/
void Init_Global_Parallel_Vars_No_MPI();

struct Parameters {
int nx;
int ny;
Expand Down
19 changes: 0 additions & 19 deletions src/global/global_parallel.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/global/global_parallel.h

This file was deleted.

3 changes: 1 addition & 2 deletions src/mpi/mpi_routines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
#include <tuple>

#include "../global/global.h"
#include "../global/global_parallel.h"
#include "../io/io.h"
#include "../mpi/cuda_mpi_routines.h"
#include "../utils/error_handling.h"

/*Global MPI Variables*/
// note: some relevant global variables are declared in global_parallel.h
// note: some relevant global variables are declared in global.h

int procID_node; /*process rank on node*/
int nproc_node; /*number of MPI processes on node*/
Expand Down
8 changes: 5 additions & 3 deletions src/mpi/mpi_routines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <utility>

#include "../global/global.h"
#include "../global/global_parallel.h"
#include "../grid/grid3D.h"

#ifdef FFTW
Expand All @@ -16,8 +15,11 @@
#endif /*FFTW*/

/*Global MPI Variables*/
// NOTE: some variable heavily used by mpi are declared in global_parallel.h
// so that they are defined even when compiled without mpi
// NOTE: some variable heavily used by mpi are declared in global.h so that they are defined even
// when compiled without mpi

extern int procID_node; /*process rank on node*/
extern int nproc_node; /*number of MPI processes on node*/

extern MPI_Comm world; /*global communicator*/
extern MPI_Comm node; /*communicator for each node*/
Expand Down

0 comments on commit 023a35d

Please sign in to comment.