Search in sources :

Example 1 with OpenAccContinuation

use of cx2x.translator.transformation.openacc.OpenAccContinuation in project claw-compiler by C2SM-RCM.

the class ClawXcodeMlTranslator method analyze.

/**
   * Analysis the XcodeML code and produce a list of applicable transformation.
   */
public void analyze() {
    _program = XcodeProgram.createFromFile(_xcodemlInputFile);
    if (_program == null) {
        abort();
    }
    // Check all pragma found in the program
    for (Xnode pragma : _program.getAllStmt(Xcode.FPRAGMASTATEMENT)) {
        // pragma does not start with the CLAW prefix
        if (!ClawLanguage.startsWithClaw(pragma)) {
            // Compile guard removal
            if (_generator != null && _generator.isCompileGuard(pragma.value())) {
                pragma.delete();
            } else // Handle special transformation of OpenACC line continuation
            if (pragma.value().toLowerCase().startsWith(ClawConstant.OPENACC_PREFIX)) {
                OpenAccContinuation t = new OpenAccContinuation(new AnalyzedPragma(pragma));
                addOrAbort(t);
            }
            // Not CLAW pragma, we do nothing
            continue;
        }
        try {
            // Analyze the raw pragma with the CLAW language parser
            ClawLanguage analyzedPragma = ClawLanguage.analyze(pragma, _generator, _target);
            // Create transformation object based on the directive
            switch(analyzedPragma.getDirective()) {
                case ARRAY_TO_CALL:
                    addOrAbort(new ArrayToFctCall(analyzedPragma));
                    break;
                case KCACHE:
                    addOrAbort(new Kcaching(analyzedPragma));
                    break;
                case LOOP_FUSION:
                    addOrAbort(new LoopFusion(analyzedPragma));
                    break;
                case LOOP_INTERCHANGE:
                    addOrAbort(new LoopInterchange(analyzedPragma));
                    break;
                case LOOP_EXTRACT:
                    addOrAbort(new LoopExtraction(analyzedPragma));
                    break;
                case LOOP_HOIST:
                    HandleBlockDirective(analyzedPragma);
                    break;
                case ARRAY_TRANSFORM:
                    HandleBlockDirective(analyzedPragma);
                    break;
                case REMOVE:
                    HandleBlockDirective(analyzedPragma);
                    break;
                case PARALLELIZE:
                    if (analyzedPragma.hasForwardClause()) {
                        addOrAbort(new ParallelizeForward(analyzedPragma));
                    } else {
                        addOrAbort(new Parallelize(analyzedPragma));
                    }
                    break;
                case PRIMITIVE:
                    addOrAbort(new DirectivePrimitive(analyzedPragma));
                    break;
                case IF_EXTRACT:
                    addOrAbort(new IfExtract(analyzedPragma));
                    break;
                // driver handled directives
                case IGNORE:
                case VERBATIM:
                    break;
                default:
                    _program.addError("Unrecognized CLAW directive", pragma.lineNo());
                    abort();
            }
        } catch (IllegalDirectiveException ex) {
            System.err.println(ex.getMessage());
            abort();
        }
    }
    // Clean up block transformation map
    for (Map.Entry<ClawDirectiveKey, ClawLanguage> entry : _blockDirectives.entrySet()) {
        createBlockDirectiveTransformation(entry.getValue(), null);
    }
    // Add utility transformation
    addOrAbort(new XcodeMLWorkaround(new ClawLanguage(_program)));
    // Analysis done, the transformation can be performed.
    _canTransform = true;
}
Also used : ArrayToFctCall(cx2x.translator.transformation.claw.ArrayToFctCall) IllegalDirectiveException(cx2x.xcodeml.exception.IllegalDirectiveException) Parallelize(cx2x.translator.transformation.claw.parallelize.Parallelize) AnalyzedPragma(cx2x.xcodeml.language.AnalyzedPragma) Xnode(cx2x.xcodeml.xnode.Xnode) DirectivePrimitive(cx2x.translator.transformation.openacc.DirectivePrimitive) XcodeMLWorkaround(cx2x.translator.transformation.utility.XcodeMLWorkaround) OpenAccContinuation(cx2x.translator.transformation.openacc.OpenAccContinuation) ParallelizeForward(cx2x.translator.transformation.claw.parallelize.ParallelizeForward) ClawLanguage(cx2x.translator.language.base.ClawLanguage) Kcaching(cx2x.translator.transformation.claw.Kcaching)

Aggregations

ClawLanguage (cx2x.translator.language.base.ClawLanguage)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 IllegalDirectiveException (cx2x.xcodeml.exception.IllegalDirectiveException)1 AnalyzedPragma (cx2x.xcodeml.language.AnalyzedPragma)1 Xnode (cx2x.xcodeml.xnode.Xnode)1