Search in sources :

Example 1 with TRequest

use of edu.iu.dsc.tws.comms.table.channel.TRequest in project twister2 by DSC-SPIDAL.

the class SimpleAllToAll method insert.

public boolean insert(ByteBuffer buf, int length, int[] header, int headerLength, int target) {
    if (finishFlag) {
        throw new Twister2RuntimeException("Cannot insert after finishing");
    }
    if (headerLength > MPIChannel.TWISTERX_CHANNEL_USER_HEADER) {
        throw new Twister2RuntimeException("Cannot have a header length greater than " + MPIChannel.TWISTERX_CHANNEL_USER_HEADER);
    }
    AllToAllSends s = sends.get(target);
    TRequest request = new TRequest(target, buf, length, header, headerLength);
    s.requestQueue.offer(request);
    return true;
}
Also used : TRequest(edu.iu.dsc.tws.comms.table.channel.TRequest) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

Example 2 with TRequest

use of edu.iu.dsc.tws.comms.table.channel.TRequest in project twister2 by DSC-SPIDAL.

the class SimpleAllToAll method isComplete.

public boolean isComplete() {
    boolean allQueuesEmpty = true;
    for (AllToAllSends s : sends.values()) {
        while (!s.requestQueue.isEmpty()) {
            if (s.sendStatus == AllToAllSendStatus.FINISH_SENT || s.sendStatus == AllToAllSendStatus.FINISHED) {
                String msg = "We cannot have items to send after finish sent";
                LOG.log(Level.SEVERE, msg);
                throw new Twister2RuntimeException(msg);
            }
            TRequest request = s.requestQueue.peek();
            if (1 == channel.send(request)) {
                s.requestQueue.poll();
                s.pendingQueue.offer(request);
            }
        }
        if (s.pendingQueue.isEmpty()) {
            if (finishFlag) {
                if (s.sendStatus == AllToAllSendStatus.SENDING) {
                    TRequest request = new TRequest(s.target);
                    if (1 == channel.sendFin(request)) {
                        s.sendStatus = AllToAllSendStatus.FINISH_SENT;
                    }
                }
            }
        } else {
            allQueuesEmpty = false;
        }
    }
    channel.progressReceives();
    channel.progressSends();
    return allQueuesEmpty && finishedTargets.size() == targets.size() && finishedSources.size() == sources.size();
}
Also used : TRequest(edu.iu.dsc.tws.comms.table.channel.TRequest) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)

Aggregations

Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)2 TRequest (edu.iu.dsc.tws.comms.table.channel.TRequest)2