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());
}
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));
}
}
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());
}
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) {
}
}
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));
}
Aggregations