Search in sources :

Example 1 with VerificationException

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");
        }
    }
}
Also used : ExperimentVerification(edu.iu.dsc.tws.examples.verification.ExperimentVerification) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException)

Example 2 with VerificationException

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);
}
Also used : BatchEnvironment(edu.iu.dsc.tws.tset.env.BatchEnvironment) TSetContext(edu.iu.dsc.tws.api.tset.TSetContext) Iterator(java.util.Iterator) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple)

Example 3 with VerificationException

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);
}
Also used : Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) Arrays(java.util.Arrays) Iterator(java.util.Iterator) SourceTSet(edu.iu.dsc.tws.tset.sets.batch.SourceTSet) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException) GatherTLink(edu.iu.dsc.tws.tset.links.batch.GatherTLink) BatchEnvironment(edu.iu.dsc.tws.tset.env.BatchEnvironment) SinkTSet(edu.iu.dsc.tws.tset.sets.batch.SinkTSet) OperationNames(edu.iu.dsc.tws.api.compute.OperationNames) BaseTSetBatchWorker(edu.iu.dsc.tws.examples.tset.BaseTSetBatchWorker) Logger(java.util.logging.Logger) SinkFunc(edu.iu.dsc.tws.api.tset.fn.SinkFunc) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) TSetEnvironment(edu.iu.dsc.tws.tset.env.TSetEnvironment) BatchEnvironment(edu.iu.dsc.tws.tset.env.BatchEnvironment) Iterator(java.util.Iterator) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException)

Example 4 with VerificationException

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");
        }
    }
}
Also used : ExperimentVerification(edu.iu.dsc.tws.examples.verification.ExperimentVerification) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException)

Example 5 with VerificationException

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);
}
Also used : BatchEnvironment(edu.iu.dsc.tws.tset.env.BatchEnvironment) VerificationException(edu.iu.dsc.tws.examples.verification.VerificationException)

Aggregations

VerificationException (edu.iu.dsc.tws.examples.verification.VerificationException)6 BatchEnvironment (edu.iu.dsc.tws.tset.env.BatchEnvironment)4 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)2 ExperimentVerification (edu.iu.dsc.tws.examples.verification.ExperimentVerification)2 Iterator (java.util.Iterator)2 OperationNames (edu.iu.dsc.tws.api.compute.OperationNames)1 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)1 TSetContext (edu.iu.dsc.tws.api.tset.TSetContext)1 SinkFunc (edu.iu.dsc.tws.api.tset.fn.SinkFunc)1 BaseTSetBatchWorker (edu.iu.dsc.tws.examples.tset.BaseTSetBatchWorker)1 TSetEnvironment (edu.iu.dsc.tws.tset.env.TSetEnvironment)1 GatherTLink (edu.iu.dsc.tws.tset.links.batch.GatherTLink)1 SinkTSet (edu.iu.dsc.tws.tset.sets.batch.SinkTSet)1 SourceTSet (edu.iu.dsc.tws.tset.sets.batch.SourceTSet)1 Arrays (java.util.Arrays)1 Logger (java.util.logging.Logger)1