Search in sources :

Example 11 with Configuration

use of cx2x.translator.config.Configuration in project claw-compiler by C2SM-RCM.

the class ClawLanguageTest 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) {
    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(directive, l.getDirective());
        if (isEnd) {
            assertTrue(l.isEndPragma());
        } else {
            assertFalse(l.isEndPragma());
        }
        assertTargets(l, targets);
    } catch (IllegalDirectiveException idex) {
        System.err.println(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) AcceleratorGenerator(cx2x.translator.language.helper.accelerator.AcceleratorGenerator)

Example 12 with Configuration

use of cx2x.translator.config.Configuration 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 13 with Configuration

use of cx2x.translator.config.Configuration 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 14 with Configuration

use of cx2x.translator.config.Configuration 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)14 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 GroupConfiguration (cx2x.translator.config.GroupConfiguration)2 File (java.io.File)2 FortranDecompiler (cx2x.decompiler.FortranDecompiler)1 ClawXcodeMlTranslator (cx2x.translator.ClawXcodeMlTranslator)1 ClawTransformationReport (cx2x.translator.report.ClawTransformationReport)1 ClawTransformer (cx2x.translator.transformer.ClawTransformer)1 XcodeProgram (cx2x.xcodeml.xnode.XcodeProgram)1 Test (org.junit.Test)1