Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/cloog/clast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions source/clast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions source/pprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If we consider "#pragma" as implicit in OpenScop, print it here,
  • If the line is not >80 columns, don't break it

Something like:
if ((f->parallel & CLAST_PARALLEL_USR) && (f->usr)) {
fprintf(dst, "#pragma %s\n", f->usr);

(f->usr)? f->usr: "");
fprintf(dst, "%*s", indent, "");
}

}

Expand Down
6 changes: 6 additions & 0 deletions source/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down