Search in sources :

Example 11 with ClawPragma

use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.

the class ClawPragmaTest method analyzeValidLoopHoist.

/**
 * Assert the result for valid CLAW loop-hoist directive
 *
 * @param raw         Raw string value of the CLAW directive to be analyzed.
 * @param inductions  List of induction variables to be checked.
 * @param interchange If true, the interchange clause is set.
 * @param indexes     Interchange indexes values.
 * @param reshape     If true, the reshape clause is set.
 * @param infos       Reshape clause values.
 * @param targets     Target clause values. Null if not set.
 * @param fusion      If true, the fusion clause is set.
 * @param group       Group clause value. Null if not set.
 * @param collapse    Collapse clause value. 0 if not set.
 */
private void analyzeValidLoopHoist(String raw, List<String> inductions, boolean interchange, List<String> indexes, boolean reshape, List<ReshapeInfo> infos, List<Target> targets, boolean fusion, String group, int collapse, boolean cleanup, CompilerDirective cleanupValue) {
    ClawPragma l = analyze(raw, ClawDirective.LOOP_HOIST);
    assertNotNull(l);
    assertEquals(inductions.size(), l.values(ClawClause.HOIST_INDUCTIONS).size());
    for (int i = 0; i < inductions.size(); ++i) {
        assertEquals(inductions.get(i), l.values(ClawClause.HOIST_INDUCTIONS).get(i));
    }
    if (interchange) {
        assertTrue(l.hasClause(ClawClause.INTERCHANGE));
    } else {
        assertFalse(l.hasClause(ClawClause.INTERCHANGE));
    }
    if (indexes != null) {
        for (int i = 0; i < indexes.size(); ++i) {
            assertEquals(indexes.get(i), l.values(ClawClause.INTERCHANGE_INDEXES).get(i));
        }
    }
    if (reshape) {
        assertTrue(l.hasClause(ClawClause.RESHAPE));
        assertEquals(infos.size(), l.getReshapeClauseValues().size());
        for (int i = 0; i < infos.size(); ++i) {
            assertEquals(infos.get(i).getArrayName(), l.getReshapeClauseValues().get(i).getArrayName());
            assertEquals(infos.get(i).getTargetDimension(), l.getReshapeClauseValues().get(i).getTargetDimension());
            List<Integer> expected = infos.get(i).getKeptDimensions();
            List<Integer> actual = l.getReshapeClauseValues().get(i).getKeptDimensions();
            assertEquals(expected.size(), actual.size());
            for (int j = 0; j < expected.size(); ++j) {
                assertEquals(expected.get(j), actual.get(j));
            }
        }
    } else {
        assertFalse(l.hasClause(ClawClause.RESHAPE));
    }
    assertTargets(l, targets);
    assertEquals(fusion, l.hasClause(ClawClause.FUSION));
    if (group != null) {
        assertTrue(l.hasClause(ClawClause.GROUP));
        assertEquals(group, l.value(ClawClause.GROUP));
    } else {
        assertFalse(l.hasClause(ClawClause.GROUP));
    }
    if (collapse > 0) {
        assertTrue(l.hasClause(ClawClause.COLLAPSE));
        assertEquals(collapse, l.getCollapseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.COLLAPSE));
    }
    if (cleanup) {
        assertTrue(l.hasClause(ClawClause.CLEANUP));
        assertSame(cleanupValue, l.getCleanupClauseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.CLEANUP));
    }
}
Also used : ClawPragma(claw.wani.language.ClawPragma) ClawConstraint(claw.wani.language.ClawConstraint)

Example 12 with ClawPragma

use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.

the class ClawPragmaTest method analyzeValidClawLoopFusion.

/**
 * Assert the result for valid loop fusion CLAW directive
 *
 * @param raw       Raw string value of the CLAW directive to be analyzed.
 * @param groupName Group name to be found if any.
 */
private void analyzeValidClawLoopFusion(String raw, String groupName, boolean collapse, int n, List<Target> targets, ClawConstraint constraint) {
    ClawPragma l = analyze(raw, ClawDirective.LOOP_FUSION);
    assertNotNull(l);
    if (groupName != null) {
        assertTrue(l.hasClause(ClawClause.GROUP));
        assertEquals(groupName, l.value(ClawClause.GROUP));
    } else {
        assertFalse(l.hasClause(ClawClause.GROUP));
        assertNull(l.value(ClawClause.GROUP));
    }
    if (collapse) {
        assertTrue(l.hasClause(ClawClause.COLLAPSE));
        assertEquals(n, l.getCollapseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.COLLAPSE));
    }
    if (constraint != null) {
        assertTrue(l.hasClause(ClawClause.CONSTRAINT));
        assertEquals(constraint, l.getConstraintClauseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.CONSTRAINT));
    }
    assertTargets(l, targets);
}
Also used : ClawPragma(claw.wani.language.ClawPragma)

Example 13 with ClawPragma

use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.

the class ClawPragmaTest method analyzeValidKcache.

/**
 * Assert the result for valid CLAW kcache directive
 *
 * @param raw     Raw string value of the CLAW directive to be analyzed.
 * @param data    List of identifiers to be checked.
 * @param offsets List of offsets to be checked.
 * @param init    If true, check that ClawPragma object has init clause enabled.
 */
private void analyzeValidKcache(String raw, List<String> data, List<Integer> offsets, boolean init, boolean hasPrivate, List<Target> targets) {
    ClawPragma l = analyze(raw, ClawDirective.KCACHE);
    assertNotNull(l);
    assertClauseListValues(l, ClawClause.DATA, data);
    if (offsets != null) {
        assertEquals(offsets.size(), l.getOffsets().size());
        for (int i = 0; i < offsets.size(); ++i) {
            assertEquals(offsets.get(i), l.getOffsets().get(i));
        }
    }
    if (init) {
        assertTrue(l.hasClause(ClawClause.INIT));
    } else {
        assertFalse(l.hasClause(ClawClause.INIT));
    }
    if (hasPrivate) {
        assertTrue(l.hasClause(ClawClause.PRIVATE));
    } else {
        assertFalse(l.hasClause(ClawClause.PRIVATE));
    }
    assertTargets(l, targets);
}
Also used : ClawPragma(claw.wani.language.ClawPragma) ClawConstraint(claw.wani.language.ClawConstraint)

Example 14 with ClawPragma

use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.

the class ClawPragmaTest method analyzeValidOverSCA.

/**
 * Assert the result for valid CLAW sca directive with data over clause.
 *
 * @param raw        Raw string value of the CLAW directive to be analyzed.
 * @param datas      Reference list for the data clause values.
 * @param dimensions Reference list of dimensions.
 */
private void analyzeValidOverSCA(String raw, List<List<String>> datas, List<List<DimensionDefinition>> dimensions) {
    ClawPragma l = analyze(raw, ClawDirective.SCA);
    assertNotNull(l);
    if (datas != null) {
        assertEquals(datas.size(), dimensions.size());
        assertTrue(l.hasClause(ClawClause.DATA_OVER));
        for (int j = 0; j < datas.size(); ++j) {
            List<String> data = datas.get(j);
            List<DimensionDefinition> dimension = dimensions.get(j);
            for (String id : data) {
                assertNotNull(l.getLayoutForData(cfg, id));
                List<DimensionDefinition> dims = l.getLayoutForData(cfg, id);
                assertEquals(dimension.size(), dims.size());
                for (int i = 0; i < dimension.size(); ++i) {
                    assertEquals(dimension.get(i).getIdentifier(), dims.get(i).getIdentifier());
                    assertEquals(dimension.get(i).getInsertionPosition(), dims.get(i).getInsertionPosition());
                    assertEquals(dimension.get(i).getLowerBound().isVar(), dims.get(i).getLowerBound().isVar());
                    assertEquals(dimension.get(i).getLowerBound().getValue(), dims.get(i).getLowerBound().getValue());
                    assertEquals(dimension.get(i).getLowerBound().getIntValue(), dims.get(i).getLowerBound().getIntValue());
                    assertEquals(dimension.get(i).getUpperBound().isVar(), dims.get(i).getUpperBound().isVar());
                    assertEquals(dimension.get(i).getUpperBound().getValue(), dims.get(i).getUpperBound().getValue());
                    assertEquals(dimension.get(i).getUpperBound().getIntValue(), dims.get(i).getUpperBound().getIntValue());
                }
            }
        }
    }
}
Also used : DimensionDefinition(claw.tatsu.xcodeml.abstraction.DimensionDefinition) ClawPragma(claw.wani.language.ClawPragma) ClawConstraint(claw.wani.language.ClawConstraint)

Example 15 with ClawPragma

use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.

the class ClawPragmaTest method analyzeValidArrayToFctCall.

/**
 * Assert the result for valid CLAW call directive
 *
 * @param raw       Raw string value of the CLAW directive to be analyzed.
 * @param arrayName Array name to be checked.
 * @param fctName   Function name to be checked.
 * @param params    List of parameters identifier to be checked.
 */
private void analyzeValidArrayToFctCall(String raw, String arrayName, String fctName, List<String> params, List<Target> targets) {
    ClawPragma l = analyze(raw, ClawDirective.ARRAY_TO_CALL);
    assertNotNull(l);
    assertEquals(params.size(), l.values(ClawClause.FCT_PARAMETERS).size());
    for (int i = 0; i < params.size(); ++i) {
        assertEquals(params.get(i), l.values(ClawClause.FCT_PARAMETERS).get(i));
    }
    assertEquals(arrayName, l.value(ClawClause.ARRAY_NAME));
    assertEquals(fctName, l.value(ClawClause.FCT_NAME));
    assertTargets(l, targets);
}
Also used : ClawPragma(claw.wani.language.ClawPragma) ClawConstraint(claw.wani.language.ClawConstraint)

Aggregations

ClawPragma (claw.wani.language.ClawPragma)21 ClawConstraint (claw.wani.language.ClawConstraint)5 IllegalDirectiveException (claw.tatsu.xcodeml.exception.IllegalDirectiveException)3 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)3 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)2 Test (org.junit.Test)2 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)1 ClawMapping (claw.wani.language.ClawMapping)1 OpenAccContinuation (claw.wani.transformation.internal.OpenAccContinuation)1 LoopFusion (claw.wani.transformation.ll.loop.LoopFusion)1 LoopInterchange (claw.wani.transformation.ll.loop.LoopInterchange)1 GroupConfiguration (claw.wani.x2t.configuration.GroupConfiguration)1 IOException (java.io.IOException)1