use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class PragmaTest method splitByContTest.
@Test
public void splitByContTest() {
Context context = new TestContext();
context.init(CompilerDirective.OPENACC, Target.GPU, null, 80);
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
assertFalse(fctDefs.isEmpty());
FfunctionDefinition fd = fctDefs.get(0);
assertNotNull(fd.body());
List<Xnode> previous = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
Xnode p1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
fd.body().append(p1);
p1.setValue("acc data present(q,acc& p,acc& h)acc& create(pt)");
try {
Pragma.splitByCont(p1, CompilerDirective.OPENACC.getPrefix(), xcodeml);
List<Xnode> splittedPragma = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
assertEquals(previous.size() + 4, splittedPragma.size());
} catch (IllegalTransformationException e) {
fail();
}
Xnode p2 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
fd.body().append(p2);
p2.setValue("omp target teams omp& distribute simd");
try {
Pragma.splitByCont(p2, CompilerDirective.OPENMP.getPrefix(), xcodeml);
List<Xnode> splittedPragma = fd.matchAll(Xcode.F_PRAGMA_STATEMENT);
assertEquals(previous.size() + 6, splittedPragma.size());
} catch (IllegalTransformationException e) {
fail();
}
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class ClawTranslatorDriver method analyze.
/**
* Analysis the XcodeML/F directives and categorized them in corresponding
* transformation with the help of the translator.
*
* @throws Exception
*/
public void analyze(InputStream inStrm) throws Exception {
_translationUnit = XcodeProgram.createFromStream(inStrm, context());
if (_translationUnit.hasErrors()) {
flushErrors();
throw new Exception("Translation unit has errors");
}
if (cfg().getCurrentDirective() == CompilerDirective.OPENMP && cfg().getCurrentTarget() == Target.CPU) {
_translationUnit.addWarning("Fine grain OpenMP directive generation " + "is not advised for CPU target.", 0);
}
try {
// Check all pragma found in the translation unit
for (Xnode pragma : _translationUnit.matchAll(Xcode.F_PRAGMA_STATEMENT)) {
// Pragma can be handled by the translator so let it do its job.
if (_translator.isHandledPragma(pragma)) {
_translator.generateTransformation(_translationUnit, pragma);
} else {
// Check if the pragma is a compile guard
if (context().getGenerator().isCompileGuard(pragma.value())) {
pragma.delete();
} else {
// Handle special transformation of OpenACC line continuation
for (GroupConfiguration gc : cfg().getGroups()) {
if (gc.getTriggerType() == GroupConfiguration.TriggerType.DIRECTIVE && Pragma.getPrefix(pragma).equals(gc.getDirective())) {
generateTransformation(gc, new ClawPragma(pragma));
}
}
}
}
}
_translator.finalizeTranslation(_translationUnit);
} catch (IllegalDirectiveException e) {
_translationUnit.addError(e.getMessage(), e.getDirectiveLine());
flushErrors();
throw e;
} catch (IllegalTransformationException e) {
_translationUnit.addError(e.getMessage(), e.getStartLine());
flushErrors();
throw e;
}
// Generate transformation for translation_unit trigger type
for (GroupConfiguration gc : cfg().getGroups()) {
if (gc.getTriggerType() == GroupConfiguration.TriggerType.TRANSLATION_UNIT) {
generateTransformation(gc, null);
}
}
// Analysis done, the transformation can be performed.
_canTransform = true;
}
use of claw.tatsu.xcodeml.exception.IllegalTransformationException in project claw-compiler by C2SM-RCM.
the class LoopTest method mergeTest.
@Test
public void mergeTest() {
Context context = new TestContext();
XcodeML xcodeml = XmlHelper.getDummyXcodeProgram(context);
assertNotNull(xcodeml);
DimensionDefinition d1 = new DimensionDefinition("i", "1", "10");
Xnode inductionI = xcodeml.createVar(FortranType.INTEGER, "i", Xscope.LOCAL);
Xnode l1 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
Xnode l2 = xcodeml.createDoStmt(inductionI, d1.generateIndexRange(xcodeml, true, false));
List<FfunctionDefinition> fctDefs = xcodeml.getAllFctDef();
assertFalse(fctDefs.isEmpty());
FfunctionDefinition f1 = fctDefs.get(0);
int doStmtCnt1 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
f1.body().append(l1);
f1.body().append(l2);
int doStmtCnt2 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 2, doStmtCnt2);
try {
Loop.merge(l1, l2);
} catch (IllegalTransformationException e) {
fail();
}
int doStmtCnt3 = f1.matchAll(Xcode.F_DO_STATEMENT).size();
assertEquals(doStmtCnt1 + 1, doStmtCnt3);
}
Aggregations