aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2004-01-08 16:35:06 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2004-01-08 16:35:06 +0000
commitda21e9d54195198c75d0b7aaedc1d6a76ee2483f (patch)
tree12195e905074922e424f94caab141908f4a40e3a
parent9ed5893de41742d85535cf4f6745b521a2a42740 (diff)
Fokke Dijkstra's patch: Added new routine PUGH_SetTopology() which can be called
by other thorns to overwrite PUGH's manual topology parameter settings. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@428 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/SetupPGH.c92
-rw-r--r--src/include/pugh.h2
2 files changed, 88 insertions, 6 deletions
diff --git a/src/SetupPGH.c b/src/SetupPGH.c
index 42ad163..dd4d854 100644
--- a/src/SetupPGH.c
+++ b/src/SetupPGH.c
@@ -29,11 +29,29 @@ CCTK_FILEVERSION(CactusPUGH_PUGH_SetupPGH_c)
/********************************************************************
+ ********************* External Routines **********************
+ ********************************************************************/
+int PUGH_SetTopology (int dim, const int topology[]);
+
+
+/********************************************************************
********************* Internal Routines **********************
********************************************************************/
static int Setup_nProcs (pGH *pughGH, int dim);
+/********************************************************************
+ ********************* Static Variables **********************
+ ********************************************************************/
+/* static integers which contain partition information if set */
+static int topology_1d_x = 0;
+static int topology_2d_x = 0;
+static int topology_2d_y = 0;
+static int topology_3d_x = 0;
+static int topology_3d_y = 0;
+static int topology_3d_z = 0;
+
+
/*@@
@routine PUGH_SetupPGH
@date Fri Feb 21 10:21:36 1997
@@ -289,6 +307,68 @@ void PUGH_DestroyPGH (pGH **GHin)
/*@@
+ @routine PUGH_SetTopology
+ @date Wed 02 Apr 2003
+ @author Fokke Dijkstra
+ @desc
+ Set/reset the static topology integer variables.
+
+ Note that using such static variables here instead of the
+ processor_topology_[123]d_[xyz] parameters is just a hack because
+ we don't want to make those steerable (this could make
+ people think they can change the processor topology at
+ runtime).
+ @enddesc
+
+ @var dim
+ @vdesc number of dimensions for the processor topology (1,2 or 3)
+ @vtype int
+ @vio in
+ @endvar
+ @var topology
+ @vdesc list with number of processors in the x,y and z direction
+ @vtype int[]
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0: OK
+ -1: invalid dimension
+ @endreturndesc
+@@*/
+int PUGH_SetTopology (int dim, const int topology[])
+{
+ int retval;
+
+
+ retval = 0;
+ if (dim == 1)
+ {
+ topology_1d_x = topology[0];
+ }
+ else if (dim == 2)
+ {
+ topology_2d_x = topology[0];
+ topology_2d_y = topology[1];
+ }
+ else if (dim == 3)
+ {
+ topology_3d_x = topology[0];
+ topology_3d_y = topology[1];
+ topology_3d_z = topology[2];
+ }
+ else
+ {
+ CCTK_WARN (1, "Only 1D, 2D, and 3D supported");
+ retval = -1;
+ }
+
+ return (retval);
+}
+
+
+ /*@@
@routine PUGH_SetupDefaultTopology
@date Sun 23 Jan 1999
@author Gabrielle Allen
@@ -323,16 +403,16 @@ int PUGH_SetupDefaultTopology (int dim, int nprocs[])
switch (dim)
{
case 1:
- nprocs[0] = processor_topology_1d_x;
+ nprocs[0] = topology_1d_x ? topology_1d_x : processor_topology_1d_x;
break;
case 2:
- nprocs[0] = processor_topology_2d_x;
- nprocs[1] = processor_topology_2d_y;
+ nprocs[0] = topology_2d_x ? topology_2d_x : processor_topology_2d_x;
+ nprocs[1] = topology_2d_y ? topology_2d_y : processor_topology_2d_y;
break;
case 3:
- nprocs[0] = processor_topology_3d_x;
- nprocs[1] = processor_topology_3d_y;
- nprocs[2] = processor_topology_3d_z;
+ nprocs[0] = topology_3d_x ? topology_3d_x : processor_topology_3d_x;
+ nprocs[1] = topology_3d_y ? topology_3d_y : processor_topology_3d_y;
+ nprocs[2] = topology_3d_z ? topology_3d_z : processor_topology_3d_z;
break;
default:
memset (nprocs, 0, dim * sizeof (int));
diff --git a/src/include/pugh.h b/src/include/pugh.h
index c0398d0..50d581a 100644
--- a/src/include/pugh.h
+++ b/src/include/pugh.h
@@ -172,6 +172,8 @@ int PUGH_Exit(cGH *GH, int retval);
const int *PUGH_Topology(const cGH *GH, int dim);
+int PUGH_SetTopology (int dim, const int topology[]);
+
#ifdef CCTK_MPI
MPI_Datatype PUGH_MPIDataType (const pGH *pughGH, int cctk_type);
#endif