Exemple #1
0
def test_visit_FieldIfStmt_nesting():
    testee = (FieldIfStmtBuilder().cond(
        FieldAccessBuilder("cond").dtype(DataType.BOOL).build()).add_true_stmt(
            FieldIfStmtBuilder().cond(
                FieldAccessBuilder("cond2").dtype(
                    DataType.BOOL).build()).build()).build())
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #2
0
def test_visit_FieldIfStmt():
    testee = FieldIfStmtFactory(true_branch__body__0=ParAssignStmtFactory())
    mask_stmts = GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())

    assert len(mask_stmts) == 2
    assert "mask" in mask_stmts[0].left.name
    assert testee.cond.name == mask_stmts[0].right.name
    assert mask_stmts[1].body[0].left.name == testee.true_branch.body[0].left.name
def test_visit_Assign_VariableKOffset():
    testee = gtir.ParAssignStmt(
        left=FieldAccessFactory(), right=FieldAccessFactory(offset=VariableKOffsetFactory())
    )
    ctx = GTIRToOIR.Context()
    GTIRToOIR().visit(testee, ctx=ctx)

    assert len(ctx.horizontal_executions) == 1
    assert ctx.horizontal_executions[0].iter_tree().if_isinstance(oir.VariableKOffset).to_list()
Exemple #4
0
def test_visit_ParAssignStmt():
    out_name = "out"
    in_name = "in"
    testee = gtir.ParAssignStmt(left=FieldAccessBuilder(out_name).build(),
                                right=FieldAccessBuilder(in_name).build())

    ctx = GTIRToOIR.Context()
    GTIRToOIR().visit(testee, ctx=ctx)
    result_horizontal_executions = ctx.horizontal_executions

    assert len(result_horizontal_executions) == 1
    assign = isinstance_and_return(result_horizontal_executions[0].body[0],
                                   oir.AssignStmt)

    left = isinstance_and_return(assign.left, oir.FieldAccess)
    right = isinstance_and_return(assign.right, oir.FieldAccess)
    assert left.name == out_name
    assert right.name == in_name
Exemple #5
0
def test_create_mask():
    mask_name = "mask"
    cond = oir_utils.FieldAccessFactory(dtype=DataType.BOOL)
    ctx = GTIRToOIR.Context()
    result_decl = gtir_to_oir._create_mask(ctx, mask_name, cond)
    result_assign = ctx.horizontal_executions[0]

    assert isinstance(result_decl, oir.Temporary)
    assert result_decl.name == mask_name

    horizontal_exec = isinstance_and_return(result_assign, oir.HorizontalExecution)
    assign = isinstance_and_return(horizontal_exec.body[0], oir.AssignStmt)

    left = isinstance_and_return(assign.left, oir.FieldAccess)
    right = isinstance_and_return(assign.right, oir.FieldAccess)

    assert left.name == mask_name
    assert right == cond
Exemple #6
0
def test_visit_FieldIfStmt_no_else():
    testee = (FieldIfStmtBuilder().cond(
        FieldAccessBuilder("cond").dtype(DataType.BOOL).build()).build())
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #7
0
def test_visit_ScalarIfStmt():
    testee = ScalarIfStmt(
        cond=gtir_utils.DummyExpr(dtype=DataType.BOOL, kind=ExprKind.SCALAR),
        true_branch=BlockStmt(body=[]),
    )
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #8
0
def test_visit_ScalarIfStmt():
    testee = ScalarIfStmtFactory()
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #9
0
def test_visit_FieldIfStmt_nesting():
    testee = FieldIfStmtFactory(true_branch__body__0=FieldIfStmtFactory())
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #10
0
def test_visit_FieldIfStmt_nesting():
    testee = FieldIfStmtFactory(true_branch=BlockStmtFactory(body=[FieldIfStmtFactory()]))
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #11
0
def test_visit_FieldIfStmt_no_else():
    testee = FieldIfStmtFactory(false_branch=None)
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #12
0
def test_visit_FieldIfStmt():
    testee = FieldIfStmtFactory(false_branch=BlockStmtFactory())
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())
Exemple #13
0
def test_visit_HorizontalRestriction_HorizontalMask():
    testee = HorizontalRestrictionFactory(mask=HorizontalMaskFactory())
    GTIRToOIR().visit(testee, ctx=GTIRToOIR.Context())