diff options
author | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2003-09-18 12:53:34 +0000 |
---|---|---|
committer | tradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2003-09-18 12:53:34 +0000 |
commit | cf6e1e025cc54b50901bc97d8c42ca90356fada1 (patch) | |
tree | 70f543acd6645ae084973ca2e852e1dea8e34611 | |
parent | 7d3aa5d99c41920b9813b97dc07a75fa6f41b022 (diff) |
Stop in PUGH_GetSliceSizes() with a level-0 warning rather than trying to
continue if the user specified invalid values for the partition parameters.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@417 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r-- | src/LoadAware.c | 111 |
1 files changed, 31 insertions, 80 deletions
diff --git a/src/LoadAware.c b/src/LoadAware.c index a98d9ba..e1f04ec 100644 --- a/src/LoadAware.c +++ b/src/LoadAware.c @@ -1,11 +1,11 @@ /*@@ - @file LoadAware.c - @date Fri Feb 21 10:21:36 2000 - @author Matei Ripeanu - @desc - + @file LoadAware.c + @date Fri Feb 21 10:21:36 2000 + @author Matei Ripeanu + @desc + @enddesc - @version $Header$ + @version $Id$ @@*/ #include <stdio.h> @@ -22,21 +22,18 @@ static const char *rcsid="$Header$"; CCTK_FILEVERSION(CactusPUGH_PUGH_LoadAware_c) -/* #define DEBUG_LA 1 */ - - /* prototypes of routines defined in this source file */ int PUGH_SetPartitionInfo (int dim, const char *partition_info[]); -static int PUGH_GetSliceSizes (int np, - int grid_points, - const char *slicesS, - int **slices, - int manual); +static void PUGH_GetSliceSizes (int np, + int grid_points, + const char *slicesS, + int **slices, + int manual); /* static pointers to strings which contain partition information if set */ static char *partition_1D[1] = {NULL}; static char *partition_2D[2] = {NULL, NULL}; -static char *partition_3D[3] = {NULL, NULL, NULL}; +static char *partition_3D[3] = {NULL, NULL, NULL}; /*@@ @@ -68,7 +65,7 @@ static char *partition_3D[3] = {NULL, NULL, NULL}; @returntype int @returndesc - 0: OK + 0: OK -1: invalid dimension @endreturndesc @@*/ @@ -132,7 +129,7 @@ int PUGH_SetPartitionInfo (int dim, const char *partition_info[]) @date Fri Feb 21 10:21:36 2000 @author Matei Ripeanu @desc - + @enddesc @calls PUGH_GetSliceSizes @@ -159,7 +156,7 @@ int PUGH_SetPartitionInfo (int dim, const char *partition_info[]) @returntype int @returndesc - 0: OK + 0: OK -1: invalid dimension @endreturndesc @@*/ @@ -232,7 +229,7 @@ int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) } - /*@@ + /*@@ @routine PUGH_GetSliceSizes @date Fri Feb 21 10:21:36 2000 @author Matei Ripeanu @@ -265,52 +262,34 @@ int PUGH_GetBounds (int dim, int *bounds[], int nprocs[], int nsize[]) @vtype int @vio in @endvar - - @returntype int - @returndesc - 0: OK - -1: can not allocate memory - -2: expect data for np processors but got for more - -3: expect data for np processors but got for fewer - -4: total doesn't match - @endreturndesc @@*/ -static int PUGH_GetSliceSizes (int np, - int grid_points, - const char *slicesS, - int **slices, - int manual) +static void PUGH_GetSliceSizes (int np, + int grid_points, + const char *slicesS, + int **slices, + int manual) { int tmp, i=0, rt=0; - *slices = (int *) malloc (np * sizeof (int)); - if (*slices == NULL) + *slices = malloc (np * sizeof (int)); + if (! *slices) { - CCTK_WARN (1, "Not enough memory"); - return (-1); + CCTK_WARN (0, "Not enough memory"); } - if (manual && (strlen (slicesS) > 0)) + if (manual && *slicesS) { while (*slicesS) { if (i >= np) { - CCTK_WARN (1, "Wrong partition parameters: " + CCTK_WARN (0, "Wrong partition parameters: " "expect data for fewer processors"); - return (-2); } sscanf (slicesS, "%d", &tmp); - if (i == 0) - { - (*slices)[i] = 0; - } - else - { - (*slices)[i] = rt - 1; - } - rt = rt + tmp; + (*slices)[i] = i ? rt - 1 : 0; + rt += tmp; i++; while (isdigit ((int) *slicesS)) { @@ -324,49 +303,21 @@ static int PUGH_GetSliceSizes (int np, if (i != np) { - CCTK_WARN (1, "Wrong partition parameters: " + CCTK_WARN (0, "Wrong partition parameters: " "expect data for more processors"); - return (-3); } - if (rt != grid_points) { - CCTK_WARN (1, "Wrong partition parameters: " + CCTK_WARN (0, "Wrong partition parameters: " "total number of grid points doesnt match"); - return (-4); } - } else { for (i = 0; i < np; i++) { (*slices)[i] = rt; - tmp = (grid_points - rt -1) / (np - i); - rt = rt + tmp; + rt += (grid_points - rt -1) / (np - i); } } - -#ifdef DEBUG_LA - printf("\n"); - for (i = 0; i<np; i++) printf( "%d :: ", (*slices)[i]); - printf("\n"); -#endif - - return (0); -} - - -/* -int main(void) { - int ret, i, *rez; - ret = PUGH_GetSliceSizes (5, 72, "12:12:24:12:12", &rez, 1); - - if (ret != 0) - printf ("Error: %d\n", ret); - else - for (i=0; i<5; i++) { - printf("%d\n", rez[i]); - } } -*/ |