use of claw.tatsu.xcodeml.abstraction.DimensionDefinition in project claw-compiler by C2SM-RCM.
the class ModelConfigTest method loadTest.
@Test
public void loadTest() {
ModelConfig cfg = new ModelConfig();
try {
cfg.load(TestConstant.TEST_MODEL_CONFIG);
assertEquals("ModelX", cfg.getName());
assertEquals(2, cfg.getNbDimensions());
assertEquals(4, cfg.getNbLayouts());
// Check correctness of "horizontal" dimension information
DimensionDefinition hori = cfg.getDimension("horizontal");
assertNotNull(hori);
assertBound(hori.getLowerBound(), 1);
assertBound(hori.getUpperBound(), "nproma");
assertBound(hori.getIterationLowerBound(), "pstart");
assertBound(hori.getIterationUpperBound(), "pend");
assertBound(hori.getIterationStep(), 1);
// Check correctness of "vertical" dimension information
DimensionDefinition vertical = cfg.getDimension("vertical");
assertNotNullDimension(vertical);
assertBound(vertical.getLowerBound(), 1);
assertBound(vertical.getUpperBound(), "klev");
assertEquals(vertical.getLowerBound(), vertical.getIterationLowerBound());
assertEquals(vertical.getUpperBound(), vertical.getIterationUpperBound());
assertBound(vertical.getIterationStep(), 1);
assertNull(cfg.getDimension("unknown"));
assertNull(cfg.getDimension(null));
assertNotNull(cfg.getDefaultLayout());
assertFalse(cfg.hasLayout(null));
assertLayout(cfg, "cpu", 1);
assertLayout(cfg, "gpu", 1);
assertLayout(cfg, "radiation", 1);
assertTrue(cfg.getLayout("unknown").isEmpty());
assertTrue(cfg.getLayout(null).isEmpty());
} catch (Exception ignored) {
fail();
}
}
use of claw.tatsu.xcodeml.abstraction.DimensionDefinition in project claw-compiler by C2SM-RCM.
the class ModelConfigTest method layoutTest.
@Test
public void layoutTest() {
ModelConfig cfg = new ModelConfig();
assertEquals(0, cfg.getNbLayouts());
DimensionDefinition d = new DimensionDefinition("dim1", "0", "ndim1");
assertTrue(cfg.getDefaultLayout().isEmpty());
assertFalse(cfg.hasDimension(d.getIdentifier()));
cfg.putDefaultLayout(Collections.singletonList(d));
assertFalse(cfg.getDefaultLayout().isEmpty());
assertTrue(cfg.hasDimension(d.getIdentifier()));
assertEquals(d, cfg.getDimension(d.getIdentifier()));
assertEquals(1, cfg.getDefaultLayout().size());
assertEquals(d, cfg.getDefaultLayout().get(0));
}
use of claw.tatsu.xcodeml.abstraction.DimensionDefinition in project claw-compiler by C2SM-RCM.
the class LoopTest method mergeTest.
@Test
public void mergeTest() {
Context context = new TestContext();
XcodeML xcodeml = XmlHelper.getDummyXcodeProgram(context);
assertNotNull(xcodeml);
DimensionDefinition d1 = new DimensionDefinition("i", "1", "10");
Xnode inductionI = xcodeml.createVar(FortranType.INTEGER, "i", Xscope.LOCAL);
Xnode l1 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
Xnode l2 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
assertFalse(fctDefs.isEmpty());
FfunctionDefinition f1 = fctDefs.get(0);
int doStmtCnt1 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
f1.body().append(l1);
f1.body().append(l2);
int doStmtCnt2 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 2, doStmtCnt2);
try {
Loop.merge(l1, l2);
} catch (IllegalTransformationException e) {
fail();
}
int doStmtCnt3 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 1, doStmtCnt3);
}
Aggregations