From 1632839cbf1a11274d329ee2138551f377653e1a Mon Sep 17 00:00:00 2001 From: Taj Muhammad Khan Date: Tue, 10 Jun 2014 11:57:58 +0200 Subject: [PATCH] Add printing of usr-defined pragmas in clast_for --- include/cloog/clast.h | 3 +++ source/clast.c | 2 ++ source/pprint.c | 5 +++++ source/program.c | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/include/cloog/clast.h b/include/cloog/clast.h index 3348aa8..eee59e4 100644 --- a/include/cloog/clast.h +++ b/include/cloog/clast.h @@ -35,6 +35,7 @@ struct clast_term { #define CLAST_PARALLEL_OMP 1 #define CLAST_PARALLEL_MPI 2 #define CLAST_PARALLEL_VEC 4 +#define CLAST_PARALLEL_USR 8 enum clast_red_type { clast_red_sum, clast_red_min, clast_red_max }; struct clast_reduction { @@ -111,6 +112,8 @@ struct clast_for { /* Enable execution time reporting for this loop */ /* Variable name to accumulate execution time this loop */ char *time_var_name; + /* User defined string */ + char *usr; }; struct clast_equation { diff --git a/source/clast.c b/source/clast.c index a4fb958..175f7f0 100644 --- a/source/clast.c +++ b/source/clast.c @@ -214,6 +214,7 @@ static void free_clast_for(struct clast_stmt *s) if (f->private_vars) free(f->private_vars); if (f->reduction_vars) free(f->reduction_vars); if (f->time_var_name) free(f->time_var_name); + if (f->usr) free(f->usr); free(f); } @@ -233,6 +234,7 @@ struct clast_for *new_clast_for(CloogDomain *domain, const char *it, f->private_vars = NULL; f->reduction_vars = NULL; f->time_var_name = NULL; + f->usr = NULL; cloog_int_init(f->stride); if (stride) cloog_int_set(f->stride, stride->stride); diff --git a/source/pprint.c b/source/pprint.c index c7e494f..eaa0780 100644 --- a/source/pprint.c +++ b/source/pprint.c @@ -509,6 +509,11 @@ void pprint_for(struct cloogoptions *options, FILE *dst, int indent, } fprintf(dst, "%*s", indent, ""); } + if (f->parallel & CLAST_PARALLEL_USR) { + fprintf(dst, "#%s\n", + (f->usr)? f->usr: ""); + fprintf(dst, "%*s", indent, ""); + } } diff --git a/source/program.c b/source/program.c index 89d6774..dd329da 100644 --- a/source/program.c +++ b/source/program.c @@ -448,6 +448,12 @@ int annotate_loops(osl_scop_p program, struct clast_stmt *root){ ret |= CLAST_PARALLEL_OMP; clastloops[j]->private_vars = strdup(loop->private_vars); } + + if (loop->directive & CLAST_PARALLEL_USR) { + clastloops[j]->parallel |= CLAST_PARALLEL_USR; + ret |= CLAST_PARALLEL_USR; + clastloops[j]->usr = strdup(loop->user); + } } if (clastloops) { free(clastloops); clastloops=NULL;}