use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator in project claw-compiler by C2SM-RCM.
the class ClawLanguageTest 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 ClawLanguage analyzeValidClawLoopExtract(String raw, String induction, String lower, String upper, String step, 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_EXTRACT, l.getDirective());
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;
} catch (IllegalDirectiveException idex) {
System.err.println(idex.getMessage());
fail();
return null;
}
}
use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator in project claw-compiler by C2SM-RCM.
the class DependenceAnalysisTest method analyzeTest3d.
/**
* Test the IterationSpace feature of fusion and check the results.
*/
@Test
public void analyzeTest3d() {
// Load test data file
File f = new File(TestConstant.TEST_DEPENDENCE_3D);
assertTrue(f.exists());
XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_DEPENDENCE_3D);
assertNotNull(xcodeml);
// Match all the function definitions
List<Xnode> functions = xcodeml.matchAll(Xcode.FFUNCTIONDEFINITION);
assertEquals(2, functions.size());
// Match all the pragmas
List<Xnode> pragmas = xcodeml.matchAll(Xcode.FPRAGMASTATEMENT);
assertEquals(1, pragmas.size());
// Analyze the pragma
Configuration configuration = new Configuration(AcceleratorDirective.OPENACC, Target.GPU);
configuration.setMaxColumns(80);
ClawTransformer transformer = new ClawTransformer(configuration);
AcceleratorGenerator generator = AcceleratorHelper.createAcceleratorGenerator(configuration);
ClawLanguage main = null;
try {
main = ClawLanguage.analyze(pragmas.get(0), generator, Target.GPU);
} catch (Exception e) {
fail();
}
// Get the function definition that interests us
Xnode fctDef = functions.get(0);
// Match all the do statements in the function
List<Xnode> loops = fctDef.matchAll(Xcode.FDOSTATEMENT);
assertEquals(11, loops.size());
// Create an iteration space
try {
IterationSpace is = new IterationSpace(loops);
is.tryFusion(xcodeml, transformer, main);
System.out.println();
System.out.println("Iteration space before fusion");
is.printDebug(true);
loops = fctDef.matchAll(Xcode.FDOSTATEMENT);
assertEquals(8, loops.size());
is.reload(loops);
System.out.println();
System.out.println("Iteration space after fusion");
is.printDebug(true);
} catch (Exception e) {
fail();
}
}
use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator in project claw-compiler by C2SM-RCM.
the class ClawLanguageTest method analyzeValidParallelize.
/**
* Assert the result for valid CLAW parallelize directive
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param data Reference list for the data clause values.
* @param over Reference list for the over clause values.
* @param dimensions Reference list of dimensions.
* @param copyClause Expected value for copy clause (Null if no copy clause)
* @param updateClause Expected value for update clause
* (Null if no update clause)
*/
private void analyzeValidParallelize(String raw, List<List<String>> data, List<List<String>> over, List<ClawDimension> dimensions, ClawDMD copyClause, ClawDMD updateClause) {
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.PARALLELIZE, l.getDirective());
if (data != null) {
assertTrue(l.hasOverDataClause());
assertEquals(data.size(), l.getOverDataClauseValues().size());
for (int i = 0; i < data.size(); ++i) {
assertEquals(data.get(i).size(), l.getOverDataClauseValues().get(i).size());
for (int j = 0; j < data.get(i).size(); ++j) {
assertEquals(data.get(i).get(j), l.getOverDataClauseValues().get(i).get(j));
}
}
}
if (over != null) {
assertTrue(l.hasOverClause());
assertEquals(over.size(), l.getOverClauseValues().size());
for (int i = 0; i < over.size(); ++i) {
assertEquals(over.get(i).size(), l.getOverClauseValues().get(i).size());
for (int j = 0; j < over.get(i).size(); ++j) {
assertEquals(over.get(i).get(j), l.getOverClauseValues().get(i).get(j));
}
}
}
if (dimensions != null) {
assertEquals(dimensions.size(), l.getDimensionValues().size());
for (int i = 0; i < dimensions.size(); ++i) {
assertEquals(dimensions.get(i).getIdentifier(), l.getDimensionValues().get(i).getIdentifier());
assertEquals(dimensions.get(i).lowerBoundIsVar(), l.getDimensionValues().get(i).lowerBoundIsVar());
assertEquals(dimensions.get(i).upperBoundIsVar(), l.getDimensionValues().get(i).upperBoundIsVar());
assertEquals(dimensions.get(i).getLowerBoundInt(), l.getDimensionValues().get(i).getLowerBoundInt());
assertEquals(dimensions.get(i).getUpperBoundInt(), l.getDimensionValues().get(i).getUpperBoundInt());
assertEquals(dimensions.get(i).getLowerBoundId(), l.getDimensionValues().get(i).getLowerBoundId());
assertEquals(dimensions.get(i).getUpperBoundId(), l.getDimensionValues().get(i).getUpperBoundId());
}
}
if (data == null && over == null && dimensions == null) {
assertTrue(l.hasForwardClause());
}
if (copyClause == null) {
assertFalse(l.hasCopyClause());
assertNull(l.getCopyClauseValue());
} else {
assertTrue(l.hasCopyClause());
assertEquals(copyClause, l.getCopyClauseValue());
}
if (updateClause == null) {
assertFalse(l.hasUpdateClause());
assertNull(l.getUpdateClauseValue());
} else {
assertTrue(l.hasUpdateClause());
assertEquals(updateClause, l.getUpdateClauseValue());
}
} catch (IllegalDirectiveException idex) {
System.err.print(idex.getMessage());
fail();
}
}
use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator 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();
}
}
use of cx2x.translator.language.helper.accelerator.AcceleratorGenerator 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());
}
}
Aggregations