aboutsummaryrefslogtreecommitdiff
path: root/src/pugh_ProcTop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pugh_ProcTop.c')
-rw-r--r--src/pugh_ProcTop.c169
1 files changed, 0 insertions, 169 deletions
diff --git a/src/pugh_ProcTop.c b/src/pugh_ProcTop.c
deleted file mode 100644
index 4ea8da8..0000000
--- a/src/pugh_ProcTop.c
+++ /dev/null
@@ -1,169 +0,0 @@
- /*@@
- @file pugh_ProcTop.c
- @date Sat Oct 16 20:10:02 CEST 1999
- @author Paul Walker
- @desc
- Set up the processor topology for different GH dimensions
- @enddesc
- @version $Header$
- @@*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-
-#include "pugh.h"
-
-void ProcTop3D(int np, int *nproc);
-void ProcTop1D(int np, int *nproc);
-
-static char *rcsid = "$Header$";
-
-
- /*@@
- @routine ProcTop
- @date Thu May 1 10:13:40 1997
- @author Paul Walker
- @desc
- Figures out a reasonable processor topology for a square
- grid on n processors. That is, it figures out a,b,c such
- that a*b*c = n and a,b, and c are in some senses minimal.
- <p>
- This algorithm will not guarantee the minimal condition,
- or at least I can't prove it does, but it seems to on
- a wide variety of processor numbers. So stop being a
- weenie - not everything needs a proof!
- <p>
- Thie came to me in the shower, and is much better than
- the old way I was doing it. I'm considering having my
- working environment be the shower for the rest of time,
- but there are some problems waterproofing my workstation.
- @enddesc
- @calledby SetupPGH
-@@*/
-
-void ProcTop(int np, int dim, int *nproc)
-{
-
- /* Set up processor topology information */
- switch (dim)
- {
- case 1:
- ProcTop1D(np, nproc);
- break;
- case 3:
- ProcTop3D(np, nproc);
- break;
- default:
- CCTK_WARN(0,"PUGH can't cope with this dimension grid yet");
- return;
- }
-
-}
-
-void ProcTop3D(int np, int *nproc)
-{
- DECLARE_CCTK_PARAMETERS
-
- int r,dim;
- int *dir;
-
- dim = 3;
-
- dir = (int *)malloc(dim*sizeof(int));
-
- if (CCTK_Equals(proc_topology,"manual"))
- {
- dir[0] = proc_top_nz;
- dir[1] = proc_top_ny;
- dir[2] = proc_top_nx;
- if (dir[0] * dir[1] * dir[2] != np)
- {
- fprintf (stderr,
- "Manual processor topology error. %d x %d x %d != %d\n",
- dir[0],dir[1],dir[2],np);
-#ifdef MPI
- CACTUS_MPI_ERROR(MPI_Finalize());
-#endif
- exit(0);
- }
- }
- else
- {
- dir[2] = (int)(pow(np,1.0/3.0)+0.0001);
- while (np % dir[2] != 0) dir[2]--;
- r = np / dir[2];
- dir[1] = (int)(sqrt(r)+0.0001);
- while (r % dir[1] != 0) dir[1]--;
- dir[0] = r / dir[1];
-
-#ifdef THORN_CARTOON_2D
- if (Contains("cartoon_active","yes"))
- {
- dir[2] = (int)(sqrt(np)+0.0001);
- while (np % dir[2] != 0) dir[2]--;
- dir[1] = 1;
- dir[0] = np / dir[2];
- }
-#endif
-
- if (dir[0] * dir[1] * dir[2] != np)
- {
- printf ("FATAL ERROR in Processor Topology\n");
- printf ("This should never happen. Please report ASAP!\n");
- exit(0);
- }
- }
-
- /* NB: PW reverses these for better alignment of comm groups */
-
- nproc[2] = dir[0];
- nproc[1] = dir[1];
- nproc[0] = dir[2];
-
- free(dir);
-}
-
-void ProcTop1D(int np, int *nproc)
-{
-
- DECLARE_CCTK_PARAMETERS
-
- int dim;
- int *dir;
-
- dim = 1;
-
- dir = (int *)malloc(dim*sizeof(int));
-
- if (CCTK_Equals(proc_topology,"manual"))
- {
- dir[0] = proc_top_nx;
- if (dir[0] != np)
- {
- fprintf (stderr,
- "Manual processor topology error. %d != %d\n",
- dir[0],np);
-#ifdef MPI
- CACTUS_MPI_ERROR(MPI_Finalize());
-#endif
- exit(0);
- }
-
- }
- else
- {
- dir[0] = np;
- }
-
- nproc[0] = dir[0];
-
- free(dir);
-
-}
-
-
-