Search in sources :

Example 21 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method matchAllAncestorTest.

@Test
public void matchAllAncestorTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_ASSIGN_STMT2, context);
    assertNotNull(xcodeml);
    List<Xnode> nodes = xcodeml.matchAll(Xcode.F_ASSIGN_STATEMENT);
    assertEquals(4, nodes.size());
    List<Xnode> matches1 = nodes.get(0).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
    List<Xnode> matches2 = nodes.get(0).matchAllAncestor(Xcode.F_IF_STATEMENT);
    assertEquals(2, matches1.size());
    assertEquals(2, matches2.size());
    matches1 = nodes.get(1).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
    matches2 = nodes.get(1).matchAllAncestor(Xcode.F_IF_STATEMENT);
    assertEquals(2, matches1.size());
    assertEquals(2, matches2.size());
    matches1 = nodes.get(3).matchAllAncestor(Xcode.F_IF_STATEMENT, Xcode.F_FUNCTION_DEFINITION);
    matches2 = nodes.get(3).matchAllAncestor(Xcode.F_IF_STATEMENT);
    assertEquals(0, matches1.size());
    assertEquals(0, matches2.size());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 22 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class FfunctionDefinitionTest method findContainingXmodTest.

@Test
public void findContainingXmodTest() {
    Context context = new TestContext();
    context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
    assertTrue(Files.exists(TestConstant.TEST_DECLARATIONS));
    XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_DECLARATIONS, context);
    assertNotNull(xcodeml);
    List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
    for (FfunctionDefinition fctDef : fctDefs) {
        // Search paths is not set so module cannot be found.
        assertNull(fctDef.findContainingXmod(context));
    }
}
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)

Example 23 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class FfunctionDefinitionTest method basicFunctionDefinitionTest.

@Test
public void basicFunctionDefinitionTest() {
    Context context = new TestContext();
    context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
    FfunctionDefinition fctDef = XmlHelper.createXfunctionDefinitionFromString(basicFDef);
    assertNotNull(fctDef);
    assertEquals("force_dummy", fctDef.getName());
    assertEquals("force_dummy", fctDef.name().value());
    assertEquals("F7ff951406df0", fctDef.getType());
    assertEquals(0, fctDef.getSymbolTable().size());
    assertEquals(0, fctDef.getDeclarationTable().count());
    assertNull(fctDef.getParams());
    assertNotNull(fctDef.body());
    assertEquals(1, fctDef.lineNo());
    assertEquals("original_code.f90", fctDef.filename());
    assertNull(fctDef.findContainingXmod(context));
    FfunctionDefinition clone = fctDef.cloneNode();
    assertNotNull(clone);
    assertEquals("force_dummy", fctDef.getName());
    assertEquals("force_dummy", fctDef.name().value());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 24 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class LoopTest method mergeFailTest.

@Test
public void mergeFailTest() {
    Context context = new TestContext();
    XcodeML xcodeml = XmlHelper.getDummyXcodeProgram(context);
    assertNotNull(xcodeml);
    Xnode n1 = xcodeml.createNode(Xcode.F_IF_STATEMENT);
    Xnode n2 = xcodeml.createNode(Xcode.F_IF_STATEMENT);
    try {
        Loop.merge(n1, null);
        fail();
    } catch (IllegalTransformationException ignored) {
    }
    try {
        Loop.merge(null, n2);
        fail();
    } catch (IllegalTransformationException ignored) {
    }
    try {
        Loop.merge(n1, n2);
        fail();
    } catch (IllegalTransformationException ignored) {
    }
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) IllegalTransformationException(claw.tatsu.xcodeml.exception.IllegalTransformationException) TestContext(helper.Utils.TestContext) XcodeML(claw.tatsu.xcodeml.xnode.common.XcodeML) Test(org.junit.Test)

Example 25 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XmodTest method getSuffixTest.

@Test
public void getSuffixTest() {
    Context context = new TestContext();
    context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
    // .[directive].[target].claw
    assertEquals(".openacc.gpu.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.OPENMP, Target.CPU, null, 80);
    assertEquals(".openmp.cpu.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.NONE, Target.CPU, null, 80);
    assertEquals(".none.cpu.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.OPENMP, Target.MIC, null, 80);
    assertEquals(".openmp.mic.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.NONE, Target.FPGA, null, 80);
    assertEquals(".none.fpga.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.OPENACC, null, null, 80);
    assertEquals(".openacc.none.claw.xmod", Xmod.getSuffix(context));
    context.init(null, null, null, 80);
    assertEquals(".none.none.claw.xmod", Xmod.getSuffix(context));
    context.init(CompilerDirective.NONE, Target.GPU, null, 80);
    assertEquals(".none.gpu.claw.xmod", Xmod.getSuffix(context));
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Aggregations

Context (claw.tatsu.common.Context)54 TestContext (helper.Utils.TestContext)44 Test (org.junit.Test)43 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)27 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)22 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)12 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)9 Xid (claw.tatsu.xcodeml.xnode.common.Xid)4 FfunctionType (claw.tatsu.xcodeml.xnode.fortran.FfunctionType)4 PromotionInfo (claw.tatsu.xcodeml.abstraction.PromotionInfo)3 Xblock (claw.tatsu.xcodeml.abstraction.Xblock)3 FbasicType (claw.tatsu.xcodeml.xnode.fortran.FbasicType)3 FmoduleDefinition (claw.tatsu.xcodeml.xnode.fortran.FmoduleDefinition)3 Configuration (claw.wani.x2t.configuration.Configuration)3 ClawTranslator (claw.wani.x2t.translator.ClawTranslator)3 ArrayList (java.util.ArrayList)3 DirectiveGenerator (claw.tatsu.directive.generator.DirectiveGenerator)2 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)2 XcodeML (claw.tatsu.xcodeml.xnode.common.XcodeML)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2