Commit 0a9bb54a authored by Loic Hausammann's avatar Loic Hausammann
Browse files

change to uppercase constant (and format)

parent 12bfc29d
...@@ -146,9 +146,8 @@ int scheduler_get_number_relation(const struct scheduler *s, ...@@ -146,9 +146,8 @@ int scheduler_get_number_relation(const struct scheduler *s,
return count; return count;
} }
/* Conservative number of dependencies per task type */ /* Conservative number of dependencies per task type */
#define max_nber_dep 128 #define MAX_NUMBER_DEP 128
/** /**
* @brief Informations about all the task dependencies of * @brief Informations about all the task dependencies of
...@@ -158,7 +157,7 @@ struct task_dependency { ...@@ -158,7 +157,7 @@ struct task_dependency {
/* Main task */ /* Main task */
/* ID of the task */ /* ID of the task */
int type_in; int type_in;
/* ID of the subtask */ /* ID of the subtask */
int subtype_in; int subtype_in;
...@@ -167,23 +166,22 @@ struct task_dependency { ...@@ -167,23 +166,22 @@ struct task_dependency {
/* Dependent task */ /* Dependent task */
/* ID of the dependent task */ /* ID of the dependent task */
int type_out[max_nber_dep]; int type_out[MAX_NUMBER_DEP];
/* ID of the dependent subtask */ /* ID of the dependent subtask */
int subtype_out[max_nber_dep]; int subtype_out[MAX_NUMBER_DEP];
/* Is the dependent task implicit */ /* Is the dependent task implicit */
int implicit_out[max_nber_dep]; int implicit_out[MAX_NUMBER_DEP];
/* Statistics */ /* Statistics */
/* number of link between the two task type */ /* number of link between the two task type */
int number_link[max_nber_dep]; int number_link[MAX_NUMBER_DEP];
/* number of ranks having this relation */ /* number of ranks having this relation */
int number_rank[max_nber_dep]; int number_rank[MAX_NUMBER_DEP];
}; };
#ifdef WITH_MPI #ifdef WITH_MPI
/** /**
* @brief Define the #task_dependency for MPI * @brief Define the #task_dependency for MPI
...@@ -199,7 +197,7 @@ void task_dependency_define(MPI_Datatype *tstype) { ...@@ -199,7 +197,7 @@ void task_dependency_define(MPI_Datatype *tstype) {
MPI_Aint disps[count]; MPI_Aint disps[count];
/* all the type are int */ /* all the type are int */
for (int i=0; i < count; i++) { for (int i = 0; i < count; i++) {
types[i] = MPI_INT; types[i] = MPI_INT;
} }
...@@ -213,17 +211,17 @@ void task_dependency_define(MPI_Datatype *tstype) { ...@@ -213,17 +211,17 @@ void task_dependency_define(MPI_Datatype *tstype) {
/* Task out */ /* Task out */
disps[3] = offsetof(struct task_dependency, type_out); disps[3] = offsetof(struct task_dependency, type_out);
blocklens[3] = max_nber_dep; blocklens[3] = MAX_NUMBER_DEP;
disps[4] = offsetof(struct task_dependency, subtype_out); disps[4] = offsetof(struct task_dependency, subtype_out);
blocklens[4] = max_nber_dep; blocklens[4] = MAX_NUMBER_DEP;
disps[5] = offsetof(struct task_dependency, implicit_out); disps[5] = offsetof(struct task_dependency, implicit_out);
blocklens[5] = max_nber_dep; blocklens[5] = MAX_NUMBER_DEP;
/* statistics */ /* statistics */
disps[6] = offsetof(struct task_dependency, number_link); disps[6] = offsetof(struct task_dependency, number_link);
blocklens[6] = max_nber_dep; blocklens[6] = MAX_NUMBER_DEP;
disps[7] = offsetof(struct task_dependency, number_rank); disps[7] = offsetof(struct task_dependency, number_rank);
blocklens[7] = max_nber_dep; blocklens[7] = MAX_NUMBER_DEP;
/* define it for MPI */ /* define it for MPI */
MPI_Type_create_struct(count, blocklens, disps, types, tstype); MPI_Type_create_struct(count, blocklens, disps, types, tstype);
...@@ -238,8 +236,8 @@ void task_dependency_define(MPI_Datatype *tstype) { ...@@ -238,8 +236,8 @@ void task_dependency_define(MPI_Datatype *tstype) {
* @param len The length of the arrays * @param len The length of the arrays
* @param type The MPI datatype * @param type The MPI datatype
*/ */
void task_dependency_sum( void task_dependency_sum(void *in_p, void *out_p, int *len,
void *in_p, void *out_p, int *len, MPI_Datatype *type){ MPI_Datatype *type) {
/* change pointer type */ /* change pointer type */
struct task_dependency *in = in_p; struct task_dependency *in = in_p;
...@@ -249,11 +247,11 @@ void task_dependency_sum( ...@@ -249,11 +247,11 @@ void task_dependency_sum(
for (int i = 0; i < *len; i++) { for (int i = 0; i < *len; i++) {
/* loop over all the object set in invals */ /* loop over all the object set in invals */
for (int j = 0; j < max_nber_dep; j++) { for (int j = 0; j < MAX_NUMBER_DEP; j++) {
/* Have we reached the end of the links? */ /* Have we reached the end of the links? */
if (in[i].number_link[j] == -1) { if (in[i].number_link[j] == -1) {
break; break;
} }
/* get a few variables */ /* get a few variables */
...@@ -263,57 +261,57 @@ void task_dependency_sum( ...@@ -263,57 +261,57 @@ void task_dependency_sum(
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check tasks */ /* Check tasks */
if (tb_type >= task_type_count) { if (tb_type >= task_type_count) {
error("Unknown task type %i", tb_type); error("Unknown task type %i", tb_type);
} }
if (tb_subtype >= task_subtype_count) { if (tb_subtype >= task_subtype_count) {
error("Unknown subtask type %i", tb_subtype); error("Unknown subtask type %i", tb_subtype);
} }
#endif #endif
/* find the corresponding id */ /* find the corresponding id */
int k = 0; int k = 0;
while (k < max_nber_dep) { while (k < MAX_NUMBER_DEP) {
/* have we reached the end of the links? */ /* have we reached the end of the links? */
if (out[i].number_link[k] == -1) { if (out[i].number_link[k] == -1) {
/* reset the counter in order to be safe */ /* reset the counter in order to be safe */
out[i].number_link[k] = 0; out[i].number_link[k] = 0;
out[i].number_rank[k] = 0; out[i].number_rank[k] = 0;
/* set the relation */ /* set the relation */
out[i].type_in = in[i].type_in; out[i].type_in = in[i].type_in;
out[i].subtype_in = in[i].subtype_in; out[i].subtype_in = in[i].subtype_in;
out[i].implicit_in = in[i].implicit_in; out[i].implicit_in = in[i].implicit_in;
out[i].type_out[k] = in[i].type_out[j]; out[i].type_out[k] = in[i].type_out[j];
out[i].subtype_out[k] = in[i].subtype_out[j]; out[i].subtype_out[k] = in[i].subtype_out[j];
out[i].implicit_out[k] = in[i].implicit_out[j]; out[i].implicit_out[k] = in[i].implicit_out[j];
break; break;
} }
/* do we have the same relation? */ /* do we have the same relation? */
if (out[i].type_out[k] == tb_type && if (out[i].type_out[k] == tb_type &&
out[i].subtype_out[k] == tb_subtype) { out[i].subtype_out[k] == tb_subtype) {
break; break;
} }
k++; k++;
} }
/* Check if we are still in the memory */ /* Check if we are still in the memory */
if (k == max_nber_dep) { if (k == MAX_NUMBER_DEP) {
error("Not enough memory, please increase max_nber_dep"); error("Not enough memory, please increase MAX_NUMBER_DEP");
} }
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check if correct relation */ /* Check if correct relation */
if (out[i].type_in != in[i].type_in || if (out[i].type_in != in[i].type_in ||
out[i].subtype_in != in[i].subtype_in || out[i].subtype_in != in[i].subtype_in ||
out[i].implicit_in != in[i].implicit_in || out[i].implicit_in != in[i].implicit_in ||
out[i].type_out[k] != in[i].type_out[j] || out[i].type_out[k] != in[i].type_out[j] ||
out[i].subtype_out[k] != in[i].subtype_out[j] || out[i].subtype_out[k] != in[i].subtype_out[j] ||
out[i].implicit_out[k] != in[i].implicit_out[j]) { out[i].implicit_out[k] != in[i].implicit_out[j]) {
error("Tasks do not correspond"); error("Tasks do not correspond");
} }
#endif #endif
...@@ -326,7 +324,7 @@ void task_dependency_sum( ...@@ -326,7 +324,7 @@ void task_dependency_sum(
return; return;
} }
#endif // WITH_MPI #endif // WITH_MPI
/** /**
* @brief Write a dot file with the task dependencies. * @brief Write a dot file with the task dependencies.
...@@ -342,22 +340,21 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) { ...@@ -342,22 +340,21 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
const ticks tic = getticks(); const ticks tic = getticks();
/* Number of possible relations between tasks */ /* Number of possible relations between tasks */
const int nber_tasks = const int nber_tasks = task_type_count * task_subtype_count;
task_type_count * task_subtype_count;
/* To get the table for a task: /* To get the table for a task:
* ind = (ta * task_subtype_count + sa) * ind = (ta * task_subtype_count + sa)
* where ta is the value of task_type and sa is the value of * where ta is the value of task_type and sa is the value of
* task_subtype */ * task_subtype */
struct task_dependency *task_dep = (struct task_dependency *)malloc( struct task_dependency *task_dep = (struct task_dependency *)malloc(
nber_tasks * sizeof(struct task_dependency)); nber_tasks * sizeof(struct task_dependency));
if (task_dep == NULL) if (task_dep == NULL)
error("Error allocating memory for task-dependency graph (table)."); error("Error allocating memory for task-dependency graph (table).");
/* Reset counter */ /* Reset counter */
for (int i = 0; i < nber_tasks; i++) { for (int i = 0; i < nber_tasks; i++) {
for (int j = 0; j < max_nber_dep; j++) { for (int j = 0; j < MAX_NUMBER_DEP; j++) {
/* Use number_link as indicator of the existance of a relation */ /* Use number_link as indicator of the existance of a relation */
task_dep[i].number_link[j] = -1; task_dep[i].number_link[j] = -1;
} }
...@@ -382,34 +379,35 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) { ...@@ -382,34 +379,35 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
const struct task *tb = ta->unlock_tasks[j]; const struct task *tb = ta->unlock_tasks[j];
int k = 0; int k = 0;
while (k < max_nber_dep) { while (k < MAX_NUMBER_DEP) {
/* not written yet */ /* not written yet */
if (cur->number_link[k] == -1) { if (cur->number_link[k] == -1) {
/* set tb */ /* set tb */
cur->type_out[k] = tb->type; cur->type_out[k] = tb->type;
cur->subtype_out[k] = tb->subtype; cur->subtype_out[k] = tb->subtype;
cur->implicit_out[k] = tb->implicit; cur->implicit_out[k] = tb->implicit;
/* statistics */
int count = scheduler_get_number_relation(s, ta, tb);
cur->number_link[k] = count;
cur->number_rank[k] = 1;
/* statistics */
int count = scheduler_get_number_relation(s, ta, tb);
cur->number_link[k] = count;
cur->number_rank[k] = 1;
break; break;
} }
/* already written */ /* already written */
if (cur->type_out[k] == tb->type && cur->subtype_out[k] == tb->subtype) { if (cur->type_out[k] == tb->type &&
cur->subtype_out[k] == tb->subtype) {
break; break;
} }
k += 1; k += 1;
} }
/* max_nber_dep is too small */ /* MAX_NUMBER_DEP is too small */
if (k == max_nber_dep) if (k == MAX_NUMBER_DEP)
error("Not enough memory, please increase max_nber_dep"); error("Not enough memory, please increase MAX_NUMBER_DEP");
} }
} }
...@@ -419,28 +417,28 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) { ...@@ -419,28 +417,28 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
task_dependency_define(&data_type); task_dependency_define(&data_type);
MPI_Op sum; MPI_Op sum;
MPI_Op_create(task_dependency_sum, /* commute */1, &sum); MPI_Op_create(task_dependency_sum, /* commute */ 1, &sum);
/* create recv buffer */ /* create recv buffer */
struct task_dependency *recv = NULL; struct task_dependency *recv = NULL;
if (s->nodeID == 0) { if (s->nodeID == 0) {
recv = (struct task_dependency *)malloc( recv = (struct task_dependency *)malloc(nber_tasks *
nber_tasks * sizeof(struct task_dependency)); sizeof(struct task_dependency));
/* reset counter */ /* reset counter */
for (int i = 0; i < nber_tasks; i++) { for (int i = 0; i < nber_tasks; i++) {
for (int j = 0; j < max_nber_dep; j++) { for (int j = 0; j < MAX_NUMBER_DEP; j++) {
/* Use number_link as indicator of the existance of a relation */ /* Use number_link as indicator of the existance of a relation */
recv[i].number_link[j] = -1; recv[i].number_link[j] = -1;
} }
} }
} }
/* Do the reduction */ /* Do the reduction */
int test = MPI_Reduce(task_dep, recv, nber_tasks, data_type, sum, 0, MPI_COMM_WORLD); int test =
if (test != MPI_SUCCESS) MPI_Reduce(task_dep, recv, nber_tasks, data_type, sum, 0, MPI_COMM_WORLD);
error("MPI reduce failed"); if (test != MPI_SUCCESS) error("MPI reduce failed");
/* free some memory */ /* free some memory */
if (s->nodeID == 0) { if (s->nodeID == 0) {
...@@ -457,60 +455,58 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) { ...@@ -457,60 +455,58 @@ void scheduler_write_dependencies(struct scheduler *s, int verbose) {
/* Write header */ /* Write header */
fprintf(f, "# %s\n", git_revision()); fprintf(f, "# %s\n", git_revision());
fprintf(f, fprintf(
"task_in,task_out,implicit_in,implicit_out,mpi_in,mpi_out,cluster_in," f,
"cluster_out,number_link,number_rank\n"); "task_in,task_out,implicit_in,implicit_out,mpi_in,mpi_out,cluster_in,"
"cluster_out,number_link,number_rank\n");
for (int i = 0; i < nber_tasks; i++){
for (int j = 0; j < max_nber_dep; j++) { for (int i = 0; i < nber_tasks; i++) {
/* Does this link exists */ for (int j = 0; j < MAX_NUMBER_DEP; j++) {
if (task_dep[i].number_link[j] == -1) { /* Does this link exists */
continue; if (task_dep[i].number_link[j] == -1) {
} continue;
}
/* Define a few variables */
int ta_type = task_dep[i].type_in; /* Define a few variables */
int ta_subtype = task_dep[i].subtype_in; int ta_type = task_dep[i].type_in;
int ta_implicit = task_dep[i].implicit_in; int ta_subtype = task_dep[i].subtype_in;
int ta_implicit = task_dep[i].implicit_in;
int tb_type = task_dep[i].type_out[j];
int tb_subtype = task_dep[i].subtype_out[j]; int tb_type = task_dep[i].type_out[j];
int tb_implicit = task_dep[i].implicit_out[j]; int tb_subtype = task_dep[i].subtype_out[j];
int tb_implicit = task_dep[i].implicit_out[j];
int count = task_dep[i].number_link[j];
int number_rank = task_dep[i].number_rank[j]; int count = task_dep[i].number_link[j];
int number_rank = task_dep[i].number_rank[j];
/* text to write */
char ta_name[200]; /* text to write */
char tb_name[200]; char ta_name[200];
char tb_name[200];
/* construct line */
task_get_full_name(ta_type, ta_subtype, ta_name); /* construct line */
task_get_full_name(tb_type, tb_subtype, tb_name); task_get_full_name(ta_type, ta_subtype, ta_name);
task_get_full_name(tb_type, tb_subtype, tb_name);
/* Check if MPI */
int ta_mpi = 0; /* Check if MPI */
if (ta_type == task_type_send || ta_type == task_type_recv) int ta_mpi = 0;
ta_mpi = 1; if (ta_type == task_type_send || ta_type == task_type_recv) ta_mpi = 1;
int tb_mpi = 0; int tb_mpi = 0;
if (tb_type == task_type_send || tb_type == task_type_recv) if (tb_type == task_type_send || tb_type == task_type_recv) tb_mpi = 1;
tb_mpi = 1;
/* Get group name */
/* Get group name */ char ta_cluster[20];
char ta_cluster[20]; char tb_cluster[20];
char tb_cluster[20]; task_get_group_name(ta_type, ta_subtype, ta_cluster);
task_get_group_name(ta_type, ta_subtype, ta_cluster); task_get_group_name(tb_type, tb_subtype, tb_cluster);
task_get_group_name(tb_type, tb_subtype, tb_cluster);
fprintf(f, "%s,%s,%d,%d,%d,%d,%s,%s,%d,%d\n", ta_name, tb_name,
fprintf(f, "%s,%s,%d,%d,%d,%d,%s,%s,%d,%d\n", ta_name, tb_name, ta_implicit, tb_implicit, ta_mpi, tb_mpi, ta_cluster,
ta_implicit, tb_implicit, ta_mpi, tb_mpi, ta_cluster, tb_cluster, count, number_rank);
tb_cluster, count, number_rank);
} }
} }
/* Close the file */ /* Close the file */
fclose(f); fclose(f);
} }
/* Be clean */ /* Be clean */
...@@ -2131,7 +2127,7 @@ void scheduler_rewait_mapper(void *map_data, int num_elements, ...@@ -2131,7 +2127,7 @@ void scheduler_rewait_mapper(void *map_data, int num_elements,
for (int ind = 0; ind < num_elements; ind++) { for (int ind = 0; ind < num_elements; ind++) {
struct task *t = &s->tasks[tid[ind]]; struct task *t = &s->tasks[tid[ind]];
/* Ignore skipped tasks. */ /* Ignore skipped tasks. */
if (t->skip) continue; if (t->skip) continue;
/* Increment the task's own wait counter for the enqueueing. */ /* Increment the task's own wait counter for the enqueueing. */
......
...@@ -619,8 +619,7 @@ void task_get_full_name(enum task_types type, enum task_subtypes subtype, ...@@ -619,8 +619,7 @@ void task_get_full_name(enum task_types type, enum task_subtypes subtype,
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
/* Check input */ /* Check input */
if (type >= task_type_count) if (type >= task_type_count) error("Unknown task type %i", type);
error("Unknown task type %i", type);
if (subtype >= task_subtype_count) if (subtype >= task_subtype_count)
error("Unknown task subtype %i with type %s", subtype, taskID_names[type]); error("Unknown task subtype %i with type %s", subtype, taskID_names[type]);
......
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