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