manpagez: man pages & more
info cloog
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.1 A First Example

CLooG takes as input a file that must be written accordingly to a grammar described in depth in a further section (see section Writing The Input File). Moreover it supports many options to tune the target code presentation or quality as discussed in a dedicated section (see section Calling CLooG). However, a basic use of CLooG is not very complex and we present in this section how to generate the code corresponding to a basic example discussed earlier (see section Basically, what’s the point ?).

The problem is to find the code that scans a 2-dimensional polyhedron where ‘i’ and ‘j’ are the unknown (the two dimensions of the space) and ‘m’ and ‘n’ are the parameters (the symbolic constants), defined by the following set of constraints:

2<=i<=n
2<=j<=m
j<=n+2-i

We also consider a partial knowledge of the parameter values, expressed thanks to the following affine constraints:

m>=2
n>=2

An input file that corresponds to this problem, and asks for a generated code in C, may be the following. Note that we do not describe here precisely the structure and the components of this file (see section Writing The Input File for such information, if you feel it necessary):

# ---------------------- CONTEXT ----------------------
c # language is C

# Context (constraints on two parameters)
2 4                   # 2 lines and 4 columns
# eq/in m  n  1         eq/in: 1 for inequality >=0, 0 for equality =0
    1   1  0 -2       # 1*m + 0*n -2*1 >= 0, i.e. m>=2
    1   0  1 -2       # 0*m + 1*n -2*1 >= 0, i.e. n>=2

1 # We want to set manually the parameter names
m n                   # parameter names

# --------------------- STATEMENTS --------------------
1 # Number of statements

1 # First statement: one domain
# First domain
5 6                   # 5 lines and 6 columns
# eq/in i  j  m  n  1 
    1   1  0  0  0 -2 # i >= 2
    1  -1  0  0  1  0 # i <= n
    1   0  1  0  0 -2 # j >= 2
    1   0 -1  1  0  0 # j <= m
    1  -1 -1  0  1  2 # n+2-i>=j
0  0  0               # for future options

1 # We want to set manually the iterator names
i j                   # iterator names

# --------------------- SCATTERING --------------------
0 # No scattering functions

This file may be called ‘basic.cloog’ (this example is provided in the CLooG distribution as test/manual_basic.cloog) and we can ask CLooG to process it and to generate the code by a simple calling to CLooG with this file as input: ‘cloog basic.cloog’. By default, CLooG will print the generated code in the standard output:

/* Generated by CLooG v0.18.0-UNKNOWN in 0.00s. */
for (i=2;i<=n;i++) {
  for (j=2;j<=min(m,-i+n+2);j++) {    
    S1(i,j) ;
  }
}

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on August 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.