Search in sources :

Example 16 with XcodeProgram

use of claw.tatsu.xcodeml.xnode.common.XcodeProgram in project claw-compiler by C2SM-RCM.

the class PragmaTest method getCompilerDirectiveTest.

@Test
public void getCompilerDirectiveTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    Xnode p1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
    Xnode n1 = xcodeml.createNode(Xcode.F_DO_STATEMENT);
    p1.setValue("claw loop-fusion");
    assertEquals(CompilerDirective.CLAW, Pragma.getCompilerDirective(p1));
    p1.setValue("omp teams distribute");
    assertEquals(CompilerDirective.OPENMP, Pragma.getCompilerDirective(p1));
    p1.setValue("acc parallel");
    assertEquals(CompilerDirective.OPENACC, Pragma.getCompilerDirective(p1));
    p1.setValue("ivdep");
    assertEquals(CompilerDirective.NONE, Pragma.getCompilerDirective(p1));
    assertEquals(CompilerDirective.NONE, Pragma.getCompilerDirective(null));
    assertEquals(CompilerDirective.NONE, Pragma.getCompilerDirective(n1));
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Example 17 with XcodeProgram

use of claw.tatsu.xcodeml.xnode.common.XcodeProgram in project claw-compiler by C2SM-RCM.

the class PragmaTest method splitByContTest.

@Test
public void splitByContTest() {
    Context context = new TestContext();
    context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
    assertFalse(fctDefs.isEmpty());
    FfunctionDefinition fd = fctDefs.get(0);
    assertNotNull(fd.body());
    List<Xnode> previous = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
    Xnode p1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
    fd.body().append(p1);
    p1.setValue("acc data present(q,acc& p,acc& h)acc& create(pt)");
    try {
        Pragma.splitByCont(p1, CompilerDirective.OPENACC.getPrefix(), xcodeml);
        List<Xnode> splittedPragma = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
        assertEquals(previous.size() + 4, splittedPragma.size());
    } catch (IllegalTransformationException e) {
        fail();
    }
    Xnode p2 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
    fd.body().append(p2);
    p2.setValue("omp target teams omp& distribute simd");
    try {
        Pragma.splitByCont(p2, CompilerDirective.OPENMP.getPrefix(), xcodeml);
        List<Xnode> splittedPragma = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
        assertEquals(previous.size() + 6, splittedPragma.size());
    } catch (IllegalTransformationException e) {
        fail();
    }
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) FfunctionDefinition(claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition) IllegalTransformationException(claw.tatsu.xcodeml.exception.IllegalTransformationException) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Example 18 with XcodeProgram

use of claw.tatsu.xcodeml.xnode.common.XcodeProgram in project claw-compiler by C2SM-RCM.

the class AssignStatementTest method gatherAssignmentTest2.

@Test
public void gatherAssignmentTest2() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_ASSIGN_STMT2, context);
    assertNotNull(xcodeml);
    List<Xnode> nodes = xcodeml.matchAll(Xcode.F_FUNCTION_DEFINITION);
    assertEquals(1, nodes.size());
    assertEquals(Xcode.F_FUNCTION_DEFINITION, nodes.get(0).opcode());
    FfunctionDefinition fctDef = new FfunctionDefinition(nodes.get(0));
    List<AssignStatement> assignStatements = fctDef.gatherAssignStatements();
    assertEquals(4, assignStatements.size());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) FfunctionDefinition(claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Example 19 with XcodeProgram

use of claw.tatsu.xcodeml.xnode.common.XcodeProgram in project claw-compiler by C2SM-RCM.

the class ModelDataTest method gatherVariableTest.

/**
 * Basic test to gather variable names in model-data directive block.
 */
@Test
public void gatherVariableTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_MODEL_DATA1, context);
    assertNotNull(xcodeml);
    List<Xnode> nodes = xcodeml.matchAll(Xcode.F_PRAGMA_STATEMENT);
    assertEquals(3, nodes.size());
    Xnode modelDataBegin = nodes.get(0);
    Xnode modelDataEnd = nodes.get(1);
    assertEquals("claw model-data", modelDataBegin.value());
    assertEquals("claw end model-data", modelDataEnd.value());
    Set<String> values = XnodeUtil.getAllVariables(modelDataBegin, modelDataEnd);
    assertEquals(2, values.size());
    assertTrue(values.contains("t"));
    assertTrue(values.contains("q"));
    assertFalse(values.contains("w"));
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Example 20 with XcodeProgram

use of claw.tatsu.xcodeml.xnode.common.XcodeProgram in project claw-compiler by C2SM-RCM.

the class FbasicTypeTest method setterTest.

/**
 * Test setter for FbasicType
 */
@Test
public void setterTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    FbasicType bt1 = new FbasicType(xcodeml.createNode(Xcode.F_BASIC_TYPE));
    FbasicType bt2 = new FbasicType(xcodeml.createNode(Xcode.F_BASIC_TYPE));
    String typeHash1 = xcodeml.getTypeTable().generateHash(FortranType.INTEGER);
    String typeHash2 = xcodeml.getTypeTable().generateHash(FortranType.INTEGER);
    bt1.setType(typeHash1);
    bt2.setType(typeHash2);
    bt1.setRef(typeHash2);
    bt2.setRef(Xname.TYPE_F_INT);
    assertEquals(Xname.TYPE_F_INT, bt2.getRef());
    assertEquals(typeHash2, bt1.getRef());
    assertFalse(bt1.hasIntent());
    bt1.setIntent(Intent.IN);
    assertTrue(bt1.hasIntent());
    assertEquals(Intent.IN, bt1.getIntent());
    bt1.removeAttribute(Xattr.INTENT);
    assertEquals(Intent.NONE, bt1.getIntent());
    assertFalse(bt1.hasIntent());
    assertFalse(bt1.isArray());
    assertFalse(bt2.isArray());
    bt1.setBooleanAttribute(Xattr.IS_ALLOCATABLE, true);
    assertTrue(bt1.isAllocatable());
    bt1.removeAttribute(Xattr.IS_ALLOCATABLE);
    assertFalse(bt1.isAllocatable());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) XcodeProgram(claw.tatsu.xcodeml.xnode.common.XcodeProgram) Test(org.junit.Test)

Aggregations

XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)25 Context (claw.tatsu.common.Context)24 TestContext (helper.Utils.TestContext)22 Test (org.junit.Test)22 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)20 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)7 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)4 ArrayList (java.util.ArrayList)3 Transformation (claw.shenron.transformation.Transformation)2 Translator (claw.shenron.translator.Translator)2 Target (claw.tatsu.common.Target)2 DataMovement (claw.tatsu.directive.common.DataMovement)2 Directive (claw.tatsu.directive.common.Directive)2 Range (claw.tatsu.primitive.Range)2 FunctionCall (claw.tatsu.xcodeml.abstraction.FunctionCall)2 Xblock (claw.tatsu.xcodeml.abstraction.Xblock)2 XnodeUtil (claw.tatsu.xcodeml.xnode.XnodeUtil)2 Xattr (claw.tatsu.xcodeml.xnode.common.Xattr)2 Xcode (claw.tatsu.xcodeml.xnode.common.Xcode)2 Xid (claw.tatsu.xcodeml.xnode.common.Xid)2