From b75ada05fe0e59efa0d5cb09487e76895c885db7 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Wed, 12 Oct 2016 16:51:37 -0600 Subject: added lexical ordering --- src/transformations/loop.cc | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/transformations/loop.cc b/src/transformations/loop.cc index 0839705..d176981 100644 --- a/src/transformations/loop.cc +++ b/src/transformations/loop.cc @@ -460,6 +460,22 @@ void Loop::buildIS(std::vector &ir_tree,std::vector &lexical stmt[loc].loop_level[ii].payload = ii; stmt[loc].loop_level[ii].parallel_level = 0; } + // Lexical ordering + stmt[loc].xform = Relation(num_dep_dim, 2 * num_dep_dim + 1); + F_And *f_xform = stmt[loc].xform.add_and(); + + for (int j = 1; j <= num_dep_dim; j++) { + EQ_Handle h = f_xform->add_EQ(); + h.update_coef(stmt[i].xform.output_var(2 * j), 1); + h.update_coef(stmt[i].xform.input_var(j), -1); + } + + for (int j = 1; j <= 2 * num_dep_dim + 1; j += 2) { + EQ_Handle h = f_xform->add_EQ(); + h.update_coef(stmt[i].xform.output_var(j), 1); + h.update_const(-lexicalOrder[(j-1)/2]); + } + stmt[i].xform.simplify(); // Update lexical ordering for next statement lexicalOrder[lexicalOrder.size()-1]++; break; @@ -740,29 +756,6 @@ Loop::Loop(const IR_Control *control) { stmt[canReduce[i]].reductionOp = opType; } } - // cleanup the IR tree - - CHILL_DEBUG_PRINT("init dumb transformation relations\n"); - - // init dumb transformation relations e.g. [i, j] -> [ 0, i, 0, j, 0] - for (int i = 0; i < stmt.size(); i++) { - int n = stmt[i].IS.n_set(); - stmt[i].xform = Relation(n, 2 * n + 1); - F_And *f_root = stmt[i].xform.add_and(); - - for (int j = 1; j <= n; j++) { - EQ_Handle h = f_root->add_EQ(); - h.update_coef(stmt[i].xform.output_var(2 * j), 1); - h.update_coef(stmt[i].xform.input_var(j), -1); - } - - for (int j = 1; j <= 2 * n + 1; j += 2) { - EQ_Handle h = f_root->add_EQ(); - h.update_coef(stmt[i].xform.output_var(j), 1); - } - stmt[i].xform.simplify(); - } - CHILL_DEBUG_PRINT("done with dumb\n"); } Loop::~Loop() { -- cgit v1.2.3-70-g09d2