Ejemplo n.º 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);
			}
Ejemplo n.º 2
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);
			}
static
isl_map* build_access_function (scoplib_scop_p scop,
				                    scoplib_statement_p s,
				                    scoplib_matrix_p m,
						    isl_space* space,
						    isl_ctx* ctxt,
						    int* row_pos,
						    int array_id)
{
  isl_map* ret = NULL;
  int i;
  isl_val* tmp = isl_val_int_from_si (ctxt, 0);
  for (i = *row_pos; i < m->NbRows; ++i)
    {
      if (SCOPVAL_get_si(m->p[i][0]) == array_id)
	{
	  ret = isl_map_universe (isl_space_copy (space));
	  int pos = 0;
	  do
	    {
	      isl_local_space* ls =
		isl_local_space_from_space (isl_space_copy (space));
	      isl_constraint* cst = isl_equality_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, pos++, isl_val_copy (tmp));

	      // Insert constraint.
	      ret = isl_map_add_constraint (ret, cst);
	      ++i;
	    }
	  while (i < m->NbRows && SCOPVAL_get_si(m->p[i][0]) == 0);
	  *row_pos = i;
	  break;
       }
    }
  isl_val_free (tmp);

  return ret;
}
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;
}
Ejemplo n.º 6
0
			void equality (const std::vector< int > & coeffs) {
				isl_constraint * equ = isl_equality_alloc (isl_local_space_copy (ls));
				for (unsigned c = 0; c < coeffs.size (); ++c)
					equ = isl_constraint_set_coefficient_si (equ, isl_dim_set, c, coeffs[c]);
				solutions = isl_set_add_constraint (solutions, equ);
			}
Ejemplo n.º 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); 
			}
Ejemplo n.º 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); 
			}