use of edu.rit.util.Range in project ffx by mjschnie.
the class Unsigned16BitIntegerBuf method colSliceBuffer.
/**
* Create a buffer for one column slice of the given integer matrix. The
* returned buffer encompasses all the rows, and <TT>theColRange</TT> of
* columns, in <TT>theMatrix</TT>. The range's stride may be 1 or greater
* than 1.
*
* @param theMatrix Matrix.
* @param theColRange Range of columns to include.
* @return Buffer.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null or
* <TT>theColRange</TT> is null.
* @exception IndexOutOfBoundsException (unchecked exception) Thrown if
* <TT>theMatrix</TT>'s allocation does not include <TT>theColRange</TT>.
*/
public static Unsigned16BitIntegerBuf colSliceBuffer(int[][] theMatrix, Range theColRange) {
if (theMatrix == null) {
throw new NullPointerException("Unsigned16BitIntegerBuf.colSliceBuffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
int nc = Arrays.colLength(theMatrix, 0);
if (0 > theColRange.lb() || theColRange.ub() >= nc) {
throw new IndexOutOfBoundsException("Unsigned16BitIntegerBuf.colSliceBuffer(): theMatrix column index range = 0.." + (nc - 1) + ", theColRange = " + theColRange);
}
if (theColRange.stride() == 1) {
return new Unsigned16BitIntegerMatrixBuf_1(theMatrix, new Range(0, nr - 1), theColRange);
} else {
return new Unsigned16BitIntegerMatrixBuf(theMatrix, new Range(0, nr - 1), theColRange);
}
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class Unsigned16BitIntegerBuf method buffer.
/**
* Create a buffer for the entire given integer matrix. The returned buffer
* encompasses all the rows and all the columns in
* <TT>theMatrix</TT>.
*
* @param theMatrix Matrix.
* @return Buffer.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null.
*/
public static Unsigned16BitIntegerBuf buffer(int[][] theMatrix) {
if (theMatrix == null) {
throw new NullPointerException("Unsigned16BitIntegerBuf.buffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
int nc = Arrays.colLength(theMatrix, 0);
return new Unsigned16BitIntegerMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1));
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class Unsigned16BitIntegerBuf method rowSliceBuffer.
/**
* Create a buffer for one row slice of the given integer matrix. The
* returned buffer encompasses <TT>theRowRange</TT> of rows, and all the
* columns, in <TT>theMatrix</TT>. The range's stride may be 1 or greater
* than 1.
*
* @param theMatrix Matrix.
* @param theRowRange Range of rows to include.
* @return Buffer.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null or
* <TT>theRowRange</TT> is null.
* @exception IndexOutOfBoundsException (unchecked exception) Thrown if
* <TT>theMatrix</TT>'s allocation does not include <TT>theRowRange</TT>.
*/
public static Unsigned16BitIntegerBuf rowSliceBuffer(int[][] theMatrix, Range theRowRange) {
if (theMatrix == null) {
throw new NullPointerException("Unsigned16BitIntegerBuf.rowSliceBuffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
if (0 > theRowRange.lb() || theRowRange.ub() >= nr) {
throw new IndexOutOfBoundsException("Unsigned16BitIntegerBuf.rowSliceBuffer(): theMatrix row index range = 0.." + (nr - 1) + ", theRowRange = " + theRowRange);
}
int nc = Arrays.colLength(theMatrix, theRowRange.lb());
if (theRowRange.stride() == 1) {
return new Unsigned16BitIntegerMatrixBuf_1(theMatrix, theRowRange, new Range(0, nc - 1));
} else {
return new Unsigned16BitIntegerMatrixBuf(theMatrix, theRowRange, new Range(0, nc - 1));
}
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class WorkerIntegerForLoop method masterExecuteNonFixed.
/**
* Execute this worker for loop in the master thread with a non-fixed
* schedule.
*
* @param range Loop index range.
* @param sch Schedule.
*
* @exception IOException Thrown if an I/O error occurred.
*/
void masterExecuteNonFixed(Range range, IntegerSchedule sch) throws IOException {
int count = myTeam.count;
sch.start(count, range);
int remaining = count;
ObjectItemBuf<Range> buf = ObjectBuf.buffer();
Range tagRange = new Range(tagFor(0), tagFor(count - 1));
Comm comm = myTeam.comm;
// Send initial task to each worker.
for (int w = 0; w < count; ++w) {
Range chunk = sch.next(w);
buf.item = chunk;
buf.reset();
int r = myTeam.workerRank(w);
int tag = tagFor(w);
comm.send(r, tag, buf);
if (chunk == null) {
--remaining;
} else {
sendTaskInput(chunk, comm, r, tag);
}
}
// that worker.
while (remaining > 0) {
CommStatus status = comm.receive(null, tagRange, buf);
Range chunk = buf.item;
int r = status.fromRank;
int tag = status.tag;
int w = workerFor(tag);
receiveTaskOutput(chunk, comm, r, tag);
chunk = sch.next(w);
buf.item = chunk;
buf.reset();
comm.send(r, tag, buf);
if (chunk == null) {
--remaining;
} else {
sendTaskInput(chunk, comm, r, tag);
}
}
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class WorkerIntegerForLoop method masterExecuteFixed.
/**
* Execute this worker for loop in the master thread with a fixed schedule.
*
* @param range Loop index range.
* @param sch Schedule.
*
* @exception IOException Thrown if an I/O error occurred.
*/
void masterExecuteFixed(Range range, IntegerSchedule sch) throws IOException {
int count = myTeam.count;
Comm comm = myTeam.comm;
// Send additional task input to each worker.
sch.start(count, range);
for (int w = 0; w < count; ++w) {
Range chunk = sch.next(w);
if (chunk != null) {
sendTaskInput(chunk, comm, myTeam.workerRank(w), tagFor(w));
}
}
// Receive additional task output from each worker.
sch.start(count, range);
for (int w = 0; w < count; ++w) {
Range chunk = sch.next(w);
if (chunk != null) {
receiveTaskOutput(chunk, comm, myTeam.workerRank(w), tagFor(w));
}
}
}
Aggregations