Search in sources :

Example 1 with ClawPragma

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

the class ClawTranslator method handleBlockDirective.

/**
 * Associate correctly the start and end directive to form blocks.
 *
 * @param xcodeml        Current translation unit.
 * @param analyzedPragma Analyzed pragma object to be handle.
 */
private void handleBlockDirective(XcodeProgram xcodeml, ClawPragma analyzedPragma) throws IllegalDirectiveException, IllegalTransformationException {
    int depth = analyzedPragma.getPragma().depth();
    ClawDirectiveKey crtRemoveKey = new ClawDirectiveKey(analyzedPragma.getDirective(), depth);
    if (analyzedPragma.isEndPragma()) {
        ClawPragma start = getBlockDirectiveStart(crtRemoveKey);
        if (start == null) {
            throw new IllegalDirectiveException(analyzedPragma.getDirective().name(), "Invalid CLAW directive (end with no start)", analyzedPragma.getPragma().lineNo());
        } else {
            createBlockDirectiveTransformation(xcodeml, start, analyzedPragma);
        }
    } else {
        addStartBlockDirective(analyzedPragma, crtRemoveKey);
    }
}
Also used : IllegalDirectiveException(claw.tatsu.xcodeml.exception.IllegalDirectiveException) ClawPragma(claw.wani.language.ClawPragma)

Example 2 with ClawPragma

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

the class ClawPragmaTest method analyzeValidScaDataMgtString.

/**
 * Assert the result for valid CLAW SCA directive
 */
private void analyzeValidScaDataMgtString(String raw, DataMovement update, DataMovement copy, boolean createClause) {
    ClawPragma l = analyze(raw, ClawDirective.SCA);
    assertNotNull(l);
    assertEquals(createClause, l.hasClause(ClawClause.CREATE));
    if (update != null) {
        assertTrue(l.hasClause(ClawClause.UPDATE));
        assertEquals(update, l.getUpdateClauseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.UPDATE));
    }
    if (copy != null) {
        assertTrue(l.hasClause(ClawClause.COPY));
        assertEquals(copy, l.getCopyClauseValue());
    } else {
        assertFalse(l.hasClause(ClawClause.COPY));
    }
}
Also used : ClawPragma(claw.wani.language.ClawPragma)

Example 3 with ClawPragma

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

the class ClawPragmaTest method analyzeValidExpandNotation.

/**
 * Assert the result for valid CLAW expand directive
 *
 * @param raw         Raw string value of the CLAW directive to be analyzed.
 * @param fusion      Set to true if the extracted option should be present.
 * @param fusionGroup Name of the group in the extracted fusion option.
 * @param parallel    Set to true if parallel clause should be present.
 * @param update      Set to true if update clause should be present.
 * @param acc         String of acc clauses that should be present.
 * @param inducNames  Induction variables names.
 * @param targets     Assert target clause.
 */
private void analyzeValidExpandNotation(String raw, boolean fusion, String fusionGroup, boolean parallel, boolean update, String acc, List<String> inducNames, List<Target> targets, String savepoint) {
    ClawPragma l = analyze(raw, ClawDirective.EXPAND);
    assertNotNull(l);
    if (fusion) {
        assertTrue(l.hasClause(ClawClause.FUSION));
        assertEquals(fusionGroup, l.value(ClawClause.GROUP));
    } else {
        assertFalse(l.hasClause(ClawClause.FUSION));
        assertNull(l.value(ClawClause.GROUP));
    }
    if (parallel) {
        assertTrue(l.hasClause(ClawClause.PARALLEL));
    } else {
        assertFalse(l.hasClause(ClawClause.PARALLEL));
    }
    if (update) {
        assertTrue(l.hasClause(ClawClause.UPDATE));
    } else {
        assertFalse(l.hasClause(ClawClause.UPDATE));
    }
    if (acc != null) {
        assertTrue(l.hasClause(ClawClause.ACC));
        assertEquals(acc, l.value(ClawClause.ACC));
    } else {
        assertFalse(l.hasClause(ClawClause.ACC));
    }
    if (savepoint != null) {
        assertTrue(l.hasClause(ClawClause.SAVEPOINT));
        assertEquals(savepoint, l.value(ClawClause.SAVEPOINT));
    } else {
        assertFalse(l.hasClause(ClawClause.SAVEPOINT));
    }
    assertClauseListValues(l, ClawClause.INDUCTION, inducNames);
    assertTargets(l, targets);
}
Also used : ClawPragma(claw.wani.language.ClawPragma)

Example 4 with ClawPragma

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

the class ClawPragmaTest method analyze.

/**
 * Execute the parsing on the raw string and return a ClawPragma object if
 * successful.
 *
 * @param raw       Raw directive.
 * @param directive Expected directive.
 * @return ClawPragma object with information extracted from parsing.
 */
private ClawPragma analyze(String raw, ClawDirective directive) {
    try {
        Xnode p = XmlHelper.createXpragma();
        p.setValue(raw);
        ClawPragma l = ClawPragma.analyze(p);
        assertEquals(directive, l.getDirective());
        return l;
    } catch (IllegalDirectiveException idex) {
        fail();
    }
    return null;
}
Also used : Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) IllegalDirectiveException(claw.tatsu.xcodeml.exception.IllegalDirectiveException) ClawPragma(claw.wani.language.ClawPragma)

Example 5 with ClawPragma

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

the class ClawPragmaTest method analyzeValidSimpleClaw.

/**
 * Assert the result for valid simple CLAW directive
 *
 * @param raw       Raw string value of the CLAW directive to be analyzed.
 * @param directive Directive to be match.
 */
private void analyzeValidSimpleClaw(String raw, ClawDirective directive, boolean isEnd, List<Target> targets) {
    ClawPragma l = analyze(raw, directive);
    assertNotNull(l);
    if (isEnd) {
        assertTrue(l.isEndPragma());
    } else {
        assertFalse(l.isEndPragma());
    }
    assertTargets(l, targets);
}
Also used : 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