Search in sources :

Example 21 with DimensionDefinition

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();
    }
}
Also used : DimensionDefinition(claw.tatsu.xcodeml.abstraction.DimensionDefinition) Test(org.junit.Test)

Example 22 with DimensionDefinition

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));
}
Also used : DimensionDefinition(claw.tatsu.xcodeml.abstraction.DimensionDefinition) Test(org.junit.Test)

Example 23 with DimensionDefinition

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);
}
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) XcodeML(claw.tatsu.xcodeml.xnode.common.XcodeML) DimensionDefinition(claw.tatsu.xcodeml.abstraction.DimensionDefinition) Test(org.junit.Test)

Aggregations

DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)23 Test (org.junit.Test)9 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)4 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)4 PromotionInfo (claw.tatsu.xcodeml.abstraction.PromotionInfo)3 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)3 ArrayList (java.util.ArrayList)3 Context (claw.tatsu.common.Context)2 FbasicType (claw.tatsu.xcodeml.xnode.fortran.FbasicType)2 ClawConstraint (claw.wani.language.ClawConstraint)2 ClawPragma (claw.wani.language.ClawPragma)2 TestContext (helper.Utils.TestContext)2 List (java.util.List)2 TomlArray (net.consensys.cava.toml.TomlArray)2 TomlTable (net.consensys.cava.toml.TomlTable)2 InsertionPosition (claw.tatsu.xcodeml.abstraction.InsertionPosition)1 NestedDoStatement (claw.tatsu.xcodeml.abstraction.NestedDoStatement)1 XcodeML (claw.tatsu.xcodeml.xnode.common.XcodeML)1 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)1