use of org.apache.sysml.runtime.instructions.gpu.context.GPUObject in project incubator-systemml by apache.
the class ExecutionContext method getMatrixInputForGPUInstruction.
public Pair<MatrixObject, Boolean> getMatrixInputForGPUInstruction(String varName) throws DMLRuntimeException {
GPUContext gCtx = getGPUContext();
boolean copied = false;
MatrixObject mo = getMatrixObject(varName);
if (mo == null) {
throw new DMLRuntimeException("No matrix object available for variable:" + varName);
}
boolean acquired = false;
if (mo.getGPUObject(gCtx) == null) {
GPUObject newGObj = gCtx.createGPUObject(mo);
mo.setGPUObject(gCtx, newGObj);
} else if (!mo.getGPUObject(gCtx).isInputAllocated()) {
mo.acquireRead();
acquired = true;
}
copied = mo.getGPUObject(gCtx).acquireDeviceRead();
if (acquired) {
mo.release();
}
return new Pair<MatrixObject, Boolean>(mo, copied);
}
use of org.apache.sysml.runtime.instructions.gpu.context.GPUObject in project incubator-systemml by apache.
the class CacheableData method clearData.
/**
* Sets the cache block reference to <code>null</code>, abandons the old block.
* Makes the "envelope" empty. Run it to finalize the object (otherwise the
* evicted cache block file may remain undeleted).
*
* In-Status: EMPTY, EVICTABLE, EVICTED;
* Out-Status: EMPTY.
*
* @throws DMLRuntimeException if error occurs
*/
public synchronized void clearData() throws DMLRuntimeException {
if (LOG.isTraceEnabled())
LOG.trace("Clear data " + getVarName());
// check if cleanup enabled and possible
if (!isCleanupEnabled())
// do nothing
return;
if (!isAvailableToModify())
throw new CacheException("CacheableData (" + getDebugName() + ") not available to " + "modify. Status = " + getStatusAsString() + ".");
// clear existing WB / FS representation (but prevent unnecessary probes)
if (!(isEmpty(true) || (_data != null && isBelowCachingThreshold()) || //additional condition for JMLC
(_data != null && !isCachingActive())))
freeEvictedBlob();
// clear the in-memory data
clearReusableData();
_data = null;
clearCache();
// clear rdd/broadcast back refs
if (_rddHandle != null)
_rddHandle.setBackReference(null);
if (_bcHandle != null)
_bcHandle.setBackReference(null);
if (_gpuObjects != null) {
for (GPUObject gObj : _gpuObjects.values()) {
if (gObj != null) {
gObj.clearData();
}
}
}
// change object state EMPTY
setDirty(false);
setEmpty();
}
Aggregations