Search in sources :

Example 11 with AcceleratorGenerator

use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator 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 12 with AcceleratorGenerator

use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator 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

Configuration (cx2x.translator.config.Configuration)12 AcceleratorGenerator (cx2x.translator.language.helper.accelerator.AcceleratorGenerator)12 Xnode (cx2x.xcodeml.xnode.Xnode)12 IllegalDirectiveException (cx2x.xcodeml.exception.IllegalDirectiveException)11 ClawLanguage (cx2x.translator.language.base.ClawLanguage)10 ClawConstraint (cx2x.translator.language.common.ClawConstraint)5 ClawTransformer (cx2x.translator.transformer.ClawTransformer)1 XcodeProgram (cx2x.xcodeml.xnode.XcodeProgram)1 File (java.io.File)1 Test (org.junit.Test)1