Search in sources :

Example 6 with ClawPragma

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

the class ClawPragmaTest method assertValidSavepointClause.

private void assertValidSavepointClause(String rawDirective, String expectedSavepointName, Map<String, String> expectedMetadata) {
    ClawPragma l = analyze(rawDirective, ClawDirective.SCA);
    assertNotNull(l);
    assertFalse(l.isEndPragma());
    assertTrue(l.hasClause(ClawClause.SAVEPOINT));
    assertEquals(expectedSavepointName, l.value(ClawClause.SAVEPOINT));
    if (expectedMetadata != null) {
        assertEquals(expectedMetadata.size(), l.getMetadataMap().size());
        for (String key : expectedMetadata.keySet()) {
            assertTrue(l.getMetadataMap().containsKey(key));
            assertEquals(expectedMetadata.get(key), l.getMetadataMap().get(key));
        }
    }
}
Also used : ClawPragma(claw.wani.language.ClawPragma)

Example 7 with ClawPragma

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

the class ClawPragmaTest method analyzeValidClawLoopExtract.

/**
 * Assert the result for valid loop extract CLAW directive
 *
 * @param raw       Raw string value of the CLAW directive to be analyzed.
 * @param induction Induction var to be found.
 * @param lower     Lower bound value to be found.
 * @param upper     Upper bound value to be found.
 * @param step      Step valu to be found if any.
 */
private ClawPragma analyzeValidClawLoopExtract(String raw, String induction, String lower, String upper, String step, List<Target> targets) {
    ClawPragma l = analyze(raw, ClawDirective.LOOP_EXTRACT);
    assertNotNull(l);
    assertEquals(induction, l.getRange().getInductionVar());
    assertEquals(lower, l.getRange().getLowerBound());
    assertEquals(upper, l.getRange().getUpperBound());
    if (step != null) {
        assertEquals(step, l.getRange().getStep());
    }
    assertTargets(l, targets);
    return l;
}
Also used : ClawPragma(claw.wani.language.ClawPragma)

Example 8 with ClawPragma

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

the class DirectivePrimitive method transform.

/**
 * Apply the directive primitive transformation.
 *
 * @param xcodeml        The XcodeML on which the transformations are applied.
 * @param translator     The translator used to applied the transformations.
 * @param transformation Not used in this transformation
 * @throws IllegalTransformationException if the transformation cannot be
 *                                        applied.
 */
@Override
public void transform(XcodeProgram xcodeml, Translator translator, Transformation transformation) throws IllegalTransformationException {
    String prefix = xcodeml.context().getGenerator().getDirectiveLanguage().getPrefix();
    if (prefix == null) {
        return;
    }
    if (getDirective().getPragma().value().toLowerCase().contains(prefix)) {
        String regex = ClawConstant.CLAW + " *" + prefix;
        getDirective().getPragma().setValue(getDirective().getPragma().value().replaceAll(regex, prefix));
        getDirective().getPragma().setValue(getDirective().getPragma().value().replaceAll(ClawConstant.CLAW, ""));
    }
    translator.addTransformation(xcodeml, new OpenAccContinuation((ClawPragma) getDirective()));
}
Also used : OpenAccContinuation(claw.wani.transformation.internal.OpenAccContinuation) ClawPragma(claw.wani.language.ClawPragma)

Example 9 with ClawPragma

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

the class ClawTranslator method applyInterchangeClause.

/**
 * Generate loop interchange transformation if the clause is present in the
 * directive.
 *
 * @param claw    ClawPragma object that tells encapsulates all information
 *                about the current directives and its clauses.
 * @param xcodeml Current XcodeML program.
 * @param stmt    Statement on which the transformation is attached. Must be a
 *                FdoStatement for the loop interchange transformation.
 */
private void applyInterchangeClause(ClawPragma claw, XcodeProgram xcodeml, Xnode stmt) throws IllegalTransformationException {
    if (claw.hasClause(ClawClause.INTERCHANGE) && Xnode.isOfCode(stmt, Xcode.F_DO_STATEMENT)) {
        Xnode p = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
        stmt.insertBefore(p);
        ClawPragma l = ClawPragma.createLoopInterchangeLanguage(claw, p);
        LoopInterchange interchange = new LoopInterchange(l);
        addTransformation(xcodeml, interchange);
        Message.debug(context(), "Loop interchange added: " + claw.values(ClawClause.INTERCHANGE_INDEXES));
    }
}
Also used : Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) LoopInterchange(claw.wani.transformation.ll.loop.LoopInterchange) ClawPragma(claw.wani.language.ClawPragma)

Example 10 with ClawPragma

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

the class ClawTranslator method applyFusionClause.

/**
 * Generate loop fusion transformation if the clause is present in the
 * directive.
 *
 * @param claw    ClawPragma object that tells encapsulates all information
 *                about the current directives and its clauses.
 * @param xcodeml Current XcodeML program.
 * @param stmt    Statement on which the transformation is attached. Must be a
 *                FdoStatement for the loop fusion transformation.
 */
private void applyFusionClause(ClawPragma claw, XcodeProgram xcodeml, Xnode stmt) throws IllegalTransformationException {
    if (claw.hasClause(ClawClause.FUSION) && Xnode.isOfCode(stmt, Xcode.F_DO_STATEMENT)) {
        ClawPragma l = ClawPragma.createLoopFusionLanguage(claw);
        addTransformation(xcodeml, new LoopFusion(stmt, l));
        Message.debug(context(), "Loop fusion added: " + claw.value(ClawClause.GROUP));
    }
}
Also used : LoopFusion(claw.wani.transformation.ll.loop.LoopFusion) ClawPragma(claw.wani.language.ClawPragma)

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