Package org.apache.sysds.runtime.controlprogram.context

# Class ExecutionContext

java.lang.Object
org.apache.sysds.runtime.controlprogram.context.ExecutionContext

Direct Known Subclasses:
  `SparkExecutionContext`

public class ExecutionContext extends Object

## Constructor Summary

Constructors
Constructor
Description
`ExecutionContext(LocalVariableMap vars)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addTmpParforFunction(String fname)`
`MatrixObject`
`allocateGPUMatrixObject(String varName, long numRows, long numCols)`
Allocates the `GPUObject` for a given LOPS Variable (eg.
`void`
`cleanupCacheableData(CacheableData<?> mo)`
`final void`
`cleanupDataObject(Data dat)`
`boolean`
`containsVariable(String name)`
`boolean`
`containsVariable(CPOperand operand)`
`static CacheableData<?>`
`createCacheableData(CacheBlock<?> cb)`
`static FrameObject`
`createFrameObject(FrameBlock fb)`
`static FrameObject`
`createFrameObject(DataCharacteristics dc)`
`static MatrixObject`
`createMatrixObject(MatrixBlock mb)`
`static MatrixObject`
`createMatrixObject(DataCharacteristics dc)`
`CacheableData<?>`
`getCacheableData(String varname)`
`CacheableData<?>`
`getCacheableData(CPOperand input)`
`DataCharacteristics`
`getDataCharacteristics(String varname)`
`Pair<MatrixObject,Boolean>`
`getDenseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols)`
Allocates a dense matrix on the GPU (for output)
`Pair<MatrixObject,Boolean>`
`getDenseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, boolean initialize)`
`FrameBlock`
`getFrameInput(String varName)`
Pins a frame variable into memory and returns the internal frame block.
`FrameBlock`
`getFrameInput(CPOperand input)`
`List<FrameBlock>`
`getFrameInputs(CPOperand[] inputs)`
`FrameObject`
`getFrameObject(String varname)`
`FrameObject`
`getFrameObject(CPOperand input)`
`GPUContext`
`getGPUContext(int index)`
Get the i-th GPUContext
`List<GPUContext>`
`getGPUContexts()`
Gets the list of GPUContexts
`long`
`getGPUDensePointerAddress(MatrixObject obj)`
`CSRPointer`
`getGPUSparsePointerAddress(MatrixObject obj)`
`Lineage`
`getLineage()`
`LineageItem`
`getLineageItem(String varname)`
`LineageItem`
`getLineageItem(CPOperand input)`
`ListObject`
`getListObject(String name)`
`ListObject`
`getListObject(CPOperand input)`
`MatrixBlock`
`getMatrixInput(String varName)`
Pins a matrix variable into memory and returns the internal matrix block.
`MatrixBlock`
`getMatrixInput(CPOperand input)`
`MatrixObject`
`getMatrixInputForGPUInstruction(String varName, String opcode)`
`List<MatrixBlock>`
`getMatrixInputs(CPOperand[] inputs)`
`List<MatrixBlock>`
`getMatrixInputs(CPOperand[] inputs, boolean includeList)`
`MatrixLineagePair`
`getMatrixLineagePair(String varname)`
`MatrixLineagePair`
`getMatrixLineagePair(CPOperand cpo)`
`MatrixObject`
`getMatrixObject(String varname)`
`MatrixObject`
`getMatrixObject(CPOperand input)`
`MetaData`
`getMetaData(String varname)`
`int`
`getNumGPUContexts()`
Gets the number of GPUContexts
`LineageItem`
`getOrCreateLineageItem(CPOperand input)`
`Program`
`getProgram()`
`ScalarObject`
`getScalarInput(String name, Types.ValueType vt, boolean isLiteral)`
`ScalarObject`
`getScalarInput(CPOperand input)`
`List<ScalarObject>`
`getScalarInputs(CPOperand[] inputs)`
`SEALClient`
`getSealClient()`
`Pair<MatrixObject,Boolean>`
`getSparseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, long nnz)`
Allocates a sparse matrix in CSR format on the GPU.
`Pair<MatrixObject,Boolean>`
`getSparseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, long nnz, boolean initialize)`
`TensorBlock`
`getTensorInput(String varName)`
Pins a matrix variable into memory and returns the internal matrix block.
`TensorObject`
`getTensorObject(String varname)`
`long`
`getTID()`
`Set<String>`
`getTmpParforFunctions()`
`Data`
`getVariable(String name)`
`Data`
`getVariable(CPOperand operand)`
`LocalVariableMap`
`getVariables()`
`ArrayList<String>`
`getVarList()`
NOTE: No order guaranteed, so keep same list for pin and unpin.
`ArrayList<String>`
`getVarListPartitioned()`
NOTE: No order guaranteed, so keep same list for pin and unpin.
`boolean`
`isAutoCreateVars()`
`boolean`
`isFederated(CPOperand input)`
`boolean`
`isFederated(CPOperand input, FTypes.FType type)`
`boolean`
`isFrameObject(String varname)`
`boolean`
`isMatrixObject(String varname)`
`void`
`maintainLineageDebuggerInfo(Instruction inst)`
`Queue<Boolean>`
`pinVariables(List<String> varList)`
Pin a given list of variables i.e., set the "clean up" state in corresponding matrix objects, so that the cached data inside these objects is not cleared and the corresponding HDFS files are not deleted (through rmvar instructions).
`void`
`releaseCacheableData(String varname)`
`void`
`releaseFrameInput(String varName)`
Unpins a currently pinned frame variable.
`void`
`releaseFrameInputs(CPOperand[] inputs)`
`void`
`releaseMatrixInput(String varName)`
Unpins a currently pinned matrix variable and update fine-grained statistics.
`void`
`releaseMatrixInput(String... varNames)`
`void`
`releaseMatrixInputForGPUInstruction(String varName)`
`void`
`releaseMatrixInputs(CPOperand[] inputs)`
`void`
`releaseMatrixInputs(CPOperand[] inputs, boolean includeList)`
`void`
`releaseMatrixOutputForGPUInstruction(String varName)`
`void`
`releaseTensorInput(String varName)`
`void`
`releaseTensorInput(String... varNames)`
`Data`
`removeVariable(String name)`
`void`
`replaceLineageItem(String varname, LineageItem li)`
`void`
`setAutoCreateVars(boolean flag)`
`void`
`setFrameOutput(String varName, FrameBlock outputData)`
`void`
`setGPUContexts(List<GPUContext> gpuContexts)`
Sets the list of GPUContexts
`void`
`setLineage(Lineage lineage)`
`void`
`setMatrixOutput(String varName, Future<MatrixBlock> fmb)`
`void`
`setMatrixOutput(String varName, MatrixBlock outputData)`
`void`
`setMatrixOutput(String varName, MatrixBlock outputData, MatrixObject.UpdateType flag)`
`void`
`setMatrixOutputAndLineage(String varName, Future<MatrixBlock> fmb, LineageItem li)`
`void`
`setMatrixOutputAndLineage(String varName, MatrixBlock outputData, LineageItem li)`
`void`
`setMatrixOutputAndLineage(CPOperand var, MatrixBlock outputData, LineageItem li)`
`void`
`setMetaData(String varName, long nrows, long ncols)`
`void`
`setMetaData(String fname, MetaData md)`
`void`
`setProgram(Program prog)`
`void`
`setScalarOutput(String varName, ScalarObject so)`
`void`
`setSealClient(SEALClient seal_client)`
`void`
`setTensorOutput(String varName, TensorBlock outputData)`
`void`
`setTID(long tid)`
`void`
`setVariable(String name, Data val)`
`void`
`setVariables(LocalVariableMap vars)`
`String`
`toString()`
`void`
`traceLineage(Instruction inst)`
`void`
`unpinVariables(List<String> varList, Queue<Boolean> varsState)`
Unpin the a given list of variables by setting their "cleanup" status to the values specified by `varsStats`.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### ExecutionContext

public ExecutionContext(LocalVariableMap vars)

## Method Details

### getProgram

public Program getProgram()

### setProgram

public void setProgram(Program prog)

### getVariables

public LocalVariableMap getVariables()

### setVariables

public void setVariables(LocalVariableMap vars)

### getLineage

public Lineage getLineage()

### setLineage

public void setLineage(Lineage lineage)

### isAutoCreateVars

public boolean isAutoCreateVars()

### setAutoCreateVars

public void setAutoCreateVars(boolean flag)

### setTID

public void setTID(long tid)

### getTID

public long getTID()

### setSealClient

public void setSealClient(SEALClient seal_client)

### getSealClient

public SEALClient getSealClient()

### getGPUContext

public GPUContext getGPUContext(int index)
Get the i-th GPUContext

Parameters:
  `index` - index of the GPUContext
Returns:
  a valid GPUContext or null if the indexed GPUContext does not exist.

### setGPUContexts

public void setGPUContexts(List<GPUContext> gpuContexts)
Sets the list of GPUContexts

Parameters:
  `gpuContexts` - a collection of GPUContexts

### getGPUContexts

public List<GPUContext> getGPUContexts()
Gets the list of GPUContexts

Returns:
  a list of GPUContexts

### getNumGPUContexts

public int getNumGPUContexts()
Gets the number of GPUContexts

Returns:
  number of GPUContexts

### getVariable

public Data getVariable(String name)

### getVariable

public Data getVariable(CPOperand operand)

### setVariable

public void setVariable(String name, Data val)

### containsVariable

public boolean containsVariable(CPOperand operand)

### containsVariable

public boolean containsVariable(String name)

### removeVariable

public Data removeVariable(String name)

### setMetaData

public void setMetaData(String fname, MetaData md)

### getMetaData

public MetaData getMetaData(String varname)

### isMatrixObject

public boolean isMatrixObject(String varname)

### getMatrixObject

public MatrixObject getMatrixObject(CPOperand input)

### getMatrixObject

public MatrixObject getMatrixObject(String varname)

### getMatrixLineagePair

public MatrixLineagePair getMatrixLineagePair(CPOperand cpo)

### getMatrixLineagePair

public MatrixLineagePair getMatrixLineagePair(String varname)

### getTensorObject

public TensorObject getTensorObject(String varname)

### isFrameObject

public boolean isFrameObject(String varname)

### getFrameObject

public FrameObject getFrameObject(CPOperand input)

### getFrameObject

public FrameObject getFrameObject(String varname)

### getCacheableData

public CacheableData<?> getCacheableData(CPOperand input)

### getCacheableData

public CacheableData<?> getCacheableData(String varname)

### releaseCacheableData

public void releaseCacheableData(String varname)

### getDataCharacteristics

public DataCharacteristics getDataCharacteristics(String varname)

### getMatrixInput

public MatrixBlock getMatrixInput(String varName)
Pins a matrix variable into memory and returns the internal matrix block.

Parameters:
  `varName` - variable name
Returns:
  matrix block

### getMatrixInput

public MatrixBlock getMatrixInput(CPOperand input)

### getTensorInput

public TensorBlock getTensorInput(String varName)
Pins a matrix variable into memory and returns the internal matrix block.

Parameters:
  `varName` - variable name
Returns:
  matrix block

### setMetaData

public void setMetaData(String varName, long nrows, long ncols)

### getDenseMatrixOutputForGPUInstruction

public Pair<MatrixObject,Boolean> getDenseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols)
Allocates a dense matrix on the GPU (for output)

Parameters:
  `varName` - name of the output matrix (known by this `ExecutionContext`)
  `numRows` - number of rows of matrix object
  `numCols` - number of columns of matrix object
Returns:
  a pair containing the wrapping `MatrixObject` and a boolean indicating whether a cuda memory allocation took place (as opposed to the space already being allocated)

### getDenseMatrixOutputForGPUInstruction

public Pair<MatrixObject,Boolean> getDenseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, boolean initialize)

### getSparseMatrixOutputForGPUInstruction

public Pair<MatrixObject,Boolean> getSparseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, long nnz)
Allocates a sparse matrix in CSR format on the GPU. Assumes that mat.getNumRows() returns a valid number

Parameters:
  `varName` - variable name
  `numRows` - number of rows of matrix object
  `numCols` - number of columns of matrix object
  `nnz` - number of non zeroes
Returns:
  matrix object

### getSparseMatrixOutputForGPUInstruction

public Pair<MatrixObject,Boolean> getSparseMatrixOutputForGPUInstruction(String varName, long numRows, long numCols, long nnz, boolean initialize)

### allocateGPUMatrixObject

public MatrixObject allocateGPUMatrixObject(String varName, long numRows, long numCols)
Allocates the `GPUObject` for a given LOPS Variable (eg. _mVar3)

Parameters:
  `varName` - variable name
  `numRows` - number of rows of matrix object
  `numCols` - number of columns of matrix object
Returns:
  matrix object

### getGPUDensePointerAddress

public long getGPUDensePointerAddress(MatrixObject obj)

### getGPUSparsePointerAddress

public CSRPointer getGPUSparsePointerAddress(MatrixObject obj)

### getMatrixInputForGPUInstruction

public MatrixObject getMatrixInputForGPUInstruction(String varName, String opcode)

### releaseMatrixInput

public void releaseMatrixInput(String varName)
Unpins a currently pinned matrix variable and update fine-grained statistics.

Parameters:
  `varName` - variable name

### releaseMatrixInput

public void releaseMatrixInput(String... varNames)

### releaseMatrixInputForGPUInstruction

public void releaseMatrixInputForGPUInstruction(String varName)

### getFrameInput

public FrameBlock getFrameInput(CPOperand input)

### getFrameInput

public FrameBlock getFrameInput(String varName)
Pins a frame variable into memory and returns the internal frame block.

Parameters:
  `varName` - variable name
Returns:
  frame block

### releaseFrameInput

public void releaseFrameInput(String varName)
Unpins a currently pinned frame variable.

Parameters:
  `varName` - variable name

### releaseFrameInputs

public void releaseFrameInputs(CPOperand[] inputs)

### releaseTensorInput

public void releaseTensorInput(String varName)

### releaseTensorInput

public void releaseTensorInput(String... varNames)

### getScalarInput

public ScalarObject getScalarInput(CPOperand input)

### getScalarInput

public ScalarObject getScalarInput(String name, Types.ValueType vt, boolean isLiteral)

### setScalarOutput

public void setScalarOutput(String varName, ScalarObject so)

### getListObject

public ListObject getListObject(CPOperand input)

### getListObject

public ListObject getListObject(String name)

### releaseMatrixOutputForGPUInstruction

public void releaseMatrixOutputForGPUInstruction(String varName)

### setMatrixOutput

public void setMatrixOutput(String varName, MatrixBlock outputData)

### setMatrixOutputAndLineage

public void setMatrixOutputAndLineage(CPOperand var, MatrixBlock outputData, LineageItem li)

### setMatrixOutputAndLineage

public void setMatrixOutputAndLineage(String varName, MatrixBlock outputData, LineageItem li)

### setMatrixOutputAndLineage

public void setMatrixOutputAndLineage(String varName, Future<MatrixBlock> fmb, LineageItem li)

### setMatrixOutput

public void setMatrixOutput(String varName, Future<MatrixBlock> fmb)

### setMatrixOutput

public void setMatrixOutput(String varName, MatrixBlock outputData, MatrixObject.UpdateType flag)

### setTensorOutput

public void setTensorOutput(String varName, TensorBlock outputData)

### setFrameOutput

public void setFrameOutput(String varName, FrameBlock outputData)

### createCacheableData

public static CacheableData<?> createCacheableData(CacheBlock<?> cb)

### createMatrixObject

public static MatrixObject createMatrixObject(MatrixBlock mb)

### createMatrixObject

public static MatrixObject createMatrixObject(DataCharacteristics dc)

### createFrameObject

public static FrameObject createFrameObject(DataCharacteristics dc)

### createFrameObject

public static FrameObject createFrameObject(FrameBlock fb)

### getMatrixInputs

public List<MatrixBlock> getMatrixInputs(CPOperand[] inputs)

### getMatrixInputs

public List<MatrixBlock> getMatrixInputs(CPOperand[] inputs, boolean includeList)

### getScalarInputs

public List<ScalarObject> getScalarInputs(CPOperand[] inputs)

### getFrameInputs

public List<FrameBlock> getFrameInputs(CPOperand[] inputs)

### releaseMatrixInputs

public void releaseMatrixInputs(CPOperand[] inputs)

### releaseMatrixInputs

public void releaseMatrixInputs(CPOperand[] inputs, boolean includeList)

### pinVariables

public Queue<Boolean> pinVariables(List<String> varList)
Pin a given list of variables i.e., set the "clean up" state in corresponding matrix objects, so that the cached data inside these objects is not cleared and the corresponding HDFS files are not deleted (through rmvar instructions). This is necessary for: function input variables, parfor result variables, parfor shared inputs that are passed to functions. The function returns the OLD "clean up" state of matrix objects.

Parameters:
  `varList` - variable list
Returns:
  indicator vector of old cleanup state of matrix objects

### unpinVariables

public void unpinVariables(List<String> varList, Queue<Boolean> varsState)
Unpin the a given list of variables by setting their "cleanup" status to the values specified by `varsStats`. Typical usage: `oldStatus = pinVariables(varList); ... unpinVariables(varList, oldStatus);` i.e., a call to unpinVariables() is preceded by pinVariables().

Parameters:
  `varList` - variable list
  `varsState` - variable state

### getVarList

public ArrayList<String> getVarList()
NOTE: No order guaranteed, so keep same list for pin and unpin.

Returns:
  list of all variable names.

### getVarListPartitioned

public ArrayList<String> getVarListPartitioned()
NOTE: No order guaranteed, so keep same list for pin and unpin.

Returns:
  list of all variable names of partitioned matrices.

### cleanupDataObject

public final void cleanupDataObject(Data dat)

### cleanupCacheableData

public void cleanupCacheableData(CacheableData<?> mo)

### isFederated

public boolean isFederated(CPOperand input)

### isFederated

public boolean isFederated(CPOperand input, FTypes.FType type)

### traceLineage

public void traceLineage(Instruction inst)

### maintainLineageDebuggerInfo

public void maintainLineageDebuggerInfo(Instruction inst)

### getLineageItem

public LineageItem getLineageItem(CPOperand input)

### getLineageItem

public LineageItem getLineageItem(String varname)

### getOrCreateLineageItem

public LineageItem getOrCreateLineageItem(CPOperand input)

### replaceLineageItem

public void replaceLineageItem(String varname, LineageItem li)

### addTmpParforFunction

public void addTmpParforFunction(String fname)

### getTmpParforFunctions

public Set<String> getTmpParforFunctions()

### toString

public String toString()

Overrides:
  `toString` in class `Object`