Search in sources :

Example 6 with GPUObject

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);
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) GPUContext(org.apache.sysml.runtime.instructions.gpu.context.GPUContext) GPUObject(org.apache.sysml.runtime.instructions.gpu.context.GPUObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) Pair(org.apache.sysml.runtime.matrix.data.Pair)

Example 7 with GPUObject

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();
}
Also used : GPUObject(org.apache.sysml.runtime.instructions.gpu.context.GPUObject)

Aggregations

GPUObject (org.apache.sysml.runtime.instructions.gpu.context.GPUObject)7 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)4 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)4 GPUContext (org.apache.sysml.runtime.instructions.gpu.context.GPUContext)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Pointer (jcuda.Pointer)2 MutableBoolean (org.apache.commons.lang.mutable.MutableBoolean)2 CSRPointer (org.apache.sysml.runtime.instructions.gpu.context.CSRPointer)2 Pair (org.apache.sysml.runtime.matrix.data.Pair)1