Skip to content
Closed
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 @@ -27,6 +27,7 @@
import org.apache.sysds.runtime.instructions.ooc.BinaryOOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.CentralMomentOOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.CtableOOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.IndexingOOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.OOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.ReblockOOCInstruction;
import org.apache.sysds.runtime.instructions.ooc.TSMMOOCInstruction;
Expand Down Expand Up @@ -75,6 +76,8 @@ public static OOCInstruction parseSingleInstruction(InstructionType ooctype, Str
return CentralMomentOOCInstruction.parseInstruction(str);
case Ctable:
return CtableOOCInstruction.parseInstruction(str);
case MatrixIndexing:
return IndexingOOCInstruction.parseInstruction(str);

default:
throw new DMLRuntimeException("Invalid OOC Instruction Type: " + ooctype);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,37 @@ public CachingStream(OOCStream<IndexedMatrixValue> source, long streamId) {
});
}

private boolean fetchFromStream() throws InterruptedException {
synchronized (this) {
if(!_cacheInProgress)
throw new DMLRuntimeException("Stream is closed");
}
private synchronized boolean fetchFromStream() throws InterruptedException {
if(!_cacheInProgress)
throw new DMLRuntimeException("Stream is closed");

IndexedMatrixValue task = _source.dequeue();

synchronized (this) {
if(task != LocalTaskQueue.NO_MORE_TASKS) {
OOCEvictionManager.put(_streamId, _numBlocks, task);
if (_index != null)
_index.put(task.getIndexes(), _numBlocks);
_numBlocks++;
notifyAll();
return false;
}
else {
_cacheInProgress = false; // caching is complete
notifyAll();
return true;
}
if(task != LocalTaskQueue.NO_MORE_TASKS) {
OOCEvictionManager.put(_streamId, _numBlocks, task);
if (_index != null)
_index.put(task.getIndexes(), _numBlocks);
_numBlocks++;
notifyAll();
return false;
}
else {
_cacheInProgress = false; // caching is complete
notifyAll();
return true;
}
}

public synchronized IndexedMatrixValue get(int idx) throws InterruptedException {
while (true) {
if (idx < _numBlocks)
return OOCEvictionManager.get(_streamId, idx);
else if (!_cacheInProgress)
if (idx < _numBlocks) {
IndexedMatrixValue out = OOCEvictionManager.get(_streamId, idx);

if (_index != null) // Ensure index is up to date
_index.putIfAbsent(out.getIndexes(), idx);

return out;
} else if (!_cacheInProgress)
return (IndexedMatrixValue)LocalTaskQueue.NO_MORE_TASKS;

wait();
Expand Down
Loading
Loading