From efcd97f211f4a178469393d03b12c73b4f11c7ea Mon Sep 17 00:00:00 2001 From: Taj Muhammad Khan Date: Sun, 25 May 2014 11:34:58 +0200 Subject: [PATCH] Declarations for omp private variables --- source/program.c | 19 +++++++++++++------ test/openscop/loops.c | 9 +++++++-- test/openscop/loops.scop | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/program.c b/source/program.c index d122234..c446291 100644 --- a/source/program.c +++ b/source/program.c @@ -370,10 +370,10 @@ int annotate_loops( osl_scop_p program , struct clast_stmt *root){ int j, nclastloops, nclaststmts; struct clast_for **clastloops = NULL; int *claststmts = NULL; + int ret = 0; if (program == NULL) { - printf("Exiting ANootate loops\n"); - return 1; + return ret; } osl_loop_p ll = osl_generic_lookup(program->extension, OSL_URI_LOOP); @@ -398,11 +398,13 @@ int annotate_loops( osl_scop_p program , struct clast_stmt *root){ for (j=0; jdirective & CLAST_PARALLEL_VEC) { - clastloops[j]->parallel += CLAST_PARALLEL_VEC; + clastloops[j]->parallel |= CLAST_PARALLEL_VEC; + ret |= CLAST_PARALLEL_VEC; } if (loop->directive & CLAST_PARALLEL_OMP) { - clastloops[j]->parallel += CLAST_PARALLEL_OMP; + clastloops[j]->parallel |= CLAST_PARALLEL_OMP; + ret |= CLAST_PARALLEL_OMP; clastloops[j]->private_vars = strdup(loop->private_vars); } } @@ -413,7 +415,7 @@ int annotate_loops( osl_scop_p program , struct clast_stmt *root){ ll = ll->next; } - return 0; + return ret; } @@ -439,8 +441,10 @@ int cloog_program_osl_pprint(FILE * file, CloogProgram * program, char c; osl_scop_p scop = options->scop; osl_coordinates_p coordinates; + char* parvar[2] = {"lbv", "ubv"}; struct clast_stmt *root; FILE * original; + int annotate_result = 0; if (scop && !options->compilable && !options->callable) { coordinates = osl_generic_lookup(scop->extension, OSL_URI_COORDINATES); @@ -476,7 +480,10 @@ int cloog_program_osl_pprint(FILE * file, CloogProgram * program, /* Generate the clast from the pseudo-AST then pretty-print it. */ root = cloog_clast_create(program, options); - annotate_loops(options->scop, root); + annotate_result = annotate_loops(options->scop, root); + print_iterator_declarations(file, program, options); + if(annotate_result & CLAST_PARALLEL_VEC) + print_declarations(file, 2, parvar); clast_pprint(file, root, coordinates->indent, options); cloog_clast_free(root); diff --git a/test/openscop/loops.c b/test/openscop/loops.c index b0bfa88..07a6833 100644 --- a/test/openscop/loops.c +++ b/test/openscop/loops.c @@ -11,10 +11,15 @@ #endif /* matmul.c 128*128 matrix multiply */ #pragma scop + /* Scattering iterators. */ + int t2, t3, t4, t5, t6, t9; + /* Original iterators. */ + int i, j, k, l, m, n; + int lbv, ubv; if (N >= 1) { lbp=0; ubp=floord(N-1,32); -#pragma omp parallel for private(lbv,ubv) +#pragma omp parallel for private(lbv,ubv,t3,t4,t5,t6,t7,t8,t9) for (t2=lbp;t2<=ubp;t2++) { for (t3=0;t3<=floord(N-1,32);t3++) { for (t4=32*t2;t4<=min(N-1,32*t2+31);t4++) { @@ -30,7 +35,7 @@ } lbp=0; ubp=floord(N-1,32); -#pragma omp parallel for private(lbv,ubv) +#pragma omp parallel for private(lbv,ubv,t3,t4,t5,t6,t7,t8,t9) for (t2=lbp;t2<=ubp;t2++) { for (t3=0;t3<=floord(N-1,32);t3++) { for (t4=0;t4<=floord(N-1,32);t4++) { diff --git a/test/openscop/loops.scop b/test/openscop/loops.scop index 8c88716..9a7f178 100644 --- a/test/openscop/loops.scop +++ b/test/openscop/loops.scop @@ -190,7 +190,7 @@ t2 # Statement identifiers 1 # Private variables -lbv,ubv +lbv,ubv,t3,t4,t5,t6,t7,t8,t9 # Directive 1 # =========================================== @@ -202,7 +202,7 @@ t2 # Statement identifiers 2 # Private variables -lbv,ubv +lbv,ubv,t3,t4,t5,t6,t7,t8,t9 # Directive 1 # =========================================== -- 2.11.4.GIT