From 1c11768340703f1eebc8b74178bb0b8df56b66e5 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 31 Jul 2010 21:42:09 +0200 Subject: [PATCH] cloog_program_read: separate reading from input from construction of CloogProgram We want to be able to let the user specify the input through an API. We will then be able to reuse the construction of CloogProgram. Signed-off-by: Sven Verdoolaege --- Makefile.am | 4 + include/cloog/cloog.h | 2 + include/cloog/input.h | 20 +++ include/cloog/loop.h | 2 + include/cloog/program.h | 2 + include/cloog/union_domain.h | 48 +++++++ source/input.c | 56 +++++++++ source/loop.c | 53 +++++--- source/program.c | 184 +++++++++++++-------------- source/union_domain.c | 294 +++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 548 insertions(+), 117 deletions(-) create mode 100644 include/cloog/input.h create mode 100644 include/cloog/union_domain.h create mode 100644 source/input.c create mode 100644 source/union_domain.c diff --git a/Makefile.am b/Makefile.am index c4be087..a2f0b6a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,6 +70,7 @@ SOURCES_CORE = \ source/clast.c \ source/matrix.c \ source/state.c \ + source/input.c \ source/int.c \ source/loop.c \ source/names.c \ @@ -77,6 +78,7 @@ SOURCES_CORE = \ source/pprint.c \ source/program.c \ source/statement.c \ + source/union_domain.c \ source/version.c DEFAULT_INCLUDES = -I. @@ -98,6 +100,7 @@ pkginclude_HEADERS = \ include/cloog/block.h \ include/cloog/clast.h \ include/cloog/cloog.h \ + include/cloog/input.h \ include/cloog/int.h \ include/cloog/matrix.h \ include/cloog/state.h \ @@ -109,6 +112,7 @@ pkginclude_HEADERS = \ include/cloog/pprint.h \ include/cloog/program.h \ include/cloog/statement.h \ + include/cloog/union_domain.h \ include/cloog/version.h pkgmatrixincludedir = $(pkgincludedir)/matrix diff --git a/include/cloog/cloog.h b/include/cloog/cloog.h index f49a102..a1d6ac2 100644 --- a/include/cloog/cloog.h +++ b/include/cloog/cloog.h @@ -52,6 +52,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/include/cloog/input.h b/include/cloog/input.h new file mode 100644 index 0000000..1b05748 --- /dev/null +++ b/include/cloog/input.h @@ -0,0 +1,20 @@ +#ifndef CLOOG_INPUT_H +#define CLOOG_INPUT_H + +#if defined(__cplusplus) +extern "C" { +#endif + +struct clooginput { + CloogDomain *context; + CloogUnionDomain *ud; +}; +typedef struct clooginput CloogInput; + +CloogInput *cloog_input_read(FILE *file, CloogOptions *options); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/include/cloog/loop.h b/include/cloog/loop.h index e55b8b3..168c9de 100644 --- a/include/cloog/loop.h +++ b/include/cloog/loop.h @@ -95,6 +95,8 @@ void cloog_loop_free(CloogLoop *) ; /****************************************************************************** * Reading functions * ******************************************************************************/ +CloogLoop *cloog_loop_from_domain(CloogState *state, CloogDomain *domain, + int number); CloogLoop * cloog_loop_read(CloogState *state, FILE * foo, int number, int nb_parameters); diff --git a/include/cloog/program.h b/include/cloog/program.h index 725484a..530d21f 100644 --- a/include/cloog/program.h +++ b/include/cloog/program.h @@ -99,6 +99,8 @@ CloogProgram * cloog_program_read(FILE *, CloogOptions *) ; * Processing functions * ******************************************************************************/ CloogProgram * cloog_program_malloc(void); +CloogProgram * cloog_program_alloc(CloogDomain *context, CloogUnionDomain *ud, + CloogOptions *options); CloogProgram * cloog_program_generate(CloogProgram *, CloogOptions *) ; void cloog_program_block(CloogProgram *program, CloogScatteringList *scattering, CloogOptions *options); diff --git a/include/cloog/union_domain.h b/include/cloog/union_domain.h new file mode 100644 index 0000000..7fc9eef --- /dev/null +++ b/include/cloog/union_domain.h @@ -0,0 +1,48 @@ +#ifndef CLOOG_UNION_DOMAIN_H +#define CLOOG_UNION_DOMAIN_H + +#if defined(__cplusplus) +extern "C" { +#endif + +/** + * CloogNamedDomainList structure: + * this structure reprensents a node of a linked list of CloogDomain structures. + */ +struct cloognameddomainlist { + CloogDomain *domain; /**< An element of the list. */ + CloogScattering *scattering; /**< Scattering function for domain. */ + char *name; /**< Name of the domain. */ + void *usr; /**< A pointer for library user's convenience. */ + struct cloognameddomainlist *next;/**< Pointer to the next element of the list.*/ +}; +typedef struct cloognameddomainlist CloogNamedDomainList; + +/** + * A structure representing the input domains and scattering functions. + */ +struct clooguniondomain { + int n_name[3]; + char **name[3]; + CloogNamedDomainList *domain; + CloogNamedDomainList **next_domain; +}; +typedef struct clooguniondomain CloogUnionDomain; + +enum cloog_dim_type { CLOOG_PARAM, CLOOG_ITER, CLOOG_SCAT }; + +CloogUnionDomain *cloog_union_domain_read(FILE *file, int nb_par, + CloogOptions *options); +CloogUnionDomain *cloog_union_domain_alloc(int nb_par); +CloogUnionDomain *cloog_union_domain_add_domain(CloogUnionDomain *ud, + const char *name, CloogDomain *domain, CloogScattering *scattering, + void *usr); +CloogUnionDomain *cloog_union_domain_set_name(CloogUnionDomain *ud, + enum cloog_dim_type type, int index, const char *name); +void cloog_union_domain_free(CloogUnionDomain *ud); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/source/input.c b/source/input.c new file mode 100644 index 0000000..d2fd261 --- /dev/null +++ b/source/input.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include "../include/cloog/cloog.h" + +#define ALLOC(type) (type*)malloc(sizeof(type)) + +static char *next_line(FILE *input, char *line, unsigned len) +{ + char *p; + + do { + if (!(p = fgets(line, len, input))) + return NULL; + while (isspace(*p) && *p != '\n') + ++p; + } while (*p == '#' || *p == '\n'); + + return p; +} + +/** + * Read input from a .cloog file, putting most of the information + * in the returned CloogInput. The chosen language is put in + * options->language. + */ +CloogInput *cloog_input_read(FILE *file, CloogOptions *options) +{ + char line[MAX_STRING]; + CloogInput *input; + char language; + int nb_par; + + input = ALLOC(CloogInput); + if (!input) + cloog_die("memory overflow.\n"); + + /* First of all, we read the language to use. */ + if (!next_line(file, line, sizeof(line))) + cloog_die("Input error.\n"); + if (sscanf(line, "%c", &language) != 1) + cloog_die("Input error.\n"); + + if (language == 'f') + options->language = LANGUAGE_FORTRAN; + else + options->language = LANGUAGE_C; + + /* We then read the context data. */ + input->context = cloog_domain_read_context(options->state, file); + nb_par = cloog_domain_parameter_dimension(input->context); + + input->ud = cloog_union_domain_read(file, nb_par, options); + + return input; +} diff --git a/source/loop.c b/source/loop.c index a41713e..b1317ef 100644 --- a/source/loop.c +++ b/source/loop.c @@ -260,23 +260,13 @@ int domain, block, inner, next ; /** - * cloog_loop_read function: - * This function reads loop data into a file (foo, possibly stdin) and - * returns a pointer to a CloogLoop structure containing the read information. - * This function can be used only for input file reading, when one loop is - * associated with one statement. - * - number is the statement block number carried by the loop (-1 if none). - * - nb_parameters is the number of parameters. - ** - * - September 9th 2002: first version. - * - April 16th 2005: adaptation to new CloogStatement struct (with number). - * - June 11th 2005: adaptation to new CloogBlock structure. - * - June 22nd 2005: Adaptation for GMP. + * Construct a CloogLoop structure from a given iteration domain + * and statement number. */ -CloogLoop *cloog_loop_read(CloogState *state, - FILE * foo, int number, int nb_parameters) -{ int nb_iterators, op1, op2, op3 ; - char s[MAX_STRING] ; +CloogLoop *cloog_loop_from_domain(CloogState *state, CloogDomain *domain, + int number) +{ + int nb_iterators; CloogLoop * loop ; CloogStatement * statement ; @@ -288,7 +278,7 @@ CloogLoop *cloog_loop_read(CloogState *state, cloog_die("memory overflow.\n"); /* domain. */ loop->state = state; - loop->domain = cloog_domain_union_read(state, foo, nb_parameters); + loop->domain = domain; if (loop->domain != NULL) nb_iterators = cloog_domain_dimension(loop->domain); else @@ -307,13 +297,40 @@ CloogLoop *cloog_loop_read(CloogState *state, loop->inner = NULL ; /* next element. */ loop->next = NULL ; + + return loop ; +} + + +/** + * cloog_loop_read function: + * This function reads loop data from a file (foo, possibly stdin) and + * returns a pointer to a CloogLoop structure containing the read information. + * This function can be used only for input file reading, when one loop is + * associated with one statement. + * - number is the statement block number carried by the loop (-1 if none). + * - nb_parameters is the number of parameters. + ** + * - September 9th 2002: first version. + * - April 16th 2005: adaptation to new CloogStatement struct (with number). + * - June 11th 2005: adaptation to new CloogBlock structure. + * - June 22nd 2005: Adaptation for GMP. + */ +CloogLoop *cloog_loop_read(CloogState *state, + FILE *foo, int number, int nb_parameters) +{ + int op1, op2, op3; + char s[MAX_STRING]; + CloogDomain *domain; + + domain = cloog_domain_union_read(state, foo, nb_parameters); /* To read that stupid "0 0 0" line. */ while (fgets(s,MAX_STRING,foo) == 0) ; while ((*s=='#' || *s=='\n') || (sscanf(s," %d %d %d",&op1,&op2,&op3)<3)) fgets(s,MAX_STRING,foo) ; - return loop ; + return cloog_loop_from_domain(state, domain, number); } diff --git a/source/program.c b/source/program.c index dc289ec..1076deb 100644 --- a/source/program.c +++ b/source/program.c @@ -51,6 +51,8 @@ # include #endif +#define ALLOC(type) (type*)malloc(sizeof(type)) + /****************************************************************************** * Structure display function * @@ -500,42 +502,6 @@ void cloog_program_free(CloogProgram * program) ******************************************************************************/ -/** - * cloog_scattering_list_read - * Read in a list of scattering functions for the nb_statements - * domains in loop. - */ -static CloogScatteringList *cloog_scattering_list_read(FILE * foo, - CloogLoop *loop, int nb_statements, int nb_parameters) -{ - int nb_scat = 0; - char s[MAX_STRING]; - CloogScatteringList *list = NULL, **next = &list; - - /* We read first the number of scattering functions in the list. */ - do { - if (!fgets(s, MAX_STRING, foo)) - break; - } while ((*s=='#' || *s=='\n') || (sscanf(s, " %d", &nb_scat) < 1)); - - if (nb_scat == 0) - return NULL; - - if (nb_scat > nb_statements) - cloog_die("too many scattering functions.\n"); - - while (nb_scat--) { - *next = (CloogScatteringList *)malloc(sizeof(CloogScatteringList)); - (*next)->scatt = cloog_domain_read_scattering(loop->domain, foo); - (*next)->next = NULL; - - next = &(*next)->next; - loop = loop->next; - } - return list; -} - - static void cloog_program_construct_block_list(CloogProgram *p) { CloogLoop *loop; @@ -549,20 +515,14 @@ static void cloog_program_construct_block_list(CloogProgram *p) /** - * cloog_program_read function: - * This function read the informations to put in a CloogProgram structure from - * a file (file, possibly stdin). It returns a pointer to a CloogProgram - * structure containing the read informations. - * - October 25th 2001: first version. - * - September 9th 2002: - the big reading function is now split in several - * functions (one per read data structure). - * - adaptation to the new file format with naming. + * Construct a CloogProgram structure from a given context and + * union domain representing the iteration domains and scattering functions. */ -CloogProgram * cloog_program_read(FILE * file, CloogOptions * options) +CloogProgram *cloog_program_alloc(CloogDomain *context, CloogUnionDomain *ud, + CloogOptions *options) { - int i, nb_statements; - char s[MAX_STRING], language, prefix[2]={'c','\0'}; - CloogLoop * current, * next ; + int i; + char prefix[] = "c"; CloogScatteringList * scatteringl; CloogNames *n; CloogProgram * p ; @@ -570,66 +530,67 @@ CloogProgram * cloog_program_read(FILE * file, CloogOptions * options) /* Memory allocation for the CloogProgram structure. */ p = cloog_program_malloc() ; - /* First of all, we read the language to use. */ - while (fgets(s,MAX_STRING,file) == 0) ; - while ((*s=='#'||*s=='\n') || (sscanf(s," %c",&language)<1)) - fgets(s,MAX_STRING,file) ; - p->language = language ; + if (options->language == LANGUAGE_FORTRAN) + p->language = 'f'; + else + p->language = 'c'; p->names = n = cloog_names_alloc(); /* We then read the context data. */ - p->context = cloog_domain_read_context(options->state, file); - n->nb_parameters = cloog_domain_parameter_dimension(p->context); + p->context = context; + n->nb_parameters = ud->n_name[CLOOG_PARAM]; - /* First part of the CloogNames structure: reading of the parameter names. */ - n->parameters = cloog_names_read_strings(file, n->nb_parameters, - NULL, FIRST_PARAMETER); - - /* We read the statement number. */ - while (fgets(s,MAX_STRING,file) == 0) ; - while ((*s=='#'||*s=='\n') || (sscanf(s," %d",&nb_statements)<1)) - fgets(s,MAX_STRING,file) ; - - /* Statements and domains reading for each statement. */ - if (nb_statements > 0) - { /* Reading of the first domain. */ - p->loop = cloog_loop_read(options->state, file, 0, n->nb_parameters); - - if (p->loop->domain != NULL) - n->nb_iterators = cloog_domain_dimension(p->loop->domain); - else - n->nb_iterators = 0; - - /* And the same for each next domain. */ - current = p->loop ; - for (i=2;i<=nb_statements;i++) { - next = cloog_loop_read(options->state, file, i-1, n->nb_parameters); - if (next->domain != NULL && - cloog_domain_dimension(next->domain) > n->nb_iterators) - n->nb_iterators = cloog_domain_dimension(next->domain); - - current->next = next ; - current = current->next ; - } - - /* Reading of the iterator names. */ - n->iterators = cloog_names_read_strings(file, n->nb_iterators, - NULL, FIRST_ITERATOR); + /* First part of the CloogNames structure: the parameter names. */ + if (ud->name[CLOOG_PARAM]) { + n->parameters = ud->name[CLOOG_PARAM]; + ud->name[CLOOG_PARAM] = NULL; + } else + n->parameters = cloog_names_generate_items(n->nb_parameters, NULL, + FIRST_PARAMETER); + + n->nb_iterators = ud->n_name[CLOOG_ITER]; + if (ud->name[CLOOG_ITER]) { + n->iterators = ud->name[CLOOG_ITER]; + ud->name[CLOOG_ITER] = NULL; + } else + n->iterators = cloog_names_generate_items(n->nb_iterators, NULL, + FIRST_ITERATOR); + + if (ud->domain) { + CloogNamedDomainList *l; + CloogLoop **next = &p->loop; + CloogScatteringList **next_scat = &scatteringl; + + scatteringl = NULL; + for (i = 0, l = ud->domain; l; ++i, l = l->next) { + *next = cloog_loop_from_domain(options->state, l->domain, i); + l->domain = NULL; + (*next)->block->statement->name = l->name; + (*next)->block->statement->usr = l->usr; + l->name = NULL; + + if (l->scattering) { + *next_scat = ALLOC(CloogScatteringList); + (*next_scat)->scatt = l->scattering; + l->scattering = NULL; + (*next_scat)->next = NULL; + + next_scat = &(*next_scat)->next; + } - /* Reading and putting the scattering data in program structure. */ - scatteringl = cloog_scattering_list_read(file, p->loop, nb_statements, - n->nb_parameters); - - if (scatteringl != NULL) - { if (cloog_scattering_list_lazy_same(scatteringl)) - cloog_msg(options, CLOOG_WARNING, - "some scattering functions are similar.\n"); - + next = &(*next)->next; + } + + if (scatteringl != NULL) { p->nb_scattdims = cloog_scattering_dimension(scatteringl->scatt, p->loop->domain); n->nb_scattering = p->nb_scattdims; - n->scattering = cloog_names_read_strings(file, p->nb_scattdims, prefix, -1); + if (ud->name[CLOOG_SCAT]) { + n->scattering = ud->name[CLOOG_SCAT]; + ud->name[CLOOG_SCAT] = NULL; + } else + n->scattering = cloog_names_generate_items(n->nb_scattering, prefix, -1); /* The boolean array for scalar dimensions is created and set to 0. */ p->scaldims = (int *)malloc(p->nb_scattdims*(sizeof(int))) ; @@ -664,11 +625,36 @@ CloogProgram * cloog_program_read(FILE * file, CloogOptions * options) p->blocklist = NULL ; p->scaldims = NULL ; } + + cloog_union_domain_free(ud); return(p) ; } +/** + * cloog_program_read function: + * This function read the informations to put in a CloogProgram structure from + * a file (file, possibly stdin). It returns a pointer to a CloogProgram + * structure containing the read informations. + * - October 25th 2001: first version. + * - September 9th 2002: - the big reading function is now split in several + * functions (one per read data structure). + * - adaptation to the new file format with naming. + */ +CloogProgram *cloog_program_read(FILE *file, CloogOptions *options) +{ + CloogInput *input; + CloogProgram *p; + + input = cloog_input_read(file, options); + p = cloog_program_alloc(input->context, input->ud, options); + free(input); + + return p; +} + + /****************************************************************************** * Processing functions * ******************************************************************************/ diff --git a/source/union_domain.c b/source/union_domain.c new file mode 100644 index 0000000..6256a73 --- /dev/null +++ b/source/union_domain.c @@ -0,0 +1,294 @@ +#include +#include +#include +#include "../include/cloog/cloog.h" + +#define ALLOC(type) (type*)malloc(sizeof(type)) +#define ALLOCN(type,n) (type*)malloc((n)*sizeof(type)) + +void cloog_named_domain_list_free(CloogNamedDomainList *list) +{ + while (list != NULL) { + CloogNamedDomainList *temp = list->next; + cloog_domain_free(list->domain); + cloog_scattering_free(list->scattering); + free(list->name); + free(list); + list = temp; + } +} + +CloogUnionDomain *cloog_union_domain_alloc(int nb_par) +{ + CloogUnionDomain *ud; + + ud = ALLOC(CloogUnionDomain); + if (!ud) + cloog_die("memory overflow.\n"); + + ud->domain = NULL; + ud->next_domain = &ud->domain; + + ud->n_name[CLOOG_PARAM] = nb_par; + ud->n_name[CLOOG_ITER] = 0; + ud->n_name[CLOOG_SCAT] = 0; + + ud->name[CLOOG_PARAM] = NULL; + ud->name[CLOOG_ITER] = NULL; + ud->name[CLOOG_SCAT] = NULL; + + return ud; +} + +void cloog_union_domain_free(CloogUnionDomain *ud) +{ + int i; + int j; + + if (!ud) + return; + + for (i = 0; i < 3; ++i) { + if (!ud->name[i]) + continue; + for (j = 0; j < ud->n_name[i]; ++i) + free(ud->name[i][j]); + free(ud->name[i]); + } + + cloog_named_domain_list_free(ud->domain); + + free(ud); +} + +/** + * Add a domain with scattering function to the union of domains. + * name may be NULL and is duplicated if it is not. + * domain and scattering are taken over by the CloogUnionDomain. + * scattering may be NULL. + */ +CloogUnionDomain *cloog_union_domain_add_domain(CloogUnionDomain *ud, + const char *name, CloogDomain *domain, CloogScattering *scattering, + void *usr) +{ + CloogNamedDomainList *named; + int n; + + if (!ud) + return NULL; + + named = ALLOC(CloogNamedDomainList); + if (!named) + cloog_die("memory overflow.\n"); + + if (ud->name[CLOOG_ITER]) + cloog_die("iterator names must be set after adding domains.\n"); + if (ud->name[CLOOG_SCAT]) + cloog_die("scattering names must be set after adding domains.\n"); + + n = cloog_domain_dimension(domain); + if (n > ud->n_name[CLOOG_ITER]) + ud->n_name[CLOOG_ITER] = n; + + if (scattering) { + n = cloog_scattering_dimension(scattering, domain); + if (n > ud->n_name[CLOOG_SCAT]) + ud->n_name[CLOOG_SCAT] = n; + } + + named->domain = domain; + named->scattering = scattering; + named->name = name ? strdup(name) : NULL; + named->usr = usr; + named->next = NULL; + + *ud->next_domain = named; + ud->next_domain = &named->next; + + return ud; +} + +/** + * Set the name of parameter, iterator or scattering dimension + * at the specified position. The name is duplicated. + */ +CloogUnionDomain *cloog_union_domain_set_name(CloogUnionDomain *ud, + enum cloog_dim_type type, int index, const char *name) +{ + int i; + + if (!ud) + return ud; + + if (type != CLOOG_PARAM && + type != CLOOG_ITER && + type != CLOOG_SCAT) + cloog_die("invalid dim type\n"); + + if (index < 0 || index >= ud->n_name[type]) + cloog_die("index out of range\n"); + + if (!ud->name[type]) { + ud->name[type] = ALLOCN(char *, ud->n_name[type]); + if (!ud->name[type]) + cloog_die("memory overflow.\n"); + for (i = 0; i < ud->n_name[type]; ++i) + ud->name[type][i] = NULL; + } + + ud->name[type][index] = strdup(name); + if (!ud->name[type][index]) + cloog_die("memory overflow.\n"); + + return ud; +} + +static char *next_line(FILE *input, char *line, unsigned len) +{ + char *p; + + do { + if (!(p = fgets(line, len, input))) + return NULL; + while (isspace(*p) && *p != '\n') + ++p; + } while (*p == '#' || *p == '\n'); + + return p; +} + +/** + * cloog_scattering_list_read + * Read in a list of scattering functions for the nb_statements + * domains in loop. + */ +static CloogScatteringList *cloog_scattering_list_read(FILE * foo, + CloogDomain **domain, int nb_statements, int nb_parameters) +{ + int nb_scat = 0; + char s[MAX_STRING]; + CloogScatteringList *list = NULL, **next = &list; + + /* We read first the number of scattering functions in the list. */ + do { + if (!fgets(s, MAX_STRING, foo)) + break; + } while ((*s=='#' || *s=='\n') || (sscanf(s, " %d", &nb_scat) < 1)); + + if (nb_scat == 0) + return NULL; + + if (nb_scat != nb_statements) + cloog_die("wrong number of scattering functions.\n"); + + while (nb_scat--) { + *next = (CloogScatteringList *)malloc(sizeof(CloogScatteringList)); + (*next)->scatt = cloog_domain_read_scattering(*domain, foo); + (*next)->next = NULL; + + next = &(*next)->next; + domain++; + } + return list; +} + +static CloogUnionDomain *set_names_from_list(CloogUnionDomain *ud, + enum cloog_dim_type type, int n, char **names) +{ + int i; + + for (i = 0; i < n; ++i) { + ud = cloog_union_domain_set_name(ud, type, i, names[i]); + free(names[i]); + } + free(names); + + return ud; +} + +/** + * Fill up a CloogUnionDomain from information in a CLooG input file. + * The language and the context are assumed to have been read from + * the input file already. + */ +CloogUnionDomain *cloog_union_domain_read(FILE *file, int nb_par, + CloogOptions *options) +{ + int op1, op2, op3; + char line[MAX_STRING], prefix[] = "c"; + CloogDomain **domain; + CloogUnionDomain *ud; + CloogScatteringList *scatteringl; + int i; + int n_iter = -1; + int n_dom; + char **names; + + ud = cloog_union_domain_alloc(nb_par); + + names = cloog_names_read_strings(file, nb_par, NULL, FIRST_PARAMETER); + ud = set_names_from_list(ud, CLOOG_PARAM, nb_par, names); + + /* We read the number of statements. */ + if (!next_line(file, line, sizeof(line))) + cloog_die("Input error.\n"); + if (sscanf(line, "%d", &n_dom) != 1) + cloog_die("Input error.\n"); + + domain = ALLOCN(CloogDomain *, n_dom); + if (!domain) + cloog_die("memory overflow.\n"); + + for (i = 0; i < n_dom; ++i) { + int dim; + + domain[i] = cloog_domain_union_read(options->state, file, + nb_par); + dim = cloog_domain_dimension(domain[i]); + if (dim > n_iter) + n_iter = dim; + + /* To read that stupid "0 0 0" line. */ + if (!next_line(file, line, sizeof(line))) + cloog_die("Input error.\n"); + if (sscanf(line, " %d %d %d", &op1, &op2, &op3) != 3) + cloog_die("Input error.\n"); + } + + /* Reading of the iterator names. */ + names = cloog_names_read_strings(file, n_iter, NULL, FIRST_ITERATOR); + + /* Reading and putting the scattering data in program structure. */ + scatteringl = cloog_scattering_list_read(file, domain, n_dom, nb_par); + + if (scatteringl) { + CloogScatteringList *is, *next; + + if (cloog_scattering_list_lazy_same(scatteringl)) + cloog_msg(options, CLOOG_WARNING, + "some scattering functions are similar.\n"); + + for (i = 0, is = scatteringl; i < n_dom; ++i, is = next) { + next = is->next; + ud = cloog_union_domain_add_domain(ud, NULL, domain[i], + is->scatt, NULL); + free(is); + } + } else { + for (i = 0; i < n_dom; ++i) + ud = cloog_union_domain_add_domain(ud, NULL, domain[i], + NULL, NULL); + } + + ud = set_names_from_list(ud, CLOOG_ITER, n_iter, names); + + if (scatteringl) { + int n_scat = ud->n_name[CLOOG_SCAT]; + names = cloog_names_read_strings(file, n_scat, prefix, -1); + ud = set_names_from_list(ud, CLOOG_SCAT, n_scat, names); + } + + free(domain); + + return ud; +} -- 2.11.4.GIT