static void
print_scattering_function_1 (FILE *file, poly_bb_p pbb, int verbosity)
{
  graphite_dim_t i;

  if (verbosity > 0)
    {
      fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb));
      fprintf (file, "#  eq");

      for (i = 0; i < pbb_nb_scattering_transform (pbb); i++)
	fprintf (file, "     s%d", (int) i);

      for (i = 0; i < pbb_nb_local_vars (pbb); i++)
	fprintf (file, "    lv%d", (int) i);

      for (i = 0; i < pbb_dim_iter_domain (pbb); i++)
	fprintf (file, "     i%d", (int) i);

      for (i = 0; i < pbb_nb_params (pbb); i++)
	fprintf (file, "     p%d", (int) i);

      fprintf (file, "    cst\n");
    }

  /* Number of disjunct components.  Remove this when
     PBB_TRANSFORMED_SCATTERING will be a pointset_powerset.  */
  fprintf (file, "1\n");
  ppl_print_polyhedron_matrix (file, PBB_TRANSFORMED_SCATTERING (pbb)
			       ? PBB_TRANSFORMED_SCATTERING (pbb)
			       : PBB_ORIGINAL_SCATTERING (pbb));

  if (verbosity > 0)
    fprintf (file, "#)\n");
}
Ejemplo n.º 2
0
int
scop_max_loop_depth (scop_p scop)
{
  int i;
  poly_bb_p pbb;
  int max_nb_loops = 0;

  FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb)
    {
      int nb_loops = pbb_dim_iter_domain (pbb);
      if (max_nb_loops < nb_loops)
        max_nb_loops = nb_loops;
    }
Ejemplo n.º 3
0
static bool
graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
			     poly_dr_p pdr1, poly_dr_p pdr2)
{
  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
  ppl_Polyhedron_t so1 = PBB_ORIGINAL_SCATTERING (pbb1);
  ppl_Polyhedron_t so2 = PBB_ORIGINAL_SCATTERING (pbb2);
  ppl_Pointset_Powerset_C_Polyhedron_t po;

  graphite_dim_t sdim1 = pdr_nb_subscripts (pdr1) + 1;
  graphite_dim_t sdim2 = pdr_nb_subscripts (pdr2) + 1;

  if (sdim1 != sdim2)
    return true;

  po = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
			      true, true);

  if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (po))
    return true;
  else
    {
      ppl_Polyhedron_t st1 = PBB_TRANSFORMED_SCATTERING (pbb1);
      ppl_Polyhedron_t st2 = PBB_TRANSFORMED_SCATTERING (pbb2);
      ppl_Pointset_Powerset_C_Polyhedron_t pt;
      graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
      graphite_dim_t otdim1 = pbb_nb_scattering_orig (pbb1);
      graphite_dim_t otdim2 = pbb_nb_scattering_orig (pbb2);
      graphite_dim_t ttdim1 = pbb_nb_scattering_transform (pbb1);
      graphite_dim_t ttdim2 = pbb_nb_scattering_transform (pbb2);

      if (dump_file && (dump_flags & TDF_DETAILS))
	fprintf (dump_file, "\nloop carries dependency.\n");
      pt = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, st1, st2,
				  false, false);

      /* Extend PO and PT to have the same dimensions.  */
      ppl_insert_dimensions_pointset (po, otdim1, ttdim1);
      ppl_insert_dimensions_pointset (po, otdim1 + ttdim1 + ddim1 + otdim2,
				      ttdim2);
      ppl_insert_dimensions_pointset (pt, 0, otdim1);
      ppl_insert_dimensions_pointset (pt, otdim1 + ttdim1 + ddim1, otdim2);

      ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (po, pt);
      return ppl_Pointset_Powerset_C_Polyhedron_is_empty (po);
    }
}
int
scop_max_loop_depth (scop_p scop)
{
  int i;
  poly_bb_p pbb;
  int max_nb_loops = 0;

  for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
    {
      int nb_loops = pbb_dim_iter_domain (pbb);
      if (max_nb_loops < nb_loops)
        max_nb_loops = nb_loops;
    }

  return max_nb_loops;
}
Ejemplo n.º 5
0
static bool
graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
				     int level)
{
  poly_bb_p pbb1 = PDR_PBB (pdr1);
  poly_bb_p pbb2 = PDR_PBB (pdr2);
  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
  ppl_Polyhedron_t so1 = PBB_TRANSFORMED_SCATTERING (pbb1);
  ppl_Polyhedron_t so2 = PBB_TRANSFORMED_SCATTERING (pbb2);
  ppl_Pointset_Powerset_C_Polyhedron_t po;
  ppl_Pointset_Powerset_C_Polyhedron_t eqpp;
  graphite_dim_t sdim1 = pdr_nb_subscripts (pdr1) + 1;
  graphite_dim_t sdim2 = pdr_nb_subscripts (pdr2) + 1;
  graphite_dim_t tdim1 = pbb_nb_scattering_transform (pbb1);
  graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
  ppl_dimension_type dim;
  bool empty_p;

  if ((PDR_TYPE (pdr1) == PDR_READ && PDR_TYPE (pdr2) == PDR_READ)
      || !poly_drs_may_alias_p (pdr1, pdr2))
    return false;

  if (sdim1 != sdim2)
    return true;

  po = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
			      true, false);
  if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (po))
    {
      ppl_delete_Pointset_Powerset_C_Polyhedron (po);
      return false;
    }

  ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &dim);
  eqpp = build_pairwise_scheduling_inequality (dim, level, tdim1 + ddim1, 1);

  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (eqpp, po);
  empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (eqpp);

  ppl_delete_Pointset_Powerset_C_Polyhedron (po);
  ppl_delete_Pointset_Powerset_C_Polyhedron (eqpp);
  return !empty_p;
}
static void
extend_scattering (poly_bb_p pbb, int max_scattering)
{
  ppl_dimension_type nb_old_dims, nb_new_dims;
  int nb_added_dims, i;
  ppl_Coefficient_t coef;
  Value one;

  nb_added_dims = max_scattering - pbb_nb_scattering_transform (pbb);
  value_init (one);
  value_set_si (one, 1);
  ppl_new_Coefficient (&coef);
  ppl_assign_Coefficient_from_mpz_t (coef, one);

  gcc_assert (nb_added_dims >= 0);

  nb_old_dims = pbb_nb_scattering_transform (pbb) + pbb_dim_iter_domain (pbb)
    + scop_nb_params (PBB_SCOP (pbb));
  nb_new_dims = nb_old_dims + nb_added_dims;

  ppl_insert_dimensions (PBB_TRANSFORMED_SCATTERING (pbb),
			 pbb_nb_scattering_transform (pbb), nb_added_dims);
  PBB_NB_SCATTERING_TRANSFORM (pbb) += nb_added_dims;

  /* Add identity matrix for the added dimensions.  */
  for (i = max_scattering - nb_added_dims; i < max_scattering; i++)
    {
      ppl_Constraint_t cstr;
      ppl_Linear_Expression_t expr;

      ppl_new_Linear_Expression_with_dimension (&expr, nb_new_dims);
      ppl_Linear_Expression_add_to_coefficient (expr, i, coef);
      ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL);
      ppl_Polyhedron_add_constraint (PBB_TRANSFORMED_SCATTERING (pbb), cstr);
      ppl_delete_Constraint (cstr);
      ppl_delete_Linear_Expression (expr);
    }

  ppl_delete_Coefficient (coef);
  value_clear (one);
}
Ejemplo n.º 7
0
static ppl_Pointset_Powerset_C_Polyhedron_t
dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2,
		         ppl_Pointset_Powerset_C_Polyhedron_t d1,
		         ppl_Pointset_Powerset_C_Polyhedron_t d2,
		         poly_dr_p pdr1, poly_dr_p pdr2,
	                 ppl_Polyhedron_t s1, ppl_Polyhedron_t s2,
		         bool direction,
		         bool original_scattering_p)
{
  scop_p scop = PBB_SCOP (pbb1);
  graphite_dim_t tdim1 = original_scattering_p ?
    pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1);
  graphite_dim_t tdim2 = original_scattering_p ?
    pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2);
  graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
  graphite_dim_t ddim2 = pbb_dim_iter_domain (pbb2);
  graphite_dim_t sdim1 = pdr_nb_subscripts (pdr1) + 1;
  graphite_dim_t gdim = scop_nb_params (scop);
  graphite_dim_t dim1 = pdr_dim (pdr1);
  graphite_dim_t dim2 = pdr_dim (pdr2);
  graphite_dim_t dim = tdim1 + tdim2 + dim1 + dim2;
  ppl_Pointset_Powerset_C_Polyhedron_t res;
  ppl_Pointset_Powerset_C_Polyhedron_t id1, id2, isc1, isc2, idr1, idr2;
  ppl_Pointset_Powerset_C_Polyhedron_t sc1, sc2, dreq;

  gcc_assert (PBB_SCOP (pbb1) == PBB_SCOP (pbb2));
  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc1, s1);
  ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc2, s2);

  id1 = map_into_dep_poly (dim, gdim, d1, ddim1, tdim1);
  id2 = map_into_dep_poly (dim, gdim, d2, ddim2, tdim1 + ddim1 + tdim2);
  isc1 = map_into_dep_poly (dim, gdim, sc1, ddim1 + tdim1, 0);
  isc2 = map_into_dep_poly (dim, gdim, sc2, ddim2 + tdim2, tdim1 + ddim1);

  idr1 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr1), ddim1, ddim1 + gdim,
			       tdim1, tdim2 + ddim2);
  idr2 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr2), ddim2, ddim2 + gdim,
			       tdim1 + ddim1 + tdim2, sdim1);

  /* Now add the subscript equalities.  */
  dreq = dr_equality_constraints (dim, tdim1 + ddim1 + tdim2 + ddim2, sdim1);

  ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&res, dim, 0);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, id1);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, id2);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, isc1);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, isc2);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr1);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr2);
  ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, dreq);
  ppl_delete_Pointset_Powerset_C_Polyhedron (id1);
  ppl_delete_Pointset_Powerset_C_Polyhedron (id2);
  ppl_delete_Pointset_Powerset_C_Polyhedron (sc1);
  ppl_delete_Pointset_Powerset_C_Polyhedron (sc2);
  ppl_delete_Pointset_Powerset_C_Polyhedron (isc1);
  ppl_delete_Pointset_Powerset_C_Polyhedron (isc2);
  ppl_delete_Pointset_Powerset_C_Polyhedron (idr1);
  ppl_delete_Pointset_Powerset_C_Polyhedron (idr2);
  ppl_delete_Pointset_Powerset_C_Polyhedron (dreq);

  if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (res))
    build_lexicographically_gt_constraint (&res, dim, MIN (tdim1, tdim2),
					   tdim1 + ddim1, direction);
  return res;
}