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
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pkgextensionsinclude_HEADERS = \
include/osl/extensions/arrays.h \
include/osl/extensions/coordinates.h \
include/osl/extensions/irregular.h \
include/osl/extensions/cloogoptions.h \
include/osl/extensions/symbols.h \
include/osl/extensions/loop.h \
include/osl/extensions/extbody.h \
Expand All @@ -129,6 +130,7 @@ libosl_la_SOURCES = \
source/extensions/arrays.c \
source/extensions/coordinates.c \
source/extensions/irregular.c \
source/extensions/cloogoptions.c \
source/extensions/symbols.c \
source/extensions/extbody.c \
source/extensions/loop.c \
Expand Down
139 changes: 139 additions & 0 deletions doc/openscop.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,7 @@ particular, the sender fully accepts the license and copyright notice.
* Extbody Extension::
* Loop Extension::
* Pluto unroll Extension::
* Cloogoptions Extension::
* Irregular Extension::
@end menu

Expand Down Expand Up @@ -2993,6 +2994,144 @@ typedef struct osl_pluto_unroll * osl_pluto_unroll_p;
@end example


@node Cloogoptions Extension
@subsection Cloogoptions Extension

@noindent @strong{Description}
@itemize @bullet
@item URI: @code{cloogoptions}.
@item Author: Taj Muhammad Khan <taj.khan@@inria.fr>.
@item Purpose: the @code{cloogoptions} extension provides a mean to pass
options to CLooG for each SCoP. It is a way to control CLooG's code generation
options at SCoP level.
@end itemize

@noindent The @code{cloogoptions} extension file format respects the following
grammar.

@example
Cloogoptions_generic ::= "<cloogoptions>" Cloogoptions "</cloogoptions>"
Cloogoptions ::= option_val_list
option_val_list ::= option_val option_val_list | (void)
option_val ::= option val_list | option string
val_list ::= val val_list | (void)
option ::= _String
string ::= _String
val ::= _Integer
@end example

@noindent This extension can be used to pass options to CLooG. It contains most of
the options contained in the @code{CloogOptions} structure present in CLooG.
@noindent Further explanation can be sought in comments in the data structure
further below.

@noindent Following is an example of a correct @code{CloogOptions} description printed in
a SCoP file:

@example
<cloogoptions>
l -1 # Last level to optimize
f 1 # First level to optimize
fs-ls-size 3 # size of fs and ls arrays
ls 1 2 3 # Last level to optimize (statement wise)
fs 1 2 3 # First level to optimize (statement wise)
stop 1 # Level to stop code generation
sh 0 # Compute simple hulls
first-unroll 1 # First dimension to unroll
otl 1 # Eliminate one time loops
esp 1 # Spread equalities
fsp 1 # Level to start spreading equalities
block 0 # Make block per dimension
compilable 0 # Generate compilable code
callable 0 # Generate callable code
language 0 # Language: 1 Fortran, 0 C
name dingdong.c # Name of the input file
save-domains 0 # Save copy of domain
openscop 1 # Input has openscop format
quiet 1 # Quiet
</cloogoptions>
@end example

@noindent @strong{Data Structure}

@noindent The @code{cloogoptions} extension data structure is provided below.
For each field of the structure, there's a flag @code{fieldname_set} which indicates whether
the value in the corresponding field is valid or not:

@example
struct osl_cloogoptions
@{
/* OPTIONS FOR LOOP GENERATION */
int l; /* Last level to optimize. */
int l_set; /* l is set. */
int f; /* First level to optimize. */
int f_set; /* f is set. */

int *ls; /* Last level to optimize (statement-wise). */
int ls_set; /* ls is set. */
int *fs; /* First level to optimize (statement-wise). */
int fs_set; /* fs is set. */
int fs_ls_size; /* Size of the fs and ls arrays (same size) */
int fs_ls_size_set; /* fs_ls_size is set */
int stop; /* Level to stop code generation. */
int stop_set; /* stop is set. */
int strides; /* 1 if user wants to handle non-unit strides (then loop
* increment can be something else than one),
* 0 otherwise.
*/
int strides_set; /* strides is set. */
int sh; /* 1 for computing simple hulls */
int sh_set; /* sh is set. */
int first_unroll; /* The first dimension to unroll */
int first_unroll_set; /* first_unroll is set. */

/* OPTIONS FOR PRETTY PRINTING */
int esp; /* 1 if user wants to spread all equalities, i.e. when
* it is something like "i = 3*j + 1 ; A[i] = 0 ;" the
* generator will write "A[3*j + 1] = 0 ;", 0 otherwise.
*/
int esp_set; /* esp is set. */
int fsp; /* The iteration level where equalities spreading can
* begin (it might happen that the user wants not to
* spread values of scattering iterators).
*/
int fsp_set; /* fsp is set. */
int otl; /* 1 for eliminate loops running just one time and write
* them as an affectation of the iterator, 0 otherwise.
*/
int otl_set; /* otl is set. */
int block; /* 1 to make one new block @{...@} per new dimension,
* 0 otherwise.
*/
int block_set; /* block is set. */
int compilable; /* 1 to generate a compilable code by using
* preprocessing, 0 otherwise.
*/
int compilable_set; /* compilable is set. */
int callable; /* 1 to generate callable code by using
* preprocessing, 0 otherwise.
*/
int callable_set; /* callable is set. */
int language; /* 1 to generate FORTRAN, 0 for C otherwise. */
int language_set; /* language is set. */

int save_domains; /* Save unsimplified copy of domain. */
int save_domains_set; /* save_domains is set. */

/* MISC OPTIONS */
char * name; /* Name of the input file. */
int name_set;
int openscop; /* 1 if input file has OpenScop format, 0 otherwise. */
int openscop_set; /* openscop is set. */

int quiet; /* Don't print any informational messages. */
int quiet_set; /* quiet is set. */
@} ;
typedef struct osl_cloogoptions osl_cloogoptions_t;
typedef struct osl_cloogoptions * osl_cloogoptions_p;
@end example


@c ---------------------------------------------------------------------------


Expand Down
182 changes: 182 additions & 0 deletions include/osl/extensions/cloogoptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@

/*+-----------------------------------------------------------------**
** OpenScop Library **
**-----------------------------------------------------------------**
** extensions/cloogoptions.h **
**-----------------------------------------------------------------**
** First version: 14/05/2013 **
**-----------------------------------------------------------------**


*****************************************************************************
* OpenScop: Structures and formats for polyhedral tools to talk together *
*****************************************************************************
* ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__, *
* / / / // // // // / / / // // / / // / /|,_, *
* / / / // // // // / / / // // / / // / / / /\ *
* |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/ \ *
* | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\ \ /\ *
* | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\ *
* | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \ \ *
* | P |n| l | = | s | t |=| = |d| = | = | = | | |=| o | | \# \ \ *
* | H | | y | | e | o | | = |l| | | = | | | | G | | \ \ \ *
* | I | | | | e | | | | | | | | | | | | | \ \ \ *
* | T | | | | | | | | | | | | | | | | | \ \ \ *
* | E | | | | | | | | | | | | | | | | | \ \ \ *
* | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | / \* \ \ *
* | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/ \ \ / *
* '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---' '--' *
* *
* Copyright (C) 2008 University Paris-Sud 11 and INRIA *
* *
* (3-clause BSD license) *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
* OpenScop Library, a library to manipulate OpenScop formats and data *
* structures. Written by: *
* Cedric Bastoul <Cedric.Bastoul@u-psud.fr> and *
* Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr> *
* *
*****************************************************************************/


#ifndef OSL_CLOOGOPTIONS_H
# define OSL_CLOOGOPTIONS_H

# include <stdio.h>
# include <osl/interface.h>

# if defined(__cplusplus)
extern "C"
{
# endif


# define OSL_URI_CLOOGOPTIONS "cloogoptions"


struct osl_cloogoptions
{
/* OPTIONS FOR LOOP GENERATION */
int l; /* Last level to optimize. */
int l_set; /* l is set. */
int f; /* First level to optimize. */
int f_set; /* f is set. */

int *ls; /* Last level to optimize (statement-wise). */
int ls_set; /* ls is set. */
int *fs; /* First level to optimize (statement-wise). */
int fs_set; /* fs is set. */
int fs_ls_size; /* Size of the fs and ls arrays (same size) */
int fs_ls_size_set; /* fs_ls_size is set */
int stop; /* Level to stop code generation. */
int stop_set; /* stop is set. */
int strides; /* 1 if user wants to handle non-unit strides (then loop
* increment can be something else than one), 0 otherwise.
*/
int strides_set; /* strides is set. */
int sh; /* 1 for computing simple hulls */
int sh_set; /* sh is set. */
int first_unroll; /* The first dimension to unroll */
int first_unroll_set; /* first_unroll is set. */

/* OPTIONS FOR PRETTY PRINTING */
int esp; /* 1 if user wants to spread all equalities, i.e. when there
* is something like "i = 3*j + 1 ; A[i] = 0 ;" the
* generator will write "A[3*j + 1] = 0 ;", 0 otherwise.
*/
int esp_set; /* esp is set. */
int fsp; /* The iteration level where equalities spreading can begin
* (it might happen that the user wants not to spread values
* of scattering iterators).
*/
int fsp_set; /* fsp is set. */
int otl; /* 1 for eliminate loops running just one time and write
* them as an affectation of the iterator, 0 otherwise.
*/
int otl_set; /* otl is set. */
int block; /* 1 to make one new block {...} per new dimension,
* 0 otherwise.
*/
int block_set; /* block is set. */
int compilable; /* 1 to generate a compilable code by using
* preprocessing, 0 otherwise.
*/
int compilable_set; /* compilable is set. */
int callable; /* 1 to generate callable code by using
* preprocessing, 0 otherwise.
*/
int callable_set; /* callable is set. */
int language; /* 1 to generate FORTRAN, 0 for C otherwise. */
int language_set; /* language is set. */

int save_domains; /* Save unsimplified copy of domain. */
int save_domains_set; /* save_domains is set. */

/* MISC OPTIONS */
char * name; /* Name of the input file. */
int name_set; /* Name of the input file is set*/
int openscop; /* 1 if the input file has OpenScop format, 0 otherwise. */
int openscop_set; /* openscop is set. */

int quiet; /* Don't print any informational messages. */
int quiet_set; /* quiet is set. */
} ;

typedef struct osl_cloogoptions osl_cloogoptions_t;
typedef struct osl_cloogoptions * osl_cloogoptions_p;

/*+***************************************************************************
* Structure display function *
*****************************************************************************/
void osl_cloogoptions_idump(FILE *, osl_cloogoptions_p, int);
void osl_cloogoptions_dump(FILE *, osl_cloogoptions_p);
char* osl_cloogoptions_sprint(osl_cloogoptions_p);


/*****************************************************************************
* Reading function *
*****************************************************************************/
osl_cloogoptions_p osl_cloogoptions_sread(char **);

/*+***************************************************************************
* Memory allocation/deallocation function *
*****************************************************************************/
osl_cloogoptions_p osl_cloogoptions_malloc();
void osl_cloogoptions_free(osl_cloogoptions_p);


/*+***************************************************************************
* Processing functions *
*****************************************************************************/
osl_cloogoptions_p osl_cloogoptions_clone(osl_cloogoptions_p);
int osl_cloogoptions_equal(osl_cloogoptions_p, osl_cloogoptions_p);
osl_interface_p osl_cloogoptions_interface();


# if defined(__cplusplus)
}
# endif

#endif /* define OSL_CLOOGOPTIONS_H */
2 changes: 2 additions & 0 deletions include/osl/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ char * osl_util_strdup(char const *);
int osl_util_get_precision();
void osl_util_print_provided(FILE *, int, char *);
char * osl_util_identifier_substitution(char *, char **);
int osl_util_read_arg_int(int, char**, int*);
int osl_util_read_arg_string(int, char**, char**);


# if defined(__cplusplus)
Expand Down
Loading