use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.
the class SKeyedReduceExample method verify.
public void verify() throws VerificationException {
boolean doVerify = jobParameters.isDoVerify();
boolean isVerified = false;
if (doVerify) {
LOG.info("Verifying results ...");
ExperimentVerification experimentVerification = new ExperimentVerification(experimentData, OperationNames.KEYED_REDUCE);
isVerified = experimentVerification.isVerified();
if (isVerified) {
LOG.info("Results generated from the experiment are verified.");
} else {
throw new VerificationException("Results do not match");
}
}
}
use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.
the class TSetAllGatherExample method execute.
@Override
public void execute(WorkerEnvironment workerEnv) {
super.execute(workerEnv);
BatchEnvironment env = TSetEnvironment.initBatch(workerEnv);
// set the parallelism of source to task stage 0
List<Integer> taskStages = jobParameters.getTaskStages();
int sourceParallelism = taskStages.get(0);
int sinkParallelism = taskStages.get(1);
SourceTSet<int[]> source = env.createSource(new TestBaseSource(), sourceParallelism).setName("Source");
AllGatherTLink<int[]> gather = source.allGather();
SinkTSet<Iterator<Tuple<Integer, int[]>>> sink = gather.sink(new SinkFunc<Iterator<Tuple<Integer, int[]>>>() {
private TSetContext context;
@Override
public boolean add(Iterator<Tuple<Integer, int[]>> value) {
// todo: check this!
int[] result = new int[0];
while (value.hasNext()) {
Tuple<Integer, int[]> t = value.next();
if (t.getKey().equals(context.getIndex())) {
result = t.getValue();
break;
}
}
LOG.info("Task Id : " + context.getIndex() + " Results " + Arrays.toString(result));
experimentData.setOutput(value);
try {
verify(OperationNames.ALLGATHER);
} catch (VerificationException e) {
LOG.info("Exception Message : " + e.getMessage());
}
return true;
}
@Override
public void prepare(TSetContext ctx) {
this.context = ctx;
}
});
env.run(sink);
}
use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.
the class TSetGatherExample method execute.
@Override
public void execute(WorkerEnvironment workerEnv) {
super.execute(workerEnv);
BatchEnvironment env = TSetEnvironment.initBatch(workerEnv);
// set the parallelism of source to task stage 0
int srcPara = jobParameters.getTaskStages().get(0);
int sinkPara = jobParameters.getTaskStages().get(1);
SourceTSet<int[]> source = env.createSource(new TestBaseSource(), srcPara).setName("Source");
GatherTLink<int[]> gather = source.gather();
SinkTSet<Iterator<Tuple<Integer, int[]>>> sink = gather.sink((SinkFunc<Iterator<Tuple<Integer, int[]>>>) val -> {
int[] value = null;
while (val.hasNext()) {
value = val.next().getValue();
}
experimentData.setOutput(value);
LOG.info("Results " + Arrays.toString(value));
try {
verify(OperationNames.GATHER);
} catch (VerificationException e) {
LOG.info("Exception Message : " + e.getMessage());
}
return true;
});
env.run(sink);
}
use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.
the class BaseTSetBatchWorker method verify.
public static void verify(String operationNames) throws VerificationException {
boolean doVerify = jobParameters.isDoVerify();
boolean isVerified = false;
if (doVerify) {
LOG.info("Verifying results ...");
ExperimentVerification experimentVerification = new ExperimentVerification(experimentData, operationNames);
isVerified = experimentVerification.isVerified();
if (isVerified) {
LOG.info("Results generated from the experiment are verified.");
} else {
throw new VerificationException("Results do not match");
}
}
}
use of edu.iu.dsc.tws.examples.verification.VerificationException in project twister2 by DSC-SPIDAL.
the class TSetAllReduceExample method execute.
@Override
public void execute(WorkerEnvironment workerEnv) {
super.execute(workerEnv);
BatchEnvironment env = TSetEnvironment.initBatch(workerEnv);
// set the parallelism of source to task stage 0
int srcPara = jobParameters.getTaskStages().get(0);
int sinkPara = jobParameters.getTaskStages().get(1);
SourceTSet<int[]> source = env.createSource(new TestBaseSource(), srcPara).setName("Source");
AllReduceTLink<int[]> reduce = source.allReduce((t1, t2) -> {
int[] val = new int[t1.length];
for (int i = 0; i < t1.length; i++) {
val[i] = t1[i] + t2[i];
}
return val;
});
SinkTSet<int[]> sink = reduce.sink(value -> {
experimentData.setOutput(value);
try {
LOG.info("Results " + Arrays.toString(value));
verify(OperationNames.ALLREDUCE);
} catch (VerificationException e) {
LOG.info("Exception Message : " + e.getMessage());
}
return true;
});
env.run(sink);
}
Aggregations