use of claw.tatsu.directive.configuration.OpenAccConfiguration in project claw-compiler by C2SM-RCM.
the class ConfigurationTest method readConfig.
void readConfig(Path cfgDirPath) {
try {
Configuration conf = new TestConfiguration();
assertNotNull(conf);
Context context = new TestContext();
assertNotNull(context);
conf = Configuration.load(cfgDirPath, null, null, null, null, Integer.valueOf(MAX_COLUMN), context, Collections.emptyList());
assertNotNull(context.getGenerator());
assertNotNull(conf.accelerator());
assertEquals(MAX_COLUMN, context.getMaxColumns());
assertFalse(conf.isForcePure());
conf.setForcePure();
assertTrue(conf.isForcePure());
int[] majorMinor = conf.getMajorMinor("0.3");
assertEquals(0, majorMinor[0]);
assertEquals(3, majorMinor[1]);
try {
conf.checkVersion("0.2");
fail();
} catch (Exception ignored) {
}
try {
conf.getMajorMinor("sdjhsajkd");
fail();
} catch (Exception ignored) {
}
try {
conf.checkVersion(ClawVersion.VERSION);
} catch (Exception ignored) {
fail();
}
assertTrue(conf.accelerator() instanceof OpenAccConfiguration);
assertTrue(context.getGenerator() instanceof OpenAcc);
assertSame(Target.GPU, conf.getCurrentTarget());
assertSame(CompilerDirective.OPENACC, conf.getCurrentDirective());
assertEquals(Configuration.CPU_STRATEGY_FUSION, conf.getParameter(Configuration.CPU_STRATEGY));
conf.overrideConfigurationParameter(Configuration.CPU_STRATEGY, Configuration.CPU_STRATEGY_SINGLE);
assertEquals(Configuration.CPU_STRATEGY_SINGLE, conf.getParameter(Configuration.CPU_STRATEGY));
assertNull(conf.getParameter(DUMMY_KEY));
conf.overrideConfigurationParameter(DUMMY_KEY, DUMMY_VALUE);
assertEquals(DUMMY_VALUE, conf.getParameter(DUMMY_KEY));
} catch (Exception e) {
fail();
}
}
use of claw.tatsu.directive.configuration.OpenAccConfiguration in project claw-compiler by C2SM-RCM.
the class Configuration method init.
/**
* Constructs basic configuration object.
*
* @param directive Accelerator directive language.
* @param target Target architecture.
*/
public void init(CompilerDirective directive, Target target) {
_parameters = new HashMap<>();
if (directive == null) {
directive = CompilerDirective.NONE;
}
_parameters.put(DEFAULT_DIRECTIVE, directive.toString());
if (target != null) {
_parameters.put(DEFAULT_TARGET, target.toString());
}
// Init specific configuration if needed
switch(directive) {
case OPENACC:
_accelerator = new OpenAccConfiguration(_parameters);
break;
case OPENMP:
_accelerator = new OpenMpConfiguration(_parameters);
break;
default:
_accelerator = new AcceleratorConfiguration(_parameters);
break;
}
_groups = new ArrayList<>();
_availableGroups = new HashMap<>();
}
Aggregations