Example #1
0
 def test_simple_independence(self):
     source = Subscript(
         expression_factory(operators.ADD_OP, self.x, IntegerInterval(20)))
     sink = Subscript(self.x)
     self.assertRaises(
         ISLIndependenceException, dependence_vector,
         [self.x], [self.sx], source, sink)
Example #2
0
 def test_simple_subscripts(self):
     source = Subscript(
         expression_factory(operators.ADD_OP, self.x, IntegerInterval(1)))
     sink = Subscript(self.x)
     dist_vect = dependence_vector([self.x], [self.sx], source, sink)
     self.assertEqual(dist_vect, (1, ))
     dist = dependence_distance(dist_vect, [self.sx])
     self.assertEqual(dist, 1)
Example #3
0
 def test_multi_dim_coupled_subscripts_dependence(self):
     """
     for (x in 0...9) { a[x + 1, x + 1] = a[x, x]; }
     """
     expr_1 = expression_factory(
         operators.ADD_OP, self.x, IntegerInterval(1))
     expr_2 = expression_factory(
         operators.ADD_OP, self.x, IntegerInterval(1))
     source = Subscript(expr_1, expr_2)
     sink = Subscript(self.x, self.x)
     dist_vect = dependence_vector([self.x], [self.sx], source, sink)
     self.assertEqual(dist_vect, (1, ))
Example #4
0
 def test_multi_dim_coupled_subscripts_independence(self):
     """
     for (x in 0...9) { a[x + 1, x + 2] = a[x, x]; }
     """
     expr_1 = expression_factory(
         operators.ADD_OP, self.x, IntegerInterval(1))
     expr_2 = expression_factory(
         operators.ADD_OP, self.x, IntegerInterval(2))
     source = Subscript(expr_1, expr_2)
     sink = Subscript(self.x, self.x)
     self.assertRaises(
         ISLIndependenceException, dependence_vector,
         [self.x], [self.sx], source, sink)
Example #5
0
 def test_AccessExpr(self):
     subscript = Subscript(self.y)
     expr = AccessExpr(self.z, subscript)
     label_subscript_expr = Subscript(self.y_label)
     subscript_label = self.context.Label(
         subscript, IntegerIntervalArray([self.state[self.y]]), None)
     label_expr = AccessExpr(self.z_label, subscript_label)
     label = self.context.Label(expr, IntegerInterval(4), None)
     env = {
         label: label_expr,
         subscript_label: label_subscript_expr,
         self.y_label: self.y,
         self.z_label: self.z,
     }
     test_value = LabelSemantics(label, env)
     self.compare(expr, test_value)
Example #6
0
 def test_UpdateExpr(self):
     subscript = Subscript(self.y)
     expr = UpdateExpr(self.z, subscript, self.x)
     label_subscript_expr = Subscript(self.y_label)
     subscript_label = self.context.Label(
         subscript, IntegerIntervalArray([self.state[self.y]]), None)
     label_expr = UpdateExpr(self.z_label, subscript_label, self.x_label)
     new_bound = IntegerIntervalArray([1, 2, 3, IntegerInterval([1, 2])])
     label = self.context.Label(expr, new_bound, None)
     env = {
         label: label_expr,
         subscript_label: label_subscript_expr,
         self.x_label: self.x,
         self.y_label: self.y,
         self.z_label: self.z,
     }
     test_value = LabelSemantics(label, env)
     self.compare(expr, test_value)
Example #7
0
    def test_variable_subscript(self):
        expr = expression_factory(operators.INDEX_ACCESS_OP, self.x,
                                  Subscript(self.i1))
        self.assertEqual(expr_parse('x[1]'), expr)

        expr = expression_factory(
            operators.INDEX_ACCESS_OP, self.x,
            Subscript(expression_factory(operators.ADD_OP, self.y, self.i1)))
        self.assertEqual(expr_parse('x[y + 1]'), expr)

        expr = expression_factory(operators.INDEX_ACCESS_OP, self.x,
                                  Subscript(self.y, self.i1))
        self.assertEqual(expr_parse('x[y, 1]'), expr)

        expr = expression_factory(
            operators.INDEX_ACCESS_OP, self.x,
            Subscript(
                expression_factory(operators.INDEX_ACCESS_OP, self.y,
                                   Subscript(self.i1))))
        self.assertEqual(expr_parse('x[y[1]]'), expr)
Example #8
0
 def test_multi_dim_subscripts(self):
     """
     Test case::
         for (x in 0...9) {
             for (y in 1...10) {
                 a[x + 2, y] = ... a[x, y - 1] ...
             }
         }
     """
     expr = expression_factory(operators.ADD_OP, self.x, IntegerInterval(2))
     source = Subscript(expr, self.y)
     expr = expression_factory(
         operators.SUBTRACT_OP, self.y, IntegerInterval(1))
     sink = Subscript(self.x, expr)
     iter_slices = [self.sx, self.sy]
     dist_vect = dependence_vector(
         [self.x, self.y], iter_slices, source, sink)
     self.assertEqual(dist_vect, (2, 1))
     dist = dependence_distance(dist_vect, iter_slices)
     self.assertEqual(dist, 21)