/* A data reference can write or read some memory or we
just know it may write some memory. */
-enum POLY_DR_TYPE
+enum poly_dr_type
{
PDR_READ,
- /* PDR_MAY_READs are represented using PDR_READS. This does not limit the
- expressiveness. */
+ /* PDR_MAY_READs are represented using PDR_READS. This does not
+ limit the expressiveness. */
PDR_WRITE,
PDR_MAY_WRITE
};
struct poly_dr
{
+ /* An identifier for this PDR. */
+ int id;
+
+ /* The number of data refs identical to this one in the PBB. */
+ int nb_refs;
+
/* A pointer to compiler's data reference description. */
void *compiler_dr;
/* A pointer to the PBB that contains this data reference. */
poly_bb_p pbb;
- enum POLY_DR_TYPE type;
+ enum poly_dr_type type;
/* The access polyhedron contains the polyhedral space this data
reference will access.
The polyhedron contains these dimensions:
- - The alias set (a):
- Every memory access is classified in at least one alias set.
+ - The alias set (a):
+ Every memory access is classified in at least one alias set.
- - The subscripts (s_0, ..., s_n):
- The memory is accessed using zero or more subscript dimensions.
+ - The subscripts (s_0, ..., s_n):
+ The memory is accessed using zero or more subscript dimensions.
- - The iteration domain (variables and parameters)
+ - The iteration domain (variables and parameters)
Do not hardcode the dimensions. Use the following accessor functions:
- pdr_alias_set_dim
| p = A;
| ... = p[?][?];
| for j
- | A[i][j+b] = m;
+ | A[i][j+k] = m;
| }
The data access A[i][j+k] in alias set "5" is described like this:
- | i j k a s0 s1 1
+ | i j k a s0 s1 1
| 0 0 0 1 0 0 -5 = 0
|-1 0 0 0 1 0 0 = 0
| 0 -1 -1 0 0 1 0 = 0
-
- The constraints on the data container A[1335][123] are:
-
- | i j k a s0 s1 1
- | 0 0 0 0 1 0 0 >= 0
- | 0 0 0 0 0 1 0 >= 0
+ | 0 0 0 0 1 0 0 >= 0 # The last four lines describe the
+ | 0 0 0 0 0 1 0 >= 0 # array size.
| 0 0 0 0 -1 0 1335 >= 0
| 0 0 0 0 0 -1 123 >= 0
polyhedron:
- | i k a s0 1
+ | i k a s0 1
| 0 0 1 0 -5 = 0
| 0 0 0 1 0 >= 0
"or"
- | i k a s0 1
+ | i k a s0 1
| 0 0 1 0 -7 = 0
| 0 0 0 1 0 >= 0
| i j k a 1
| 0 0 0 -1 15 = 0 */
ppl_Pointset_Powerset_C_Polyhedron_t accesses;
- ppl_Pointset_Powerset_C_Polyhedron_t data_container;
+
+ /* Data reference's base object set number, we must assure 2 pdrs are in the
+ same base object set before dependency checking. */
+ int dr_base_object_set;
+
+ /* The number of subscripts. */
+ graphite_dim_t nb_subscripts;
};
+#define PDR_ID(PDR) (PDR->id)
+#define PDR_NB_REFS(PDR) (PDR->nb_refs)
#define PDR_CDR(PDR) (PDR->compiler_dr)
#define PDR_PBB(PDR) (PDR->pbb)
#define PDR_TYPE(PDR) (PDR->type)
#define PDR_ACCESSES(PDR) (PDR->accesses)
-#define PDR_DATA_CONTAINER(PDR) (PDR->data_container)
+#define PDR_BASE_OBJECT_SET(PDR) (PDR->dr_base_object_set)
+#define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
-void new_poly_dr (poly_bb_p, ppl_Pointset_Powerset_C_Polyhedron_t,
- ppl_Pointset_Powerset_C_Polyhedron_t,
- enum POLY_DR_TYPE, void *);
+void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t,
+ enum poly_dr_type, void *, graphite_dim_t);
void free_poly_dr (poly_dr_p);
void debug_pdr (poly_dr_p);
void print_pdr (FILE *, poly_dr_p);
static inline scop_p pdr_scop (poly_dr_p pdr);
-/* The number of subscripts of the PDR. */
+/* The dimension of the PDR_ACCESSES polyhedron of PDR. */
-static inline graphite_dim_t
-pdr_nb_subscripts (poly_dr_p pdr)
+static inline ppl_dimension_type
+pdr_dim (poly_dr_p pdr)
{
- poly_bb_p pbb = PDR_PBB (pdr);
ppl_dimension_type dim;
-
ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PDR_ACCESSES (pdr),
&dim);
- return dim - pbb_dim_iter_domain (pbb) - pbb_nb_params (pbb) - 1;
+ return dim;
}
/* The dimension of the iteration domain of the scop of PDR. */
return scop_nb_params (pdr_scop (pdr));
}
-/* The dimension of the accesses polyhedron of PDR. */
-
-static inline graphite_dim_t
-pdr_dim (poly_dr_p pdr)
-{
- graphite_dim_t alias_nb_dimensions = 1;
-
- return pbb_dim_iter_domain (PDR_PBB (pdr)) + alias_nb_dimensions
- + pdr_nb_subscripts (pdr) + scop_nb_params (pdr_scop (pdr));
-}
-
/* The dimension of the alias set in PDR. */
static inline ppl_dimension_type
return pbb_dim_iter_domain (pbb) + param;
}
+/* Returns true when PDR is a "read". */
+
+static inline bool
+pdr_read_p (poly_dr_p pdr)
+{
+ return PDR_TYPE (pdr) == PDR_READ;
+}
+
+/* Returns true when PDR is a "write". */
+
+static inline bool
+pdr_write_p (poly_dr_p pdr)
+{
+ return PDR_TYPE (pdr) == PDR_WRITE;
+}
+
+/* Returns true when PDR is a "may write". */
+
+static inline bool
+pdr_may_write_p (poly_dr_p pdr)
+{
+ return PDR_TYPE (pdr) == PDR_MAY_WRITE;
+}
+
typedef struct poly_scattering *poly_scattering_p;
struct poly_scattering
/* A copy of the transformed scattering. */
poly_scattering_p saved;
+
+ /* True when the PDR duplicates have already been removed. */
+ bool pdr_duplicates_removed;
+
+ /* True when this PBB contains only a reduction statement. */
+ bool is_reduction;
};
#define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
#define PBB_SAVED(PBB) (PBB->saved)
#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
+#define PBB_PDR_DUPLICATES_REMOVED(PBB) (PBB->pdr_duplicates_removed)
+#define PBB_IS_REDUCTION(PBB) (PBB->is_reduction)
-extern void new_poly_bb (scop_p, void *);
+extern void new_poly_bb (scop_p, void *, bool);
extern void free_poly_bb (poly_bb_p);
extern void debug_loop_vec (poly_bb_p);
extern void schedule_to_scattering (poly_bb_p, int);
extern bool scop_do_interchange (scop_p);
extern bool scop_do_strip_mine (scop_p);
extern void pbb_number_of_iterations (poly_bb_p, graphite_dim_t, Value);
+extern void pbb_number_of_iterations_at_time (poly_bb_p, graphite_dim_t, Value);
+extern void pbb_remove_duplicate_pdrs (poly_bb_p);
+
+/* The index of the PBB. */
+
+static inline int
+pbb_index (poly_bb_p pbb)
+{
+ return GBB_BB (PBB_BLACK_BOX (pbb))->index;
+}
+
+/* The loop of the PBB. */
+
+static inline loop_p
+pbb_loop (poly_bb_p pbb)
+{
+ return gbb_loop (PBB_BLACK_BOX (pbb));
+}
/* The scop that contains the PDR. */
-static inline scop_p pdr_scop (poly_dr_p pdr)
+static inline scop_p
+pdr_scop (poly_dr_p pdr)
{
return PBB_SCOP (PDR_PBB (pdr));
}
return PBB_NB_SCATTERING_TRANSFORM (pbb);
}
+/* The number of dynamic scattering dimensions in PBB. */
+
+static inline graphite_dim_t
+pbb_nb_dynamic_scattering_transform (const struct poly_bb *pbb)
+{
+ /* This function requires the 2d + 1 scattering format to be
+ invariant during all transformations. */
+ gcc_assert (PBB_NB_SCATTERING_TRANSFORM (pbb) % 2);
+ return PBB_NB_SCATTERING_TRANSFORM (pbb) / 2;
+}
+
/* Returns the number of local variables used in the transformed
scattering polyhedron of PBB. */
+ pbb_dim_iter_domain (pbb);
}
+/* The scattering dimension of PBB corresponding to the dynamic level
+ LEVEL. */
+
+static inline ppl_dimension_type
+psct_dynamic_dim (poly_bb_p pbb, graphite_dim_t level)
+{
+ graphite_dim_t result;
+ result = 1 + 2 * level;
+
+ gcc_assert (result < pbb_nb_scattering_transform (pbb));
+ return result;
+}
+
/* Adds to the transformed scattering polyhedron of PBB a new local
variable and returns its index. */
c = 2a + b */
ppl_Pointset_Powerset_C_Polyhedron_t context;
- /* A hashtable of the original pairs of dependent data references.
- For each pair of dependent data references, the dependence
- polyhedron is stored also. */
- htab_t original_pdr_pairs;
+ /* A hashtable of the data dependence relations for the original
+ scattering. */
+ htab_t original_pddrs;
};
#define SCOP_BBS(S) (S->bbs)
#define SCOP_REGION(S) ((sese) S->region)
#define SCOP_DEP_GRAPH(S) (S->dep_graph)
#define SCOP_CONTEXT(S) (S->context)
-#define SCOP_ORIGINAL_PDR_PAIRS(S) (S->original_pdr_pairs)
+#define SCOP_ORIGINAL_PDDRS(S) (S->original_pddrs)
extern scop_p new_scop (void *);
extern void free_scop (scop_p);