diff --git a/include/cloog/options.h b/include/cloog/options.h index f4dd70e..18e327c 100644 --- a/include/cloog/options.h +++ b/include/cloog/options.h @@ -123,6 +123,7 @@ struct cloogoptions int noblocks ; /* 1 if I don't want to make statement blocks, 0 otherwise. */ int noscalars ; /* 1 if I don't want to use scalar dimensions, 0 otherwise. */ int nosimplify; /* 1 if I don't want to simplify polyhedra, 0 otherwise. */ + int scop_options;/* 1 if osl_cloogoptions are to be used */ } ; diff --git a/osl b/osl index beeef6c..b527f7a 160000 --- a/osl +++ b/osl @@ -1 +1 @@ -Subproject commit beeef6cf937b26befaac17179e9a35512c7c284d +Subproject commit b527f7a48cb086182fb19d7556c09730717f367c diff --git a/source/options.c b/source/options.c index 3689c0c..ad4443a 100644 --- a/source/options.c +++ b/source/options.c @@ -43,6 +43,7 @@ #ifdef OSL_SUPPORT #include +#include #endif @@ -160,6 +161,7 @@ void cloog_options_print(FILE * foo, CloogOptions * options) fprintf(foo,"noscalars = %3d.\n",options->noscalars) ; fprintf(foo,"noblocks = %3d.\n",options->noblocks) ; fprintf(foo,"nosimplify = %3d.\n",options->nosimplify) ; + fprintf(foo,"scopoptions = %3d.\n",options->scop_options) ; } @@ -182,6 +184,7 @@ void cloog_options_free(CloogOptions *options) #endif free(options->fs); free(options->ls); + free(options->name); free(options); } @@ -237,6 +240,7 @@ void cloog_options_help() " (default setting: stdout).\n" #ifdef OSL_SUPPORT " -openscop Input file has OpenScop format.\n" + " -scopoptions Use options passed via extension in the scop.\n" #endif " -v, --version Display the version information (and more).\n" " -q, --quiet Don't print any informational messages.\n" @@ -341,7 +345,7 @@ CloogOptions *cloog_options_malloc(CloogState *state) options->strides = 0 ; /* Generate a code with unit strides. */ options->sh = 0; /* Compute actual convex hull. */ options->first_unroll = -1; /* First level to unroll: none. */ - options->name = ""; + options->name = NULL; /* OPTIONS FOR PRETTY PRINTING */ options->esp = 1 ; /* We want Equality SPreading.*/ options->fsp = 1 ; /* The First level to SPread is the first. */ @@ -363,6 +367,7 @@ CloogOptions *cloog_options_malloc(CloogState *state) options->noblocks = 0 ; /* I do want to make statement blocks.*/ options->noscalars = 0 ; /* I do want to use scalar dimensions.*/ options->nosimplify = 0 ; /* I do want to simplify polyhedra.*/ + options->scop_options = 0 ; /* Use command line options by default.*/ return options ; } @@ -457,6 +462,13 @@ void cloog_options_read(CloogState *state, int argc, char **argv, else if (strcmp(argv[i],"-nosimplify") == 0) (*options)->nosimplify = 1 ; + else + if (strcmp(argv[i],"-scopoptions") == 0) +#ifdef OSL_SUPPORT + (*options)->scop_options = 1; +#else + cloog_die("CLooG has not been compiled with OpenScop support.\n"); +#endif else if ((strcmp(argv[i],"-struct") == 0) || (strcmp(argv[i],"-structure") == 0)) (*options)->structure = 1 ; @@ -494,7 +506,7 @@ void cloog_options_read(CloogState *state, int argc, char **argv, else { if (!input_is_set) { input_is_set = 1 ; - (*options)->name = argv[i] ; + (*options)->name = strdup(argv[i]); /* stdin is a special value, when used, we set input to standard input. */ if (strcmp(argv[i],"stdin") == 0) *input = stdin ; @@ -515,6 +527,101 @@ void cloog_options_read(CloogState *state, int argc, char **argv, } #ifdef OSL_SUPPORT +/** + * This function extracts CLooG option values from + * an OpenScop osl_cloogtopions extension + * In case no options are found in scop, it keeps the default options + * + * \param[in] scop Input Scop. + * \param[out] options Updated CloogOptions + * \return + */ +void cloog_options_extract_from_scop(osl_scop_p scop, CloogOptions *options){ + int j=0; + osl_cloogoptions_p ops = NULL; + + if (!options) + cloog_die("Options must be provided.\n"); + + if (!scop) + cloog_die("SCoP must be provided.\n"); + + ops = osl_generic_lookup(scop->extension, OSL_URI_CLOOGOPTIONS); + + if (ops!=NULL) { + /* OPTIONS FOR LOOP GENERATION */ + if (ops->l_set) + options->l = ops->l ; + if (ops->f_set) + options->f = ops->f ; + + if (ops->fs_ls_size_set) + options->fs_ls_size = ops->fs_ls_size; + if (ops->ls_set) { + free(options->ls); + if (options->fs_ls_size) { //malloc(0) returns non-NULL ptr + options->ls = (int*) malloc( ops->fs_ls_size*sizeof(int) ); + if (options->ls==NULL) + cloog_die("memory overflow.\n"); + + for (j=0; j< options->fs_ls_size; j++) { + options->ls[j] = ops->ls[j]; + } + } + } + if (ops->fs_set) { + free(options->fs); + if (options->fs_ls_size) { //malloc(0) returns non-NULL ptr + options->fs = (int*) malloc( ops->fs_ls_size*sizeof(int) ); + if (options->fs==NULL) + cloog_die("memory overflow.\n"); + + for (j=0; j< options->fs_ls_size; j++) { + options->fs[j] = ops->fs[j]; + } + } + } + + if (ops->stop_set) + options->stop = ops->stop ; + if (ops->strides_set) + options->strides = ops->strides; + if (ops->sh_set) + options->sh = ops->sh; + if (ops->first_unroll_set) + options->first_unroll = ops->first_unroll; + + if (ops->name_set) { + if(options->name) + free(options->name); + options->name = strdup(ops->name); + } + /* OPTIONS FOR PRETTY PRINTING */ + if (ops->esp_set) + options->esp = ops->esp; + if (ops->fsp_set) + options->fsp = ops->fsp; + if (ops->otl_set) + options->otl = ops->otl; + if (ops->block_set) + options->block = ops->block; + if (ops->compilable_set) + options->compilable = ops->compilable; + if (ops->callable_set) + options->callable = ops->callable; + if (ops->quiet_set) + options->quiet = ops->quiet; + if (ops->save_domains_set) + options->save_domains = ops->save_domains; + /* MISC OPTIONS */ + if (ops->language_set) + options->language = ops->language; + if (ops->openscop_set) + options->openscop = ops->openscop; + + options->scop_options = 1; + } +} /** * This function extracts CLooG option values from an OpenScop scop and * updates an existing CloogOption structure with those values. If the @@ -528,6 +635,13 @@ void cloog_options_copy_from_osl_scop(osl_scop_p scop, cloog_die("Options must be provided.\n"); if (scop) { + + /* "use options provided in scop" specified */ + if (options->scop_options) { + /* Extract the cloogoptions from osl_scop*/ + cloog_options_extract_from_scop(scop, options); + } + /* Extract the language. */ if (!strcmp(scop->language, "FORTRAN")) options->language = CLOOG_LANGUAGE_FORTRAN; @@ -535,6 +649,8 @@ void cloog_options_copy_from_osl_scop(osl_scop_p scop, options->language = CLOOG_LANGUAGE_C; /* Store the input SCoP in the option structure. */ + if(options->scop) + osl_scop_free(options->scop); options->scop = scop; } } diff --git a/source/program.c b/source/program.c index 89d6774..2caec70 100644 --- a/source/program.c +++ b/source/program.c @@ -320,6 +320,7 @@ static void print_iterator_declarations(FILE *file, CloogProgram *program, } } +#ifdef OSL_SUPPORT static int get_osl_loop_flags (osl_scop_p scop) { int flags = 0; osl_loop_p ll = osl_generic_lookup(scop->extension, OSL_URI_LOOP); @@ -360,6 +361,7 @@ static void print_iterator_declarations_osl(FILE *file, CloogProgram *program, if(loopflags & CLAST_PARALLEL_VEC) print_declarations(file, 2, vecvar); } +#endif static void print_callable_preamble(FILE *file, CloogProgram *program, CloogOptions *options) @@ -403,6 +405,7 @@ static void print_callable_postamble(FILE *file, CloogProgram *program) fprintf(file, "}\n"); } +#ifdef OSL_SUPPORT /* * add tags clast loops according to information in scop's osl_loop extension */ @@ -458,6 +461,7 @@ int annotate_loops(osl_scop_p program, struct clast_stmt *root){ return ret; } +#endif /**