use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method analyzeValidLoopHoist.
/**
* Assert the result for valid CLAW loop-hoist directive
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param inductions List of induction variables to be checked.
* @param interchange If true, the interchange clause is set.
* @param indexes Interchange indexes values.
* @param reshape If true, the reshape clause is set.
* @param infos Reshape clause values.
* @param targets Target clause values. Null if not set.
* @param fusion If true, the fusion clause is set.
* @param group Group clause value. Null if not set.
* @param collapse Collapse clause value. 0 if not set.
*/
private void analyzeValidLoopHoist(String raw, List<String> inductions, boolean interchange, List<String> indexes, boolean reshape, List<ReshapeInfo> infos, List<Target> targets, boolean fusion, String group, int collapse, boolean cleanup, CompilerDirective cleanupValue) {
ClawPragma l = analyze(raw, ClawDirective.LOOP_HOIST);
assertNotNull(l);
assertEquals(inductions.size(), l.values(ClawClause.HOIST_INDUCTIONS).size());
for (int i = 0; i < inductions.size(); ++i) {
assertEquals(inductions.get(i), l.values(ClawClause.HOIST_INDUCTIONS).get(i));
}
if (interchange) {
assertTrue(l.hasClause(ClawClause.INTERCHANGE));
} else {
assertFalse(l.hasClause(ClawClause.INTERCHANGE));
}
if (indexes != null) {
for (int i = 0; i < indexes.size(); ++i) {
assertEquals(indexes.get(i), l.values(ClawClause.INTERCHANGE_INDEXES).get(i));
}
}
if (reshape) {
assertTrue(l.hasClause(ClawClause.RESHAPE));
assertEquals(infos.size(), l.getReshapeClauseValues().size());
for (int i = 0; i < infos.size(); ++i) {
assertEquals(infos.get(i).getArrayName(), l.getReshapeClauseValues().get(i).getArrayName());
assertEquals(infos.get(i).getTargetDimension(), l.getReshapeClauseValues().get(i).getTargetDimension());
List<Integer> expected = infos.get(i).getKeptDimensions();
List<Integer> actual = l.getReshapeClauseValues().get(i).getKeptDimensions();
assertEquals(expected.size(), actual.size());
for (int j = 0; j < expected.size(); ++j) {
assertEquals(expected.get(j), actual.get(j));
}
}
} else {
assertFalse(l.hasClause(ClawClause.RESHAPE));
}
assertTargets(l, targets);
assertEquals(fusion, l.hasClause(ClawClause.FUSION));
if (group != null) {
assertTrue(l.hasClause(ClawClause.GROUP));
assertEquals(group, l.value(ClawClause.GROUP));
} else {
assertFalse(l.hasClause(ClawClause.GROUP));
}
if (collapse > 0) {
assertTrue(l.hasClause(ClawClause.COLLAPSE));
assertEquals(collapse, l.getCollapseValue());
} else {
assertFalse(l.hasClause(ClawClause.COLLAPSE));
}
if (cleanup) {
assertTrue(l.hasClause(ClawClause.CLEANUP));
assertSame(cleanupValue, l.getCleanupClauseValue());
} else {
assertFalse(l.hasClause(ClawClause.CLEANUP));
}
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method analyzeValidClawLoopFusion.
/**
* Assert the result for valid loop fusion CLAW directive
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param groupName Group name to be found if any.
*/
private void analyzeValidClawLoopFusion(String raw, String groupName, boolean collapse, int n, List<Target> targets, ClawConstraint constraint) {
ClawPragma l = analyze(raw, ClawDirective.LOOP_FUSION);
assertNotNull(l);
if (groupName != null) {
assertTrue(l.hasClause(ClawClause.GROUP));
assertEquals(groupName, l.value(ClawClause.GROUP));
} else {
assertFalse(l.hasClause(ClawClause.GROUP));
assertNull(l.value(ClawClause.GROUP));
}
if (collapse) {
assertTrue(l.hasClause(ClawClause.COLLAPSE));
assertEquals(n, l.getCollapseValue());
} else {
assertFalse(l.hasClause(ClawClause.COLLAPSE));
}
if (constraint != null) {
assertTrue(l.hasClause(ClawClause.CONSTRAINT));
assertEquals(constraint, l.getConstraintClauseValue());
} else {
assertFalse(l.hasClause(ClawClause.CONSTRAINT));
}
assertTargets(l, targets);
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method analyzeValidKcache.
/**
* Assert the result for valid CLAW kcache directive
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param data List of identifiers to be checked.
* @param offsets List of offsets to be checked.
* @param init If true, check that ClawPragma object has init clause enabled.
*/
private void analyzeValidKcache(String raw, List<String> data, List<Integer> offsets, boolean init, boolean hasPrivate, List<Target> targets) {
ClawPragma l = analyze(raw, ClawDirective.KCACHE);
assertNotNull(l);
assertClauseListValues(l, ClawClause.DATA, data);
if (offsets != null) {
assertEquals(offsets.size(), l.getOffsets().size());
for (int i = 0; i < offsets.size(); ++i) {
assertEquals(offsets.get(i), l.getOffsets().get(i));
}
}
if (init) {
assertTrue(l.hasClause(ClawClause.INIT));
} else {
assertFalse(l.hasClause(ClawClause.INIT));
}
if (hasPrivate) {
assertTrue(l.hasClause(ClawClause.PRIVATE));
} else {
assertFalse(l.hasClause(ClawClause.PRIVATE));
}
assertTargets(l, targets);
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method analyzeValidOverSCA.
/**
* Assert the result for valid CLAW sca directive with data over clause.
*
* @param raw Raw string value of the CLAW directive to be analyzed.
* @param datas Reference list for the data clause values.
* @param dimensions Reference list of dimensions.
*/
private void analyzeValidOverSCA(String raw, List<List<String>> datas, List<List<DimensionDefinition>> dimensions) {
ClawPragma l = analyze(raw, ClawDirective.SCA);
assertNotNull(l);
if (datas != null) {
assertEquals(datas.size(), dimensions.size());
assertTrue(l.hasClause(ClawClause.DATA_OVER));
for (int j = 0; j < datas.size(); ++j) {
List<String> data = datas.get(j);
List<DimensionDefinition> dimension = dimensions.get(j);
for (String id : data) {
assertNotNull(l.getLayoutForData(cfg, id));
List<DimensionDefinition> dims = l.getLayoutForData(cfg, id);
assertEquals(dimension.size(), dims.size());
for (int i = 0; i < dimension.size(); ++i) {
assertEquals(dimension.get(i).getIdentifier(), dims.get(i).getIdentifier());
assertEquals(dimension.get(i).getInsertionPosition(), dims.get(i).getInsertionPosition());
assertEquals(dimension.get(i).getLowerBound().isVar(), dims.get(i).getLowerBound().isVar());
assertEquals(dimension.get(i).getLowerBound().getValue(), dims.get(i).getLowerBound().getValue());
assertEquals(dimension.get(i).getLowerBound().getIntValue(), dims.get(i).getLowerBound().getIntValue());
assertEquals(dimension.get(i).getUpperBound().isVar(), dims.get(i).getUpperBound().isVar());
assertEquals(dimension.get(i).getUpperBound().getValue(), dims.get(i).getUpperBound().getValue());
assertEquals(dimension.get(i).getUpperBound().getIntValue(), dims.get(i).getUpperBound().getIntValue());
}
}
}
}
}
use of claw.wani.language.ClawPragma in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest 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) {
ClawPragma l = analyze(raw, ClawDirective.ARRAY_TO_CALL);
assertNotNull(l);
assertEquals(params.size(), l.values(ClawClause.FCT_PARAMETERS).size());
for (int i = 0; i < params.size(); ++i) {
assertEquals(params.get(i), l.values(ClawClause.FCT_PARAMETERS).get(i));
}
assertEquals(arrayName, l.value(ClawClause.ARRAY_NAME));
assertEquals(fctName, l.value(ClawClause.FCT_NAME));
assertTargets(l, targets);
}
Aggregations