Commit 03f41465 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Expand names to avoid confusion of part with particles

Sort some headers into alphabetic order
parent 186d79e1
......@@ -82,19 +82,19 @@ int main(int argc, char *argv[]) {
int nr_nodes = 1, myrank = 0;
FILE *file_thread;
int with_outputs = 1;
struct initpart ipart;
struct partition initial_partition;
#if defined(WITH_MPI) && defined(HAVE_METIS)
enum repart_type reparttype = REPART_METIS_BOTH;
enum repartition_type reparttype = REPART_METIS_BOTH;
#endif
/* Default initial partition type is grid for shared memory and when
* METIS is not available. */
ipart.type = INITPART_GRID;
ipart.grid[0] = 1;
ipart.grid[1] = 1;
ipart.grid[2] = 1;
initial_partition.type = INITPART_GRID;
initial_partition.grid[0] = 1;
initial_partition.grid[1] = 1;
initial_partition.grid[2] = 1;
#if defined(WITH_MPI) && defined(HAVE_METIS)
ipart.type = INITPART_METIS_NOWEIGHT;
initial_partition.type = INITPART_METIS_NOWEIGHT;
#endif
/* Choke on FP-exceptions. */
......@@ -121,9 +121,11 @@ int main(int argc, char *argv[]) {
fflush(stdout);
/* Set a default grid so that grid[0]*grid[1]*grid[2] == nr_nodes. */
factor(nr_nodes, &ipart.grid[0], &ipart.grid[1]);
factor(nr_nodes / ipart.grid[1], &ipart.grid[0], &ipart.grid[2]);
factor(ipart.grid[0] * ipart.grid[1], &ipart.grid[1], &ipart.grid[0]);
factor(nr_nodes, &initial_partition.grid[0], &initial_partition.grid[1]);
factor(nr_nodes / initial_partition.grid[1], &initial_partition.grid[0],
&initial_partition.grid[2]);
factor(initial_partition.grid[0] * initial_partition.grid[1],
&initial_partition.grid[1], &initial_partition.grid[0]);
#endif
/* Greeting message */
......@@ -193,21 +195,22 @@ int main(int argc, char *argv[]) {
* followed by three numbers defining the grid. */
switch (optarg[0]) {
case 'g':
ipart.type = INITPART_GRID;
initial_partition.type = INITPART_GRID;
if (strlen(optarg) > 2) {
if (sscanf(optarg, "g %i %i %i", &ipart.grid[0], &ipart.grid[1],
&ipart.grid[2]) != 3)
if (sscanf(optarg, "g %i %i %i", &initial_partition.grid[0],
&initial_partition.grid[1],
&initial_partition.grid[2]) != 3)
error("Error parsing grid.");
}
break;
case 'm':
ipart.type = INITPART_METIS_NOWEIGHT;
initial_partition.type = INITPART_METIS_NOWEIGHT;
break;
case 'w':
ipart.type = INITPART_METIS_WEIGHT;
initial_partition.type = INITPART_METIS_WEIGHT;
break;
case 'v':
ipart.type = INITPART_VECTORIZE;
initial_partition.type = INITPART_VECTORIZE;
break;
}
break;
......@@ -270,10 +273,12 @@ int main(int argc, char *argv[]) {
#if defined(WITH_MPI)
if (myrank == 0) {
message("Running with %i thread(s) per node.", nr_threads);
message("Using initial partition %s", initpart_name[ipart.type]);
if (ipart.type == INITPART_GRID)
message("grid set to [ %i %i %i ].", ipart.grid[0], ipart.grid[1], ipart.grid[2]);
message("Using %s repartitioning", repart_name[reparttype]);
message("Using initial partition %s",
initial_partition_name[initial_partition.type]);
if (initial_partition.type == INITPART_GRID)
message("grid set to [ %i %i %i ].", initial_partition.grid[0],
initial_partition.grid[1], initial_partition.grid[2]);
message("Using %s repartitioning", repartition_name[reparttype]);
if (nr_nodes == 1) {
message("WARNING: you are running with one MPI rank.");
......@@ -407,7 +412,7 @@ int main(int argc, char *argv[]) {
#ifdef WITH_MPI
/* Split the space. */
engine_split(&e, &ipart);
engine_split(&e, &initial_partition);
engine_redistribute(&e);
#endif
......
......@@ -52,8 +52,8 @@
#include "hydro.h"
#include "minmax.h"
#include "part.h"
#include "timers.h"
#include "partition.h"
#include "timers.h"
const char *engine_policy_names[12] = {
"none", "rand", "steal", "keep",
......@@ -297,7 +297,7 @@ void engine_repartition(struct engine *e) {
#if defined(WITH_MPI) && defined(HAVE_METIS)
/* Clear the repartition flag. */
enum repart_type reparttype = e->forcerepart;
enum repartition_type reparttype = e->forcerepart;
e->forcerepart = REPART_NONE;
/* Nothing to do if only using a single node. Also avoids METIS
......@@ -305,8 +305,8 @@ void engine_repartition(struct engine *e) {
if (e->nr_nodes == 1) return;
/* Do the repartitioning. */
part_repart(reparttype, e->nodeID, e->nr_nodes, e->s, e->sched.tasks,
e->sched.nr_tasks);
partition_repartition(reparttype, e->nodeID, e->nr_nodes, e->s,
e->sched.tasks, e->sched.nr_tasks);
/* Now comes the tricky part: Exchange particles between all nodes.
This is done in two steps, first allreducing a matrix of
......@@ -1730,16 +1730,16 @@ void engine_makeproxies(struct engine *e) {
* @brief Split the underlying space into regions and assign to separate nodes.
*
* @param e The #engine.
* @param ipart structure defining the cell partition technique
* @param initial_partition structure defining the cell partition technique
*/
void engine_split(struct engine *e, struct initpart *ipart) {
void engine_split(struct engine *e, struct partition *initial_partition) {
#ifdef WITH_MPI
struct space *s = e->s;
/* Do the initial partition of the cells. */
part_part(ipart, e->nodeID, e->nr_nodes, s);
partition_initial_partition(initial_partition, e->nodeID, e->nr_nodes, s);
/* Make the proxies. */
engine_makeproxies(e);
......@@ -1830,7 +1830,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
int home = numa_node_of_cpu(sched_getcpu()), half = nr_cores / 2;
bool done = false, swap_hyperthreads = hyperthreads_present();
if (swap_hyperthreads && nodeID == 0)
if (swap_hyperthreads && nodeID == 0)
message("prefer physical cores to hyperthreads");
while (!done) {
......
......@@ -150,7 +150,7 @@ struct engine {
/* Force the engine to rebuild? */
int forcerebuild;
enum repart_type forcerepart;
enum repartition_type forcerepart;
/* How many steps have we done with the same set of tasks? */
int tasks_age;
......@@ -178,7 +178,7 @@ void engine_print(struct engine *e);
void engine_init_particles(struct engine *e);
void engine_step(struct engine *e);
void engine_maketasks(struct engine *e);
void engine_split(struct engine *e, struct initpart *ipart);
void engine_split(struct engine *e, struct partition *initial_partition);
int engine_exchange_strays(struct engine *e, int offset, int *ind, int N);
void engine_rebuild(struct engine *e);
void engine_repartition(struct engine *e);
......
......@@ -31,11 +31,11 @@
#include "../config.h"
/* Standard headers. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <values.h>
#include <strings.h>
#include <values.h>
/* MPI headers. */
#ifdef WITH_MPI
......@@ -47,17 +47,17 @@
#endif
/* Local headers. */
#include "space.h"
#include "partition.h"
#include "const.h"
#include "error.h"
#include "debug.h"
#include "error.h"
#include "partition.h"
#include "space.h"
/* Maximum weight used for METIS. */
#define metis_maxweight 10000.0f
/* Simple descriptions of initial partition types for reports. */
const char *initpart_name[] = {
const char *initial_partition_name[] = {
"gridded cells",
"vectorized point associated cells",
"METIS particle weighted cells",
......@@ -65,7 +65,7 @@ const char *initpart_name[] = {
};
/* Simple descriptions of repartition types for reports. */
const char *repart_name[] = {
const char *repartition_name[] = {
"no",
"METIS edge and vertex time weighted cells",
"METIS particle count vertex weighted cells",
......@@ -293,7 +293,7 @@ static void split_metis(struct space *s, int nregions, int *celllist) {
* @brief Partition the given space into a number of connected regions.
*
* Split the space using METIS to derive a partitions using the
* given edge and vertex weights. If no weights are given then an
* given edge and vertex weights. If no weights are given then an
* unweighted partition is performed.
*
* @param s the space of cells to partition.
......@@ -735,8 +735,9 @@ static void repart_vertex_metis(struct space *s, int nodeID, int nr_nodes) {
* @param tasks the completed tasks from the last engine step for our node.
* @param nr_tasks the number of tasks.
*/
void part_repart(enum repart_type reparttype, int nodeID, int nr_nodes,
struct space *s, struct task *tasks, int nr_tasks) {
void partition_repartition(enum repartition_type reparttype, int nodeID,
int nr_nodes, struct space *s, struct task *tasks,
int nr_tasks) {
#if defined(WITH_MPI) && defined(HAVE_METIS)
......@@ -781,30 +782,33 @@ void part_repart(enum repart_type reparttype, int nodeID, int nr_nodes,
* scheme fails. In that case we fallback to a vectorised scheme, that is
* guaranteed to work provided we have more cells than nodes.
*
* @param ipart the type of partitioning to try.
* @param initial_partition the type of partitioning to try.
* @param nodeID our nodeID.
* @param nr_nodes the number of nodes.
* @param s the space of cells.
*/
void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
struct space *s) {
void partition_initial_partition(struct partition *initial_partition,
int nodeID, int nr_nodes, struct space *s) {
/* Geometric grid partitioning. */
if (ipart->type == INITPART_GRID) {
if (initial_partition->type == INITPART_GRID) {
int j, k;
int ind[3];
struct cell *c;
/* If we've got the wrong number of nodes, fail. */
if (nr_nodes != ipart->grid[0] * ipart->grid[1] * ipart->grid[2])
if (nr_nodes != initial_partition->grid[0] * initial_partition->grid[1]
* initial_partition->grid[2])
error("Grid size does not match number of nodes.");
/* Run through the cells and set their nodeID. */
// message("s->dim = [%e,%e,%e]", s->dim[0], s->dim[1], s->dim[2]);
for (k = 0; k < s->nr_cells; k++) {
c = &s->cells[k];
for (j = 0; j < 3; j++) ind[j] = c->loc[j] / s->dim[j] * ipart->grid[j];
c->nodeID = ind[0] + ipart->grid[0] * (ind[1] + ipart->grid[1] * ind[2]);
for (j = 0; j < 3; j++)
ind[j] = c->loc[j] / s->dim[j] * initial_partition->grid[j];
c->nodeID = ind[0] + initial_partition->grid[0] *
(ind[1] + initial_partition->grid[1] * ind[2]);
// message("cell at [%e,%e,%e]: ind = [%i,%i,%i], nodeID = %i", c->loc[0],
// c->loc[1], c->loc[2], ind[0], ind[1], ind[2], c->nodeID);
}
......@@ -813,13 +817,13 @@ void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
if (!check_complete(s, (nodeID == 0), nr_nodes)) {
if (nodeID == 0)
message("Grid initial partition failed, using a vectorised partition");
ipart->type = INITPART_VECTORIZE;
part_part(ipart, nodeID, nr_nodes, s);
initial_partition->type = INITPART_VECTORIZE;
partition_initial_partition(initial_partition, nodeID, nr_nodes, s);
return;
}
} else if (ipart->type == INITPART_METIS_WEIGHT ||
ipart->type == INITPART_METIS_NOWEIGHT) {
} else if (initial_partition->type == INITPART_METIS_WEIGHT ||
initial_partition->type == INITPART_METIS_NOWEIGHT) {
#if defined(WITH_MPI) && defined(HAVE_METIS)
/* Simple k-way partition selected by METIS using cell particle counts as
* weights or not. Should be best when starting with a inhomogeneous dist.
......@@ -828,7 +832,7 @@ void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
/* Space for particles per cell counts, which will be used as weights or
* not. */
int *weights = NULL;
if (ipart->type == INITPART_METIS_WEIGHT) {
if (initial_partition->type == INITPART_METIS_WEIGHT) {
if ((weights = (int *)malloc(sizeof(int) * s->nr_cells)) == NULL)
error("Failed to allocate weights buffer.");
bzero(weights, sizeof(int) * s->nr_cells);
......@@ -876,12 +880,13 @@ void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
/* And apply to our cells */
split_metis(s, nr_nodes, celllist);
/* It's not known if this can fail, but check for this before proceeding. */
/* It's not known if this can fail, but check for this before
* proceeding. */
if (!check_complete(s, (nodeID == 0), nr_nodes)) {
if (nodeID == 0)
message("METIS initial partition failed, using a vectorised partition");
ipart->type = INITPART_VECTORIZE;
part_part(ipart, nodeID, nr_nodes, s);
initial_partition->type = INITPART_VECTORIZE;
partition_initial_partition(initial_partition, nodeID, nr_nodes, s);
}
if (weights != NULL) free(weights);
......@@ -890,7 +895,7 @@ void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
error("SWIFT was not compiled with METIS support");
#endif
} else if (ipart->type == INITPART_VECTORIZE) {
} else if (initial_partition->type == INITPART_VECTORIZE) {
#if defined(WITH_MPI)
/* Vectorised selection, guaranteed to work for samples less than the
......
......@@ -23,7 +23,7 @@
#include "task.h"
/* Initial partitioning types. */
enum initpart_type {
enum partition_type {
INITPART_GRID = 0,
INITPART_VECTORIZE,
INITPART_METIS_WEIGHT,
......@@ -31,16 +31,15 @@ enum initpart_type {
};
/* Simple descriptions of types for reports. */
extern const char *initpart_name[];
extern const char *initial_partition_name[];
/* The selected initial partition type and any related metadata. */
struct initpart {
enum initpart_type type;
struct partition {
enum partition_type type;
int grid[3];
};
/* Repartition type to use. */
enum repart_type {
enum repartition_type {
REPART_NONE = 0,
REPART_METIS_BOTH,
REPART_METIS_VERTEX,
......@@ -49,11 +48,12 @@ enum repart_type {
};
/* Simple descriptions of types for reports. */
extern const char *repart_name[];
extern const char *repartition_name[];
void part_repart(enum repart_type reparttype, int nodeID, int nr_nodes,
struct space *s, struct task *tasks, int nr_tasks);
void part_part(struct initpart *ipart, int nodeID, int nr_nodes,
struct space *s);
void partition_repartition(enum repartition_type reparttype, int nodeID,
int nr_nodes, struct space *s,
struct task *tasks, int nr_tasks);
void partition_initial_partition(struct partition *initial_partition,
int nodeID, int nr_nodes, struct space *s);
#endif /* SWIFT_PARTITION_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment