aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknarf <knarf@b61c5cb5-eaca-4651-9a7a-d64986f99364>2009-09-18 19:55:30 +0000
committerknarf <knarf@b61c5cb5-eaca-4651-9a7a-d64986f99364>2009-09-18 19:55:30 +0000
commita6345d6e112cf83d6c1a60f9049524b30aa1a0ae (patch)
tree041f814e54726450956e7740dd2628988477d6ad
parent268936b8f93bec3a18681d2650cac01d4395dd76 (diff)
bugfix for the "automatic" topologyy generator:
It used to fall back to the old method, when some of the spcifications for nprocs have already been set, because it should not overwrite something e.g. specified by parameters. If this is not the case, nprocs is usually initialized with 0es. This was good. PUGH also tries to be smart and for very small extends in one direction (smaller than 2*ghostsize) it presets nprocs in that direction with 1. This is also good. Now, PUGH presets this before the "automatic" topology generator kicks in, which means this sees the "1" and falls back to the old method. This old method however has problems with exactly this type of grid and gets it wrong (overwriting that "1"). This patch now lets the automatic method only fall back to the old method if it arrives at a different answer than preset values (if set). (This fallback is neccessary because it cannot handle all cases which the old method does.) This fixes the problem because the automatic method also arrives at the preset value of "1" (and can set the other dimentions which have not been preset). git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@497 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/Topology.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/Topology.c b/src/Topology.c
index e9b5592..4849ba9 100644
--- a/src/Topology.c
+++ b/src/Topology.c
@@ -243,7 +243,7 @@ static int FranksTopology(int dim,
int max_dir, max_length;
int free_procs = total_procs-1;
int used_procs = 1;
-
+ int *my_nprocs = (int*)malloc(dim*sizeof(int));
/* Nothing to decompose here */
if (dim == 0)
@@ -251,20 +251,11 @@ static int FranksTopology(int dim,
return TraditionalTopology(dim, total_procs, nsize,
nghostzones, nprocs);
}
- /* If there are numbers already set up or we have funny grid sizes,
- fall back */
- for (i = 0; i < dim; i++)
- {
- if (nprocs[i] || (nsize[i]<1))
- {
- return TraditionalTopology(dim, total_procs, nsize,
- nghostzones, nprocs);
- }
- }
+
/* start with a single domain */
for (i = 0; i < dim; i++)
{
- nprocs[i] = 1;
+ my_nprocs[i] = 1;
}
/* divide as long as there are processors left */
while (free_procs)
@@ -276,13 +267,13 @@ static int FranksTopology(int dim,
for (i = 0; i < dim; i++)
{
/* is one part larger than the max? (then it might be a new max) */
- if ((nsize[i] / nprocs[i] > max_length) &&
+ if ((nsize[i] / my_nprocs[i] > max_length) &&
/* would there be at least one real point if we divide? */
- (nsize[i] > 2*nghostzones[i]+nprocs[i]) &&
+ (nsize[i] > 2*nghostzones[i]+my_nprocs[i]) &&
/* do we have enough processors left to divide in this direction? */
- (used_procs/nprocs[i] <= free_procs))
+ (used_procs/my_nprocs[i] <= free_procs))
{
- max_length = nsize[i] / nprocs[i];
+ max_length = nsize[i] / my_nprocs[i];
max_dir = i;
}
}
@@ -291,11 +282,10 @@ static int FranksTopology(int dim,
{
for (i = 0; i < dim; i++)
{
- nprocs[i] = 0;
+ my_nprocs[i] = 0;
}
CCTK_WARN(CCTK_WARN_COMPLAIN,
- "Falling back to the old PUGH topology method, overwriting "
- "eventually set manual topologies");
+ "Falling back to the old PUGH topology method");
return TraditionalTopology(dim, total_procs, nsize,
nghostzones, nprocs);
}
@@ -303,8 +293,24 @@ static int FranksTopology(int dim,
/* note: this is garanteed to decrement at least by one, since the number
of used processors is naturally always >= the number of processors used
for one dimension */
- free_procs -= used_procs/nprocs[max_dir];
- nprocs[max_dir]++;
+ free_procs -= used_procs/my_nprocs[max_dir];
+ my_nprocs[max_dir]++;
+ }
+ /* If there are numbers already set up which are different from what
+ we arrive at or we have funny grid sizes, fall back */
+ for (i = 0; i < dim; i++)
+ {
+ if (nprocs[i] && (nprocs[i]!=my_nprocs[i]) || (nsize[i]<1))
+ {
+ CCTK_WARN(CCTK_WARN_COMPLAIN,
+ "Falling back to the old PUGH topology method");
+ return TraditionalTopology(dim, total_procs, nsize,
+ nghostzones, nprocs);
+ }
+ }
+ for (i = 0; i < dim; i++)
+ {
+ nprocs[i] = my_nprocs[i];
}
/* success */
return 0;