Skip to content

Commit

Permalink
dump ScatteringList in cloog_program_dump_cloog
Browse files Browse the repository at this point in the history
In case a scattering list is supplied to cloog_program_dump_cloog
a CLooG input file is produced, that describes the CloogProgram (before the
scattering is applied) and the scattering to be applied to the CloogProgram.

In case no scattering list is supplied (scattering is NULL) the current
behaviour is unchanged. cloog_program_dump_cloog assumes the scattering was
already applied.

Signed-off-by: Tobias Grosser <grosser@fim.uni-passau.de>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
  • Loading branch information
tobiasgrosser authored and Sven Verdoolaege committed Jun 16, 2010
1 parent 341b1cd commit efe35d1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
2 changes: 2 additions & 0 deletions include/cloog/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ typedef struct cloogscatteringlist CloogScatteringList;
******************************************************************************/
void cloog_domain_print_constraints(FILE *, CloogDomain *,
int print_number);
void cloog_scattering_print_constraints(FILE *, CloogScattering *,
int print_number);
void cloog_domain_free(CloogDomain *) ;
void cloog_scattering_free(CloogScattering *);
CloogDomain * cloog_domain_copy(CloogDomain *) ;
Expand Down
2 changes: 1 addition & 1 deletion include/cloog/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ typedef struct cloogprogram CloogProgram ;
void cloog_program_print_structure(FILE *, CloogProgram *, int) ;
void cloog_program_print(FILE *, CloogProgram *) ;
void cloog_program_pprint(FILE *, CloogProgram *, CloogOptions *) ;
void cloog_program_dump_cloog(FILE *, CloogProgram *) ;
void cloog_program_dump_cloog(FILE *, CloogProgram *, CloogScatteringList *);


/******************************************************************************
Expand Down
13 changes: 13 additions & 0 deletions source/isl/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ void cloog_domain_print_constraints(FILE *foo, CloogDomain *domain,
}


void cloog_scattering_print_constraints(FILE *foo, CloogScattering *scattering,
int print_number)
{
if (print_number)
isl_map_print(&scattering->map, foo, 0, ISL_FORMAT_POLYLIB);
else {
assert(scattering->map.n == 1);
isl_basic_map_print(scattering->map.p[0], foo,
0, NULL, NULL, ISL_FORMAT_POLYLIB);
}
}


void cloog_domain_free(CloogDomain * domain)
{
isl_set_free(&domain->set);
Expand Down
52 changes: 40 additions & 12 deletions source/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,22 @@ int level ;
* cloog_program_dump_cloog function:
* This function dumps a CloogProgram structure supposed to be completely
* filled in a CLooG input file (foo possibly stdout) such as CLooG can
* rebuild almost exactly the data structure from the input file (the number
* of scattering functions is lost since they are included inside the
* iteration domains, this can only lead to a less beautiful pretty printing).
* WARNING: this function do not respect CloogDomain as an object.
* - June 27th 2003: first version.
* - May 15th 2005: (debug) several patches by Kristof Beyls.
* - November 16th 2005: adaptation for CLooG 0.14.0 structures.
* rebuild almost exactly the data structure from the input file.
*
* If the scattering is already applied, the scattering parameter is supposed to
* be NULL. In this case the number of scattering functions is lost, since they
* are included inside the iteration domains. This can only lead to a less
* beautiful pretty printing.
*
* In case the scattering is not yet applied it can be passed to this function
* and will be included in the CLooG input file dump.
*/
void cloog_program_dump_cloog(FILE * foo, CloogProgram * program)
void cloog_program_dump_cloog(FILE * foo, CloogProgram * program,
CloogScatteringList *scattering)
{
int i;
CloogLoop * loop ;
CloogScatteringList *tmp_scatt;

fprintf(foo,
"# CLooG -> CLooG\n"
Expand Down Expand Up @@ -205,14 +209,38 @@ void cloog_program_dump_cloog(FILE * foo, CloogProgram * program)
loop = loop->next ;
}
fprintf(foo,"\n1 # Iterator name(s)\n") ;
for (i=0;i<program->names->nb_scattering;i++)
fprintf(foo,"%s ",program->names->scattering[i]);

/* Scattering already applied? In this case print the scattering names as
* additional iterator names. */
if (!scattering)
for (i = 0; i < program->names->nb_scattering; i++)
fprintf(foo, "%s ", program->names->scattering[i]);
for (i=0;i<program->names->nb_iterators;i++)
fprintf(foo,"%s ",program->names->iterators[i]);
fprintf(foo,"\n\n") ;

/* Scattering functions (none since included inside domains). */
fprintf(foo,"# No scattering functions.\n0\n\n") ;
/* Exit, if scattering is already applied. */
if (!scattering) {
fprintf(foo, "# No scattering functions.\n0\n\n");
return;
}

/* Scattering relations. */
fprintf(foo, "# --------------------- SCATTERING --------------------\n");

i = 0;
for (tmp_scatt = scattering; tmp_scatt; tmp_scatt = tmp_scatt->next)
i++;

fprintf(foo, "%d # Scattering functions", i);

for (tmp_scatt = scattering; tmp_scatt; tmp_scatt = tmp_scatt->next)
cloog_scattering_print_constraints(foo, tmp_scatt->scatt, 1);

fprintf(foo, "\n1 # Scattering dimension name(s)\n");

for (i = 0; i < program->names->nb_scattering; i++)
fprintf(foo, "%s ", program->names->scattering[i]);
}


Expand Down

0 comments on commit efe35d1

Please sign in to comment.