From ce1bd89ec14535514c529b28c381a3c3e841526b Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 1 Dec 2003 22:50:36 +0000 Subject: Bug was discovered by Fokke Dijkstra: manual partitioning settings was applied to both grid function and grid array variables. Should be done only for grid functions, of course. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@424 b61c5cb5-eaca-4651-9a7a-d64986f99364 --- src/LoadAware.c | 21 ++++-- src/SetupGroup.c | 24 ++---- src/SetupPGH.c | 2 +- src/SetupPGV.c | 207 +++++++++++++--------------------------------------- src/include/pugh.h | 3 +- src/include/pughi.h | 9 ++- 6 files changed, 79 insertions(+), 187 deletions(-) diff --git a/src/LoadAware.c b/src/LoadAware.c index e1f04ec..cd31e18 100644 --- a/src/LoadAware.c +++ b/src/LoadAware.c @@ -133,6 +133,11 @@ int PUGH_SetPartitionInfo (int dim, const char *partition_info[]) @enddesc @calls PUGH_GetSliceSizes + @var is_gf + @vdesc flag indicating that bounds are to be set up for a grid function + @vtype int + @vio in + @endvar @var dim @vdesc dimension to set up bounds for @vtype int @@ -160,7 +165,7 @@ int PUGH_SetPartitionInfo (int dim, const char *partition_info[]) -1: invalid dimension @endreturndesc @@*/ -int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) +int PUGH_GetBounds (int is_gf, int dim, int *bounds[], int nprocs[], int nsize[]) { DECLARE_CCTK_PARAMETERS int i, retval, manual, external_manual; @@ -176,7 +181,7 @@ int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) partition_info = external_manual ? (const char *) partition_1D[0] : partition_1d_x; PUGH_GetSliceSizes (nprocs[0], nsize[0], partition_info, &bounds[0], - manual || external_manual); + is_gf && (manual || external_manual)); } else if (dim == 2) { @@ -184,12 +189,12 @@ int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) partition_info = external_manual ? (const char *) partition_2D[0] : partition_2d_x; PUGH_GetSliceSizes (nprocs[0], nsize[0], partition_info, &bounds[0], - manual || external_manual); + is_gf && (manual || external_manual)); external_manual = partition_2D[1] != NULL; partition_info = external_manual ? (const char *) partition_2D[1] : partition_2d_y; PUGH_GetSliceSizes (nprocs[1], nsize[1], partition_info, &bounds[1], - manual || external_manual); + is_gf && (manual || external_manual)); } else if (dim == 3) { @@ -197,21 +202,21 @@ int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) partition_info = external_manual ? (const char *) partition_3D[0] : partition_3d_x; PUGH_GetSliceSizes (nprocs[0], nsize[0], partition_info, &bounds[0], - manual || external_manual); + is_gf && (manual || external_manual)); external_manual = partition_3D[1] != NULL; partition_info = external_manual ? (const char *) partition_3D[1] : partition_3d_y; PUGH_GetSliceSizes (nprocs[1], nsize[1], partition_info, &bounds[1], - manual || external_manual); + is_gf && (manual || external_manual)); external_manual = partition_3D[2] != NULL; partition_info = external_manual ? (const char *) partition_3D[2] : partition_3d_z; PUGH_GetSliceSizes (nprocs[2], nsize[2], partition_info, &bounds[2], - manual || external_manual); + is_gf && (manual || external_manual)); } else { - if (manual) + if (is_gf && manual) { CCTK_WARN (1, "Only 1D, 2D, and 3D supported in manual topology setup"); retval = -1; diff --git a/src/SetupGroup.c b/src/SetupGroup.c index 1e91bc4..79c4da0 100644 --- a/src/SetupGroup.c +++ b/src/SetupGroup.c @@ -159,14 +159,8 @@ static int PUGH_SetupGAGroup (pGH *newGH, connectivity = PUGH_SetupConnectivity (dim, newGH->nprocs, nprocs, perme); - extras = PUGH_SetupPGExtras (dim, - perme, - staggercode, - nsize, - ghostsize, - newGH->nprocs, - connectivity->nprocs, - newGH->myproc); + extras = PUGH_SetupPGExtras (0, dim, perme, staggercode, nsize, ghostsize, + newGH->nprocs, connectivity->nprocs, newGH->myproc); free (nprocs); free (perme); @@ -181,6 +175,7 @@ static int PUGH_SetupGAGroup (pGH *newGH, /* Set up the communication buffer used for all variables within this group. Note: only with allocated buffers we can have group communication. */ + groupcomm = NULL; if(newGH->commmodel == PUGH_ALLOCATEDBUFFERS) { groupcomm = PUGH_SetupGArrayGroupComm (newGH, @@ -191,22 +186,17 @@ static int PUGH_SetupGAGroup (pGH *newGH, vtype, extras); } - else - { - groupcomm = NULL; - } - - temp = (void ***) realloc (newGH->variables, (newGH->nvariables+n_variables) * - sizeof (void **)); + temp = realloc (newGH->variables, (newGH->nvariables+n_variables) * + sizeof (void **)); if(temp) { newGH->variables = temp; for (variable = 0; variable < n_variables; variable++) { - newGH->variables[newGH->nvariables] = (void **) malloc (n_timelevels * - sizeof (void *)); + newGH->variables[newGH->nvariables] = malloc (n_timelevels * + sizeof (void *)); if (newGH->variables[newGH->nvariables]) { diff --git a/src/SetupPGH.c b/src/SetupPGH.c index 174cd6c..42ad163 100644 --- a/src/SetupPGH.c +++ b/src/SetupPGH.c @@ -128,7 +128,7 @@ pGH *PUGH_SetupPGH (void *callerid, nprocs, perme); free(nprocs); - pughGH->GFExtras[idim-1] = PUGH_SetupPGExtras (idim, perme, staggertype, + pughGH->GFExtras[idim-1] = PUGH_SetupPGExtras (1, idim, perme, staggertype, nsize, nghostzones, pughGH->nprocs, pughGH->Connectivity[idim-1]->nprocs, diff --git a/src/SetupPGV.c b/src/SetupPGV.c index a1554a8..4eca675 100644 --- a/src/SetupPGV.c +++ b/src/SetupPGV.c @@ -55,14 +55,9 @@ static int IntSort(const void *a, const void *b); @desc Sets up a PGExtras structure. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ -pGExtras *PUGH_SetupPGExtras(int dim, +pGExtras *PUGH_SetupPGExtras(int is_gf, + int dim, int *perme, int stagger, int *sh, @@ -74,7 +69,7 @@ pGExtras *PUGH_SetupPGExtras(int dim, int error; pGExtras *this; - this = (pGExtras *)malloc(sizeof(pGExtras)); + this = malloc(sizeof(pGExtras)); /* Setup memory */ if(this) @@ -89,7 +84,7 @@ pGExtras *PUGH_SetupPGExtras(int dim, this->dim = dim; - PUGH_SetupPGExtrasSizes(dim, perme, stagger, sh, nghosts, + PUGH_SetupPGExtrasSizes(is_gf, dim, perme, stagger, sh, nghosts, total_procs, nprocs, this_proc,this); PUGH_SetupPGExtrasOwnership(dim, perme, stagger, sh, nghosts, total_procs, nprocs, this_proc, this); @@ -109,12 +104,6 @@ pGExtras *PUGH_SetupPGExtras(int dim, @desc Destroys a PGExtras structure. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ void PUGH_DestroyPGExtras(pGExtras **PGExtras) { @@ -165,12 +154,6 @@ void PUGH_DestroyPGExtras(pGExtras **PGExtras) all the details of processor connectivities for this processor layout. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ pConnectivity *PUGH_SetupConnectivity(int dim, int total_procs, @@ -182,17 +165,17 @@ pConnectivity *PUGH_SetupConnectivity(int dim, int i; /* Allocate memory */ - this = (pConnectivity *)malloc(sizeof(pConnectivity)); + this = malloc(sizeof(pConnectivity)); if(this) { - this->nprocs = (int *)malloc(dim*sizeof(int)); - this->perme = (int *)malloc(dim*sizeof(int)); - this->neighbours = (int **)malloc(total_procs*sizeof(int *)); + this->nprocs = malloc(dim*sizeof(int)); + this->perme = malloc(dim*sizeof(int)); + this->neighbours = malloc(total_procs*sizeof(int *)); if(this->neighbours) { - this->neighbours[0] = (int *)malloc(total_procs*2*dim*sizeof(int)); + this->neighbours[0] = malloc(total_procs*2*dim*sizeof(int)); } else { @@ -253,12 +236,6 @@ pConnectivity *PUGH_SetupConnectivity(int dim, all the details of processor connectivities for this processor layout. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ void PUGH_DestroyConnectivity(pConnectivity **conn) { @@ -281,8 +258,6 @@ void PUGH_DestroyConnectivity(pConnectivity **conn) Generate the appropriate processor topology for this processor decomposition. @enddesc - @calls - @calledby @history @hdate Tue Jan 30 17:04:50 2001 @hauthor Tom Goodale @hdesc Added call to integer root function and qsort to @@ -290,7 +265,6 @@ void PUGH_DestroyConnectivity(pConnectivity **conn) demonstrable failure of the algorithm when dealing with large prime factors. @endhistory - @@*/ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs) { @@ -344,7 +318,7 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs) int place; root = free_dims; - working = (int *)calloc(free_dims,sizeof(int)); + working = calloc(free_dims,sizeof(int)); #ifdef DEBUG_PUGH printf("Processor topology for dimension %d\n",dim); #endif @@ -397,12 +371,6 @@ int PUGH_GenerateTopology(int dim, int total_procs, int *nprocs) Works out the array of neighbouring processors for every processor. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ int PUGH_GenerateNeighbours(int dim, int total_procs, @@ -417,7 +385,7 @@ int PUGH_GenerateNeighbours(int dim, int *pos; int temp; - pos = (int *)malloc(dim*sizeof(int)); + pos = malloc(dim*sizeof(int)); if(dim == 0 || pos) { @@ -507,12 +475,6 @@ int PUGH_GenerateNeighbours(int dim, Decompose an ijk index into seperate components. Taken from libHLL. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ int PUGH_DecomposeIJK(int dim, int ijk, int *nprocs, int *pos) { @@ -543,12 +505,6 @@ int PUGH_DecomposeIJK(int dim, int ijk, int *nprocs, int *pos) Compose an ijk index from seperate components. Taken from libHLL. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ int PUGH_ComposeIJK(int dim, int *nprocs, @@ -579,12 +535,6 @@ int PUGH_ComposeIJK(int dim, @desc Allocate memory for the members of the pGExtras structure. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ int PUGH_SetupPGExtrasMemory(int dim, int total_procs, @@ -601,18 +551,18 @@ int PUGH_SetupPGExtrasMemory(int dim, /* Do it in stages. * First: things depending on the number of processors */ - this->lb = (int **)malloc(total_procs*sizeof(int *)); - this->ub = (int **)malloc(total_procs*sizeof(int *)); - this->rnsize = (int **)malloc(total_procs*sizeof(int *)); - this->rnpoints = (int *) malloc(total_procs*sizeof(int)); + this->lb = malloc(total_procs*sizeof(int *)); + this->ub = malloc(total_procs*sizeof(int *)); + this->rnsize = malloc(total_procs*sizeof(int *)); + this->rnpoints = malloc(total_procs*sizeof(int)); /* Things just depending on dimension */ - this->nghostzones = (int *)malloc(dim*sizeof(int)); - this->nsize = (int *)malloc(dim*sizeof(int)); - this->lnsize = (int *)malloc(dim*sizeof(int)); - this->bbox = (int *)malloc(2*dim*sizeof(int)); - this->iterator = (int *)malloc(dim*sizeof(int)); - this->hyper_volume = (int *)malloc(dim*sizeof(int)); + this->nghostzones = malloc(dim*sizeof(int)); + this->nsize = malloc(dim*sizeof(int)); + this->lnsize = malloc(dim*sizeof(int)); + this->bbox = malloc(2*dim*sizeof(int)); + this->iterator = malloc(dim*sizeof(int)); + this->hyper_volume = malloc(dim*sizeof(int)); /* Check all the above succeeded and then get memory for * arrays hanging off the above. @@ -628,9 +578,9 @@ int PUGH_SetupPGExtrasMemory(int dim, (dim == 0 || this->iterator ) && (dim == 0 || this->hyper_volume)) { - this->lb[0] = (int *)malloc(total_procs *dim*sizeof(int)); - this->ub[0] = (int *)malloc(total_procs *dim*sizeof(int)); - this->rnsize[0] = (int *)malloc(total_procs*2*dim*sizeof(int)); + this->lb[0] = malloc(total_procs *dim*sizeof(int)); + this->ub[0] = malloc(total_procs *dim*sizeof(int)); + this->rnsize[0] = malloc(total_procs*2*dim*sizeof(int)); if (dim > 0) { @@ -720,16 +670,16 @@ int PUGH_SetupPGExtrasMemory(int dim, { for (j = 0; j < 2; j++) { - this->ownership[i][j] = (int *) malloc(dim*sizeof(int)); - this->ghosts[i][j] = (int **)malloc(2*dim*sizeof(int *)); - this->overlap[i][j] = (int **)malloc(2*dim*sizeof(int *)); + this->ownership[i][j] = malloc(dim*sizeof(int)); + this->ghosts[i][j] = malloc(2*dim*sizeof(int *)); + this->overlap[i][j] = malloc(2*dim*sizeof(int *)); if(dim > 0) { if(this->ghosts[i][j] && this->overlap[i][j]) { - this->ghosts[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int)); - this->overlap[i][j][0] = (int *)malloc(2*dim*dim*sizeof(int)); + this->ghosts[i][j][0] = malloc(2*dim*dim*sizeof(int)); + this->overlap[i][j][0] = malloc(2*dim*dim*sizeof(int)); for (k=1; k < 2*dim; k++) { this->ghosts[i][j][k] = this->ghosts[i][j][0] + k*dim; @@ -843,14 +793,9 @@ int PUGH_SetupPGExtrasMemory(int dim, Sets up the size information in the pGExtras structure. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ -int PUGH_SetupPGExtrasSizes(int dim, +int PUGH_SetupPGExtrasSizes(int is_gf, + int dim, int *perme, int stagger, int *sh, @@ -892,7 +837,8 @@ int PUGH_SetupPGExtrasSizes(int dim, /* Setup the bounding box stuff */ - PUGH_SetupBoundingBox(dim, + PUGH_SetupBoundingBox(is_gf, + dim, perme, stagger, sh, @@ -950,12 +896,6 @@ int PUGH_SetupPGExtrasSizes(int dim, Mostly taken from original SetupOwnership by Paul. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ int PUGH_SetupPGExtrasOwnership(int dim, int *perme, @@ -1098,7 +1038,7 @@ int PUGH_SetupPGExtrasStaggering(int dim, int s,d,k,dir; int *upperbnd; - upperbnd = (int*) malloc(dim*sizeof(int)); + upperbnd = malloc(dim*sizeof(int)); for (d=0;d 0 && bounds && pos) { /* Work out the bounds in each direction - either from parameters file or default*/ - PUGH_GetBounds(dim, bounds, nprocs, this->nsize); + PUGH_GetBounds(is_gf, dim, bounds, nprocs, this->nsize); /* for (dir = 0 ; dir < dim; dir++) { @@ -1255,14 +1190,7 @@ int PUGH_SetupBoundingBox(int dim, @desc Determines info about the sizes on each processor. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ - int PUGH_SetupRemoteSizes(int dim, int *perme, int stagger, @@ -1299,11 +1227,6 @@ int PUGH_SetupRemoteSizes(int dim, @desc Sets up a communication buffer for a group of GAs. @enddesc - @calls - @calledby - @history - - @endhistory @@*/ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH, int dim, @@ -1317,19 +1240,19 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH, pComm *this; - this = (pComm *) malloc (sizeof (pComm)); + this = malloc (sizeof (pComm)); if (this) { - this->buffer_sz = (int *) malloc (2 * dim * sizeof (int)); - this->send_buffer = (void **) malloc (2 * dim * sizeof (void *)); - this->recv_buffer = (void **) malloc (2 * dim * sizeof (void *)); + this->buffer_sz = malloc (2 * dim * sizeof (int)); + this->send_buffer = malloc (2 * dim * sizeof (void *)); + this->recv_buffer = malloc (2 * dim * sizeof (void *)); #ifdef CCTK_MPI - this->sreq = (MPI_Request *) malloc (2 * dim * sizeof (MPI_Request)); - this->rreq = (MPI_Request *) malloc (2 * dim * sizeof (MPI_Request)); - this->sstatus = (MPI_Status *) malloc (2 * dim * sizeof (MPI_Status)); + this->sreq = malloc (2 * dim * sizeof (MPI_Request)); + this->rreq = malloc (2 * dim * sizeof (MPI_Request)); + this->sstatus = malloc (2 * dim * sizeof (MPI_Status)); #endif - this->docomm = (int *) malloc (2 * dim * sizeof (int)); + this->docomm = malloc (2 * dim * sizeof (int)); if(this->buffer_sz && this->send_buffer && @@ -1429,11 +1352,6 @@ pComm *PUGH_SetupGArrayGroupComm(pGH *pughGH, @desc Sets up a communication buffer for a GA. @enddesc - @calls - @calledby - @history - - @endhistory @@*/ pComm *PUGH_SetupGArrayComm(pGH *pughGH, int dim, @@ -1459,11 +1377,6 @@ pComm *PUGH_SetupGArrayComm(pGH *pughGH, @desc Destroys a communication buffer. @enddesc - @calls - @calledby - @history - - @endhistory @@*/ void PUGH_DestroyComm(pComm **comm) { @@ -1489,12 +1402,6 @@ void PUGH_DestroyComm(pComm **comm) @desc Sets up a new pGA. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ pGA *PUGH_SetupGArray(void *parent, pGExtras *extras, @@ -1512,7 +1419,7 @@ pGA *PUGH_SetupGArray(void *parent, { pGA *this; - this = (pGA *)malloc(sizeof(pGA)); + this = malloc(sizeof(pGA)); if(this) { @@ -1528,7 +1435,7 @@ pGA *PUGH_SetupGArray(void *parent, this->arrayid = arrayid; this->storage = PUGH_NOSTORAGE; - this->name = (char *) malloc((strlen(name)+1)*sizeof(char)); + this->name = malloc((strlen(name)+1)*sizeof(char)); this->padddata = NULL; this->data = this->padddata; @@ -1565,12 +1472,6 @@ pGA *PUGH_SetupGArray(void *parent, @desc Destroys a pGA object. @enddesc - @calls - @calledby - @history - - @endhistory - @@*/ void PUGH_DestroyGArray(pGA **GA) { @@ -1611,24 +1512,16 @@ void PUGH_DestroyGArray(pGA **GA) @desc Generate the highest integer below a given integer root of an integer. @enddesc - @calls - @calledby - @history - - @endhistory + @var number @vdesc The number to take the root of @vtype int @vio in - @vcomment - @endvar @var invpower @vdesc The root to take @vtype int @vio in - @vcomment - @endvar @returntype int diff --git a/src/include/pugh.h b/src/include/pugh.h index a90a693..c0398d0 100644 --- a/src/include/pugh.h +++ b/src/include/pugh.h @@ -147,7 +147,8 @@ pGH *PUGH_pGH(const cGH *GH); int PUGH_Evolve(tFleshConfig *config); -int PUGH_GetBounds(int dim, +int PUGH_GetBounds(int is_gf, + int dim, int **bounds, int *nprocs, int *nsize); diff --git a/src/include/pughi.h b/src/include/pughi.h index abb3330..71828db 100644 --- a/src/include/pughi.h +++ b/src/include/pughi.h @@ -21,7 +21,8 @@ pConnectivity *PUGH_SetupConnectivity(int dim, int *nprocs, int *perme); -pGExtras *PUGH_SetupPGExtras(int dim, +pGExtras *PUGH_SetupPGExtras(int is_gf, + int dim, int *perme, int stagger, int *sh, @@ -65,7 +66,8 @@ int PUGH_SetupPGExtrasMemory(int dim, int *nprocs, pGExtras *this); -int PUGH_SetupPGExtrasSizes(int dim, +int PUGH_SetupPGExtrasSizes(int is_gf, + int dim, int *perme, int stagger, int *sh, @@ -85,7 +87,8 @@ int PUGH_SetupPGExtrasOwnership(int dim, int this_proc, pGExtras *this); -int PUGH_SetupBoundingBox(int dim, +int PUGH_SetupBoundingBox(int is_gf, + int dim, int *perme, int stagger, int *sh, -- cgit v1.2.3