use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method assertValidSavepointClause.
private void assertValidSavepointClause(String rawDirective, String expectedSavepointName, Map<String, String> expectedMetadata) {
ClawPragma l = analyze(rawDirective, ClawDirective.SCA);
assertNotNull(l);
assertFalse(l.isEndPragma());
assertTrue(l.hasClause(ClawClause.SAVEPOINT));
assertEquals(expectedSavepointName, l.value(ClawClause.SAVEPOINT));
if (expectedMetadata != null) {
assertEquals(expectedMetadata.size(), l.getMetadataMap().size());
for (String key : expectedMetadata.keySet()) {
assertTrue(l.getMetadataMap().containsKey(key));
assertEquals(expectedMetadata.get(key), l.getMetadataMap().get(key));
}
}
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method analyzeValidClawLoopExtract.
/**
* Assert the result for valid loop extract CLAW directive
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param induction Induction var to be found.
* @param lower Lower bound value to be found.
* @param upper Upper bound value to be found.
* @param step Step valu to be found if any.
*/
private ClawPragma analyzeValidClawLoopExtract(String raw, String induction, String lower, String upper, String step, List<Target> targets) {
ClawPragma l = analyze(raw, ClawDirective.LOOP_EXTRACT);
assertNotNull(l);
assertEquals(induction, l.getRange().getInductionVar());
assertEquals(lower, l.getRange().getLowerBound());
assertEquals(upper, l.getRange().getUpperBound());
if (step != null) {
assertEquals(step, l.getRange().getStep());
}
assertTargets(l, targets);
return l;
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class DirectivePrimitive method transform.
/**
* Apply the directive primitive transformation.
*
* @param xcodeml The XcodeML on which the transformations are applied.
* @param translator The translator used to applied the transformations.
* @param transformation Not used in this transformation
* @throws IllegalTransformationException if the transformation cannot be
* applied.
*/
@Override
public void transform(XcodeProgram xcodeml, Translator translator, Transformation transformation) throws IllegalTransformationException {
String prefix = xcodeml.context().getGenerator().getDirectiveLanguage().getPrefix();
if (prefix == null) {
return;
}
if (getDirective().getPragma().value().toLowerCase().contains(prefix)) {
String regex = ClawConstant.CLAW + " *" + prefix;
getDirective().getPragma().setValue(getDirective().getPragma().value().replaceAll(regex, prefix));
getDirective().getPragma().setValue(getDirective().getPragma().value().replaceAll(ClawConstant.CLAW, ""));
}
translator.addTransformation(xcodeml, new OpenAccContinuation((ClawPragma) getDirective()));
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawTranslator method applyInterchangeClause.
/**
* Generate loop interchange transformation if the clause is present in the
* directive.
*
* @param claw ClawPragma object that tells encapsulates all information
* about the current directives and its clauses.
* @param xcodeml Current XcodeML program.
* @param stmt Statement on which the transformation is attached. Must be a
* FdoStatement for the loop interchange transformation.
*/
private void applyInterchangeClause(ClawPragma claw, XcodeProgram xcodeml, Xnode stmt) throws IllegalTransformationException {
if (claw.hasClause(ClawClause.INTERCHANGE) && Xnode.isOfCode(stmt, Xcode.F_DO_STATEMENT)) {
Xnode p = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
stmt.insertBefore(p);
ClawPragma l = ClawPragma.createLoopInterchangeLanguage(claw, p);
LoopInterchange interchange = new LoopInterchange(l);
addTransformation(xcodeml, interchange);
Message.debug(context(), "Loop interchange added: " + claw.values(ClawClause.INTERCHANGE_INDEXES));
}
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawTranslator method applyFusionClause.
/**
* Generate loop fusion transformation if the clause is present in the
* directive.
*
* @param claw ClawPragma object that tells encapsulates all information
* about the current directives and its clauses.
* @param xcodeml Current XcodeML program.
* @param stmt Statement on which the transformation is attached. Must be a
* FdoStatement for the loop fusion transformation.
*/
private void applyFusionClause(ClawPragma claw, XcodeProgram xcodeml, Xnode stmt) throws IllegalTransformationException {
if (claw.hasClause(ClawClause.FUSION) && Xnode.isOfCode(stmt, Xcode.F_DO_STATEMENT)) {
ClawPragma l = ClawPragma.createLoopFusionLanguage(claw);
addTransformation(xcodeml, new LoopFusion(stmt, l));
Message.debug(context(), "Loop fusion added: " + claw.value(ClawClause.GROUP));
}
}
Aggregations