Exemple #1
0
			void offseted_less_than_var (int v, int offset, int v2) { // v + offset <= v2
				isl_constraint * less = isl_inequality_alloc (isl_local_space_copy (ls));
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, v, -1);
				less = isl_constraint_set_constant_si (less, -offset);
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, v2, 1);
				solutions = isl_set_add_constraint (solutions, less);
			}
Exemple #2
0
/// @brief Create an isl constraint from a row of OpenScop integers.
///
/// @param row An array of isl/OpenScop integers.
/// @param Space An isl space object, describing how to spilt the dimensions.
///
/// @return An isl constraint representing this integer array.
isl_constraint *constraintFromMatrixRowFull(isl_int *row,
                                            __isl_take isl_space *Space) {
  isl_constraint *c;

  unsigned NbOut = isl_space_dim(Space, isl_dim_out);
  unsigned NbIn = isl_space_dim(Space, isl_dim_in);
  unsigned NbParam = isl_space_dim(Space, isl_dim_param);

  isl_local_space *LSpace = isl_local_space_from_space(Space);

  if (isl_int_is_zero(row[0]))
    c = isl_equality_alloc(LSpace);
  else
    c = isl_inequality_alloc(LSpace);

  unsigned current_column = 1;

  for (unsigned j = 0; j < NbOut; ++j)
    isl_constraint_set_coefficient(c, isl_dim_out, j, row[current_column++]);

  for (unsigned j = 0; j < NbIn; ++j)
    isl_constraint_set_coefficient(c, isl_dim_in, j, row[current_column++]);

  for (unsigned j = 0; j < NbParam; ++j)
    isl_constraint_set_coefficient(c, isl_dim_param, j, row[current_column++]);

  isl_constraint_set_constant(c, row[current_column]);

  return c;
}
Exemple #3
0
			void offseted_diff_less_than_var (int va, int vb, int offset, int mv) { // va - vb + offset <= mv
				isl_constraint * less = isl_inequality_alloc (isl_local_space_copy (ls));
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, va, -1);
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, vb, 1);
				less = isl_constraint_set_constant_si (less, -offset);
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, mv, 1);
				solutions = isl_set_add_constraint (solutions, less);
			}
Exemple #4
0
static void
pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
{
  isl_space *d;
  isl_constraint *c;
  int iter, strip;
  /* STRIP is the dimension that iterates with stride STRIDE.  */
  /* ITER is the dimension that enumerates single iterations inside
     one strip that has at most STRIDE iterations.  */
  strip = time_depth;
  iter = strip + 2;

  pbb->transformed = isl_map_insert_dims (pbb->transformed, isl_dim_out,
					  strip, 2);

  /* Lower bound of the striped loop.  */
  d = isl_map_get_space (pbb->transformed);
  c = isl_inequality_alloc (isl_local_space_from_space (d));
  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, -stride);
  c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, 1);
  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);

  /* Upper bound of the striped loop.  */
  d = isl_map_get_space (pbb->transformed);
  c = isl_inequality_alloc (isl_local_space_from_space (d));
  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, stride);
  c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, -1);
  c = isl_constraint_set_constant_si (c, stride - 1);
  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);

  /* Static scheduling for ITER level.
     This is mandatory to keep the 2d + 1 canonical scheduling format.  */
  d = isl_map_get_space (pbb->transformed);
  c = isl_equality_alloc (isl_local_space_from_space (d));
  c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
  pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
}
static
isl_set* build_iteration_domain (scoplib_scop_p scop,
				                   scoplib_statement_p s,
						    isl_space* space,
						    isl_ctx* ctxt)
{
  isl_set* ret = isl_set_universe (isl_space_domain (isl_space_copy (space)));
  int i;
  isl_val* tmp = isl_val_int_from_si (ctxt, 0);
  scoplib_matrix_p m = s->domain->elt;
  for (i = 0; i < m->NbRows; ++i)
    {
      isl_local_space* ls =
  	isl_local_space_from_space (isl_set_get_space (ret));
      isl_constraint* cst;
      if (SCOPVAL_get_si(m->p[i][0]) == 0)
  	cst = isl_equality_alloc (isl_local_space_copy (ls));
      else
  	cst = isl_inequality_alloc (isl_local_space_copy (ls));

      // Set input dimensions.
      int k;
      for (k = 0; k < s->nb_iterators; ++k)
  	{
  	  tmp = isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][k+1]));
  	  cst = isl_constraint_set_coefficient_val (cst, isl_dim_set, k, isl_val_copy (tmp));
  	}
      for (k = 0; k < scop->nb_parameters; ++k)
  	{
  	  tmp =
  	    isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][k+1+s->nb_iterators]));
  	  cst =
  	    isl_constraint_set_coefficient_val (cst, isl_dim_param, k,
  						isl_val_copy (tmp));
  	}
      tmp = isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][m->NbColumns - 1]));
      cst = isl_constraint_set_constant_val (cst, isl_val_copy (tmp));

      // Insert constraint.
      ret = isl_set_add_constraint (ret, cst);
    }
  isl_val_free (tmp);

  return ret;
}
static
isl_map* build_schedule (scoplib_scop_p scop,
				         scoplib_statement_p s,
			                 isl_space* sp,
			                 isl_ctx* ctxt)
{
  // Set up the space.
  isl_space* space_in  = isl_space_domain (isl_space_copy (sp));
  int dout = s->schedule->NbRows;
  isl_space* space_out = isl_space_set_alloc(ctxt, scop->nb_parameters, dout);
  int i;
  char buffer[32];
  char* name;
  for (i = 0; i < dout; ++i)
    {
      sprintf (buffer, "t%d", i);
      name = strdup (buffer);
      space_out = isl_space_set_dim_name (space_out, isl_dim_set, i, name);
    }
  for (i = 0; i < scop->nb_parameters; ++i)
    {
      name = strdup (((SgVariableSymbol*)(scop->parameters[i]))->get_name().str());
      space_out = isl_space_set_dim_name (space_out, isl_dim_param, i, name);
    }

  isl_space* space = isl_space_map_from_domain_and_range
    (isl_space_copy (space_in), isl_space_copy (space_out));
  isl_map* ret = isl_map_universe (isl_space_copy (space));
  isl_val* tmp = isl_val_int_from_si (ctxt, 0);
  scoplib_matrix_p m = s->schedule;
  for (i = 0; i < m->NbRows; ++i)
    {
      isl_local_space* ls =
  	isl_local_space_from_space (isl_space_copy (space));
      isl_constraint* cst;
      if (SCOPVAL_get_si(m->p[i][0]) == 0)
  	cst = isl_equality_alloc (isl_local_space_copy (ls));
      else
  	cst = isl_inequality_alloc (isl_local_space_copy (ls));

      // Set input dimensions.
      int k;
      for (k = 0; k < s->nb_iterators; ++k)
  	{
  	  tmp = isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][k+1]));
  	  cst = isl_constraint_set_coefficient_val (cst, isl_dim_in, k, isl_val_copy (tmp));
  	}
      for (k = 0; k < scop->nb_parameters; ++k)
  	{
  	  tmp =
  	    isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][k+1+s->nb_iterators]));
  	  cst =
  	    isl_constraint_set_coefficient_val (cst, isl_dim_param, k,
  						isl_val_copy (tmp));
  	}
      tmp = isl_val_set_si (tmp, SCOPVAL_get_si(m->p[i][m->NbColumns - 1]));
      cst = isl_constraint_set_constant_val (cst, isl_val_copy (tmp));

      // Set output dimension.
      tmp = isl_val_set_si (tmp, -1);
      isl_constraint_set_coefficient_val (cst, isl_dim_out, i, isl_val_copy (tmp));

      // Insert constraint.
      ret = isl_map_add_constraint (ret, cst);
    }
  isl_val_free (tmp);

  return ret;
}
Exemple #7
0
			void less_than_const (int v, int constant) { // v <= constant
				isl_constraint * less = isl_inequality_alloc (isl_local_space_copy (ls));
				less = isl_constraint_set_coefficient_si (less, isl_dim_set, v, -1);
				less = isl_constraint_set_constant_si (less, constant);
				solutions = isl_set_add_constraint (solutions, less); 
			}
Exemple #8
0
			void more_than_const (int v, int constant) { // constant <= v
				isl_constraint * more = isl_inequality_alloc (isl_local_space_copy (ls));
				more = isl_constraint_set_coefficient_si (more, isl_dim_set, v, 1);
				more = isl_constraint_set_constant_si (more, -constant);
				solutions = isl_set_add_constraint (solutions, more); 
			}