Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,9 @@ && getRDDHandle() == null) ) {
_requiresLocalWrite = false;
}
else if( hasStreamHandle() ) {
_data = readBlobFromStream( getStreamHandle() );
OOCStream<IndexedMatrixValue> stream = getStreamHandle();
stream.start();
_data = readBlobFromStream(stream);
}
else if( getRDDHandle()==null || getRDDHandle().allowsShortCircuitRead() ) {
if( DMLScript.STATISTICS )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,10 @@ protected long writeStreamToHDFS(String fname, String ofmt, int rep, FileFormatP
MetaDataFormat iimd = (MetaDataFormat) _metaData;
FileFormat fmt = (ofmt != null ? FileFormat.safeValueOf(ofmt) : iimd.getFileFormat());
MatrixWriter writer = MatrixWriterFactory.createMatrixWriter(fmt, rep, fprop);
return writer.writeMatrixFromStream(fname, getStreamHandle(),
getNumRows(), getNumColumns(), ConfigurationManager.getBlocksize());
OOCStream<IndexedMatrixValue> stream = getStreamHandle();
stream.start();
return writer.writeMatrixFromStream(fname, stream, getNumRows(), getNumColumns(),
ConfigurationManager.getBlocksize());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.sysds.runtime.ooc.cache.GroupedBlockKey;
import org.apache.sysds.runtime.ooc.cache.io.OOCIOHandler;
import org.apache.sysds.runtime.ooc.cache.OOCCacheManager;
import org.apache.sysds.runtime.ooc.primitives.OOCPrimitive;
import org.apache.sysds.runtime.ooc.stream.SourceOOCStream;
import org.apache.sysds.runtime.ooc.util.OOCUtils;
import shaded.parquet.it.unimi.dsi.fastutil.ints.IntArrayList;
Expand Down Expand Up @@ -272,9 +273,10 @@ else if(tmp instanceof OOCCacheManager.CachedSubCallback<?> cachedSub) {
}
}
}
} catch (DMLRuntimeException e) {
}
catch(RuntimeException e) {
// Propagate failure to subscribers
_failure = e;
_failure = DMLRuntimeException.of(e);
synchronized (this) {
notifyAll();
}
Expand Down Expand Up @@ -595,6 +597,11 @@ public CachingStream getStreamCache() {
return this;
}

@Override
public OOCPrimitive getPrimitive() {
return _source.getPrimitive();
}

@Override
public boolean isProcessed() {
return false;
Expand All @@ -617,7 +624,7 @@ public void setData(CacheableData<?> data) {

@SuppressWarnings("unchecked")
public void setSubscriber(Consumer<OOCStream.QueueCallback<IndexedMatrixValue>> subscriber, boolean incrConsumers) {
if(_deletable)
if(_deletable && incrConsumers)
throw new DMLRuntimeException("Cannot register a new subscriber on " + this + " because has been flagged for deletion");
if(_failure != null)
throw _failure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public void processInstruction( ExecutionContext ec ) {
} else
cst3 = ec.getScalarInput(input3).getDoubleValue();

qIn1.start();
if(qIn2 != null)
qIn2.start();
if(qIn3 != null)
qIn3.start();

HashMap<Long, MatrixBlock> blocksIn2 = new HashMap<>(), blocksIn3 = new HashMap<>();
MatrixBlock block2, block3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,40 +192,32 @@ public void processInstruction(ExecutionContext ec) {
long lcols = ec.getScalarInput(cols).getLongValue();
checkValidDimensions(lrows, lcols);

OOCStream<MatrixIndexes> qIn = createWritableStream();
int nrb = (int)((lrows-1) / blen)+1;
int ncb = (int)((lcols-1) / blen)+1;

for (int row = 0; row < nrb; row++)
for (int col = 0; col < ncb; col++)
qIn.enqueue(new MatrixIndexes(row+1, col+1));

qIn.closeInput();

if(sparsity == 0.0 && lrows < Integer.MAX_VALUE && lcols < Integer.MAX_VALUE) {
mapOOC(qIn, qOut, idx -> {
long rlen = Math.min(blen, lrows - (idx.getRowIndex()-1) * blen);
long clen = Math.min(blen, lcols - (idx.getColumnIndex()-1) * blen);
return new IndexedMatrixValue(idx, new MatrixBlock((int)rlen, (int)clen, 0.0));
});
OOCInstructionUtils.dataGen(qOut, idx -> {
long rlen = Math.min(blen, lrows - (idx.getRowIndex() - 1) * blen);
long clen = Math.min(blen, lcols - (idx.getColumnIndex() - 1) * blen);
return new MatrixBlock((int) rlen, (int) clen, 0.0);
}, getContext());
return;
}

if(sparsity == 1.0 && minValue == maxValue) {
mapOOC(qIn, qOut, idx -> {
long rlen = Math.min(blen, lrows - (idx.getRowIndex()-1) * blen);
long clen = Math.min(blen, lcols - (idx.getColumnIndex()-1) * blen);
return new IndexedMatrixValue(idx, new MatrixBlock((int)rlen, (int)clen, minValue));
});
OOCInstructionUtils.dataGen(qOut, idx -> {
long rlen = Math.min(blen, lrows - (idx.getRowIndex() - 1) * blen);
long clen = Math.min(blen, lcols - (idx.getColumnIndex() - 1) * blen);
return new MatrixBlock((int) rlen, (int) clen, minValue);
}, getContext());
return;
}

Well1024a bigrand = LibMatrixDatagen.setupSeedsForRand(lSeed);
int nrb = (int) ((lrows - 1) / blen) + 1;
int ncb = (int) ((lcols - 1) / blen) + 1;
int nb = nrb * ncb;
long[] seeds = new long[nb];
for(int i = 0; i < nb; i++) seeds[i] = bigrand.nextLong();

mapOOC(qIn, qOut, idx -> {
OOCInstructionUtils.dataGen(qOut, idx -> {
long rlen = Math.min(blen, lrows - (idx.getRowIndex()-1) * blen);
long clen = Math.min(blen, lcols - (idx.getColumnIndex()-1) * blen);

Expand All @@ -242,8 +234,8 @@ public void processInstruction(ExecutionContext ec) {

LibMatrixDatagen.genRandomNumbers(false, 0, 1, 0, 1, mout, getGenerator(rlen, clen), bSeed, null);
mout.recomputeNonZeros();
return new IndexedMatrixValue(idx, mout);
});
return mout;
}, getContext());
}
else if(method == Types.OpOpDG.SEQ) {
double lfrom = ec.getScalarInput(seq_from).getDoubleValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void processInstruction(ExecutionContext ec) {
Double scalarOut = null;
IndexedMatrixValue tmp;

qIn.start();
while((tmp = qIn.dequeue()) != LocalTaskQueue.NO_MORE_TASKS) {
if(tmp.getIndexes().getRowIndex() == firstBlockRow + 1 &&
tmp.getIndexes().getColumnIndex() == firstBlockCol + 1) {
Expand Down Expand Up @@ -301,6 +302,7 @@ public void processInstruction(ExecutionContext ec) {
qOut.propagateFailure(DMLRuntimeException.of(err));
return null;
});
qIn.start();

if(hasIntermediateStream)
cachedStream.scheduleDeletion(); // We can immediately delete blocks after consumption
Expand Down Expand Up @@ -356,6 +358,7 @@ else if(opcode.equalsIgnoreCase(Opcodes.LEFT_INDEX.toString())) {
qOutRaw.closeInput();
return null;
});
qLhs.start();
return;
}

Expand Down Expand Up @@ -452,6 +455,8 @@ else if(opcode.equalsIgnoreCase(Opcodes.LEFT_INDEX.toString())) {
qOutRaw.closeInput();
return null;
});
qLhs.start();
qRhs.start();
}
else
throw new DMLRuntimeException(
Expand Down
Loading
Loading