Search in sources :

Example 11 with IllegalDirectiveException

use of cx2x.xcodeml.exception.IllegalDirectiveException in project claw-compiler by C2SM-RCM.

the class ClawLanguageTest method analyzeUnvalidClawLanguage.

/**
   * Assert any unvalid claw raw input
   *
   * @param raw Raw string value of the CLAW directive to be analyzed.
   */
private void analyzeUnvalidClawLanguage(String raw) {
    try {
        Xnode p = XmlHelper.createXpragma();
        p.setValue(raw);
        Configuration configuration = new Configuration(AcceleratorDirective.OPENACC, Target.GPU);
        AcceleratorGenerator generator = AcceleratorHelper.createAcceleratorGenerator(configuration);
        ClawLanguage.analyze(p, generator, Target.GPU);
        fail();
    } catch (IllegalDirectiveException pex) {
        assertNotNull(pex);
        assertNotNull(pex.getMessage());
    }
}
Also used : Xnode(cx2x.xcodeml.xnode.Xnode) IllegalDirectiveException(cx2x.xcodeml.exception.IllegalDirectiveException) Configuration(cx2x.translator.config.Configuration) AcceleratorGenerator(cx2x.translator.language.helper.accelerator.AcceleratorGenerator)

Example 12 with IllegalDirectiveException

use of cx2x.xcodeml.exception.IllegalDirectiveException in project claw-compiler by C2SM-RCM.

the class ClawLanguageTest 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) {
    try {
        Xnode p = XmlHelper.createXpragma();
        p.setValue(raw);
        Configuration configuration = new Configuration(AcceleratorDirective.OPENACC, Target.GPU);
        AcceleratorGenerator generator = AcceleratorHelper.createAcceleratorGenerator(configuration);
        ClawLanguage l = ClawLanguage.analyze(p, generator, Target.GPU);
        assertEquals(ClawDirective.ARRAY_TO_CALL, l.getDirective());
        assertEquals(params.size(), l.getFctParams().size());
        for (int i = 0; i < params.size(); ++i) {
            assertEquals(params.get(i), l.getFctParams().get(i));
        }
        assertEquals(arrayName, l.getArrayName());
        assertEquals(fctName, l.getFctName());
        assertTargets(l, targets);
    } catch (IllegalDirectiveException idex) {
        System.err.print(idex.getMessage());
        fail();
    }
}
Also used : Xnode(cx2x.xcodeml.xnode.Xnode) IllegalDirectiveException(cx2x.xcodeml.exception.IllegalDirectiveException) Configuration(cx2x.translator.config.Configuration) ClawLanguage(cx2x.translator.language.base.ClawLanguage) ClawConstraint(cx2x.translator.language.common.ClawConstraint) AcceleratorGenerator(cx2x.translator.language.helper.accelerator.AcceleratorGenerator)

Example 13 with IllegalDirectiveException

use of cx2x.xcodeml.exception.IllegalDirectiveException in project claw-compiler by C2SM-RCM.

the class ClawLanguageTest method analyzeValidClawLoopInterchange.

/**
   * Assert the result for valid loop interchange CLAW directive
   *
   * @param raw     Raw string value of the CLAW directive to be analyzed.
   * @param indexes List of indexes to be found if any.
   */
private void analyzeValidClawLoopInterchange(String raw, List<String> indexes, boolean parallel, String acc, List<Target> targets) {
    try {
        Xnode p = XmlHelper.createXpragma();
        p.setValue(raw);
        Configuration configuration = new Configuration(AcceleratorDirective.OPENACC, Target.GPU);
        AcceleratorGenerator generator = AcceleratorHelper.createAcceleratorGenerator(configuration);
        ClawLanguage l = ClawLanguage.analyze(p, generator, Target.GPU);
        assertEquals(ClawDirective.LOOP_INTERCHANGE, l.getDirective());
        if (indexes != null) {
            assertTrue(l.hasIndexes());
            assertEquals(indexes.size(), l.getIndexes().size());
        } else {
            assertFalse(l.hasIndexes());
            assertNull(l.getIndexes());
        }
        if (parallel) {
            assertTrue(l.hasParallelClause());
        } else {
            assertFalse(l.hasParallelClause());
        }
        if (acc != null) {
            assertTrue(l.hasAcceleratorClause());
            assertEquals(acc, l.getAcceleratorClauses());
        } else {
            assertFalse(l.hasAcceleratorClause());
            assertNull(l.getAcceleratorClauses());
        }
        assertTargets(l, targets);
    } catch (IllegalDirectiveException idex) {
        fail();
    }
}
Also used : Xnode(cx2x.xcodeml.xnode.Xnode) IllegalDirectiveException(cx2x.xcodeml.exception.IllegalDirectiveException) Configuration(cx2x.translator.config.Configuration) ClawLanguage(cx2x.translator.language.base.ClawLanguage) AcceleratorGenerator(cx2x.translator.language.helper.accelerator.AcceleratorGenerator)

Aggregations

IllegalDirectiveException (cx2x.xcodeml.exception.IllegalDirectiveException)13 Xnode (cx2x.xcodeml.xnode.Xnode)12 Configuration (cx2x.translator.config.Configuration)11 AcceleratorGenerator (cx2x.translator.language.helper.accelerator.AcceleratorGenerator)11 ClawLanguage (cx2x.translator.language.base.ClawLanguage)10 ClawConstraint (cx2x.translator.language.common.ClawConstraint)5 ClawLexer (cx2x.translator.language.parser.ClawLexer)1 ClawParser (cx2x.translator.language.parser.ClawParser)1 ArrayToFctCall (cx2x.translator.transformation.claw.ArrayToFctCall)1 Kcaching (cx2x.translator.transformation.claw.Kcaching)1 Parallelize (cx2x.translator.transformation.claw.parallelize.Parallelize)1 ParallelizeForward (cx2x.translator.transformation.claw.parallelize.ParallelizeForward)1 DirectivePrimitive (cx2x.translator.transformation.openacc.DirectivePrimitive)1 OpenAccContinuation (cx2x.translator.transformation.openacc.OpenAccContinuation)1 XcodeMLWorkaround (cx2x.translator.transformation.utility.XcodeMLWorkaround)1 AnalyzedPragma (cx2x.xcodeml.language.AnalyzedPragma)1 ParseCancellationException (org.antlr.v4.runtime.misc.ParseCancellationException)1