Package org.apache.sysds.hops.recompile
Class Recompiler
java.lang.Object
org.apache.sysds.hops.recompile.Recompiler
Dynamic recompilation of hop dags to runtime instructions, which includes the
following substeps:
(1) deep copy hop dag, (2) refresh matrix characteristics, (3) apply
dynamic rewrites, (4) refresh memory estimates, (5) construct lops (incl
operator selection), and (6) generate runtime program (incl piggybacking).
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleancheckCPReblock(ExecutionContext ec, String varin) CP Reblock check for spark instructions; in contrast to MR, we can not rely on the input file sizes because inputs might be passed via rdds.deepCopyHopsDag(List<Hop> hops) Deep copy of hops dags for parallel recompilation.static HopdeepCopyHopsDag(Hop hops) Deep copy of hops dags for parallel recompilation.static voidexecuteInMemoryReblock(ExecutionContext ec, String varin, String varout) static voidexecuteInMemoryReblock(ExecutionContext ec, String varin, String varout, LineageItem litem) static voidextractDAGOutputStatistics(List<Hop> hops, LocalVariableMap vars) static voidextractDAGOutputStatistics(List<Hop> hops, LocalVariableMap vars, boolean overwrite) static voidextractDAGOutputStatistics(Hop hop, LocalVariableMap vars, boolean overwrite) static voidrClearLops(Hop hop) Clearing lops for a given hops includes to (1) remove the reference to constructed lops and (2) clear the exec type (for consistency).static ArrayList<Instruction>recompile(StatementBlock sb, ArrayList<Hop> hops, ExecutionContext ec, RecompileStatus status, boolean inplace, boolean replaceLit, boolean updateStats, boolean forceEt, boolean pred, Types.ExecType et, long tid) Core internal primitive for the dynamic recompilation of any DAGs/predicate, including all variants with slightly different configurations.static voidrecompileFunctionOnceIfNeeded(boolean recompileOnce, List<ProgramBlock> childBlocks, long tid, boolean inplace, Recompiler.ResetType reset, ExecutionContext ec) static ArrayList<Instruction>recompileHopsDag(Hop hop, LocalVariableMap vars, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) static ArrayList<Instruction>recompileHopsDag(StatementBlock sb, ArrayList<Hop> hops, ExecutionContext ec, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) static ArrayList<Instruction>recompileHopsDag(StatementBlock sb, ArrayList<Hop> hops, LocalVariableMap vars, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) static ArrayList<Instruction>recompileHopsDag2Forced(Hop hop, long tid, Types.ExecType et) static ArrayList<Instruction>recompileHopsDag2Forced(StatementBlock sb, ArrayList<Hop> hops, long tid, Types.ExecType et) static ArrayList<Instruction>static ArrayList<Instruction>recompileHopsDagInstructions(StatementBlock sb, ArrayList<Hop> hops) static voidrecompileProgramBlockHierarchy(List<ProgramBlock> pbs, LocalVariableMap vars, long tid, boolean inplace, Recompiler.ResetType resetRecompile) static voidrecompileProgramBlockHierarchy2Forced(ArrayList<ProgramBlock> pbs, long tid, Set<String> fnStack, Types.ExecType et) Method to recompile program block hierarchy to forced execution time.static voidThis method does NO full program block recompile (no stats update, no rewrites, no recursion) but only regenerates lops and instructions.static RecompileStatusreconcileUpdatedCallVarsIf(RecompileStatus oldStatus, RecompileStatus callStatusIf, RecompileStatus callStatusElse, StatementBlock sb) static LocalVariableMapreconcileUpdatedCallVarsIf(LocalVariableMap oldCallVars, LocalVariableMap callVarsIf, LocalVariableMap callVarsElse, StatementBlock sb) static booleanreconcileUpdatedCallVarsLoops(RecompileStatus oldCallStatus, RecompileStatus callStatus, StatementBlock sb) static booleanreconcileUpdatedCallVarsLoops(LocalVariableMap oldCallVars, LocalVariableMap callVars, StatementBlock sb) static voidRe-initializes the recompiler according to the current optimizer flags.static voidremoveUpdatedScalars(LocalVariableMap callVars, StatementBlock sb) Remove any scalar variables from the variable map if the variable is updated in this block.static booleanrequiresRecompilation(ArrayList<Hop> hops) static booleanrequiresRecompilation(Hop hop) static intrGetMaxParallelism(List<Hop> hops) static intrGetMaxParallelism(Hop hop) static voidrRecompileProgramBlock2Forced(ProgramBlock pb, long tid, Set<String> fnStack, Types.ExecType et) static voidrReplaceLiterals(Hop hop, ExecutionContext ec, boolean scalarsOnly) public interface to package local literal replacementstatic voidrReplaceLiterals(Hop hop, LocalVariableMap vars, boolean scalarsOnly) static voidrSetExecType(Hop hop, Types.ExecType etype) static voidrSetMaxParallelism(List<Hop> hops, int k) static voidrSetMaxParallelism(Hop hop, int k) static voidrUpdateFunctionNames(Hop hop, long pid) static voidrUpdateStatistics(Hop hop, LocalVariableMap vars) static voidupdateFunctionNames(List<Hop> hops, long pid)
-
Constructor Details
-
Recompiler
public Recompiler()
-
-
Method Details
-
reinitRecompiler
public static void reinitRecompiler()Re-initializes the recompiler according to the current optimizer flags. -
recompileHopsDag
public static ArrayList<Instruction> recompileHopsDag(StatementBlock sb, ArrayList<Hop> hops, ExecutionContext ec, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) -
recompileHopsDag
public static ArrayList<Instruction> recompileHopsDag(StatementBlock sb, ArrayList<Hop> hops, LocalVariableMap vars, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) -
recompileHopsDag
public static ArrayList<Instruction> recompileHopsDag(Hop hop, LocalVariableMap vars, RecompileStatus status, boolean inplace, boolean replaceLit, long tid) -
recompileHopsDag2Forced
public static ArrayList<Instruction> recompileHopsDag2Forced(StatementBlock sb, ArrayList<Hop> hops, long tid, Types.ExecType et) -
recompileHopsDag2Forced
-
recompileHopsDagInstructions
public static ArrayList<Instruction> recompileHopsDagInstructions(StatementBlock sb, ArrayList<Hop> hops) -
recompileHopsDagInstructions
-
recompile
public static ArrayList<Instruction> recompile(StatementBlock sb, ArrayList<Hop> hops, ExecutionContext ec, RecompileStatus status, boolean inplace, boolean replaceLit, boolean updateStats, boolean forceEt, boolean pred, Types.ExecType et, long tid) Core internal primitive for the dynamic recompilation of any DAGs/predicate, including all variants with slightly different configurations.- Parameters:
sb- statement block of DAG, null for predicateshops- list of DAG root nodesec- Execution contextstatus- recompilation statusinplace- modify DAG in place, otherwise deep copyreplaceLit- replace literals (only applicable on deep copy)updateStats- update statistics, rewrites, and memory estimatesforceEt- force a given execution type, null for resetpred- recompile for predicate DAGet- given execution typetid- thread id, 0 for main or before worker creation- Returns:
- modified list of instructions
-
recompileProgramBlockHierarchy
public static void recompileProgramBlockHierarchy(List<ProgramBlock> pbs, LocalVariableMap vars, long tid, boolean inplace, Recompiler.ResetType resetRecompile) -
recompileProgramBlockHierarchy2Forced
public static void recompileProgramBlockHierarchy2Forced(ArrayList<ProgramBlock> pbs, long tid, Set<String> fnStack, Types.ExecType et) Method to recompile program block hierarchy to forced execution time. This affects also referenced functions and chains of functions. Use et==null in order to release the forced exec type.- Parameters:
pbs- list of program blockstid- thread idfnStack- function stacket- execution type
-
recompileProgramBlockInstructions
This method does NO full program block recompile (no stats update, no rewrites, no recursion) but only regenerates lops and instructions. The primary use case is recompilation after are hop configuration changes which allows to preserve statistics (e.g., propagated worst case stats from other program blocks) and better performance for recompiling individual program blocks.- Parameters:
pb- program block- Throws:
IOException- if IOException occurs
-
requiresRecompilation
-
requiresRecompilation
-
deepCopyHopsDag
Deep copy of hops dags for parallel recompilation.- Parameters:
hops- list of high-level operators- Returns:
- list of high-level operators
-
deepCopyHopsDag
Deep copy of hops dags for parallel recompilation.- Parameters:
hops- high-level operator- Returns:
- high-level operator
-
updateFunctionNames
-
rUpdateFunctionNames
-
reconcileUpdatedCallVarsLoops
public static boolean reconcileUpdatedCallVarsLoops(LocalVariableMap oldCallVars, LocalVariableMap callVars, StatementBlock sb) -
reconcileUpdatedCallVarsLoops
public static boolean reconcileUpdatedCallVarsLoops(RecompileStatus oldCallStatus, RecompileStatus callStatus, StatementBlock sb) -
reconcileUpdatedCallVarsIf
public static LocalVariableMap reconcileUpdatedCallVarsIf(LocalVariableMap oldCallVars, LocalVariableMap callVarsIf, LocalVariableMap callVarsElse, StatementBlock sb) -
reconcileUpdatedCallVarsIf
public static RecompileStatus reconcileUpdatedCallVarsIf(RecompileStatus oldStatus, RecompileStatus callStatusIf, RecompileStatus callStatusElse, StatementBlock sb) -
rRecompileProgramBlock2Forced
public static void rRecompileProgramBlock2Forced(ProgramBlock pb, long tid, Set<String> fnStack, Types.ExecType et) -
removeUpdatedScalars
Remove any scalar variables from the variable map if the variable is updated in this block.- Parameters:
callVars- Map of variables eligible for propagation.sb- DML statement block.
-
extractDAGOutputStatistics
-
extractDAGOutputStatistics
public static void extractDAGOutputStatistics(List<Hop> hops, LocalVariableMap vars, boolean overwrite) -
extractDAGOutputStatistics
-
rClearLops
Clearing lops for a given hops includes to (1) remove the reference to constructed lops and (2) clear the exec type (for consistency). The latter is important for advanced optimizers like parfor; otherwise subtle side-effects of program recompilation and hop-lop rewrites possible (e.g., see indexingop hop-lop rewrite in combination parfor rewrite set exec type that eventuelly might lead to unnecessary remote_parfor jobs).- Parameters:
hop- high-level operator
-
rUpdateStatistics
-
rReplaceLiterals
public interface to package local literal replacement- Parameters:
hop- high-level operatorec- Execution contextscalarsOnly- if true, replace only scalar variables but no matrix operations; if false, apply full literal replacement
-
rReplaceLiterals
-
rSetExecType
-
rGetMaxParallelism
-
rGetMaxParallelism
-
rSetMaxParallelism
-
rSetMaxParallelism
-
recompileFunctionOnceIfNeeded
public static void recompileFunctionOnceIfNeeded(boolean recompileOnce, List<ProgramBlock> childBlocks, long tid, boolean inplace, Recompiler.ResetType reset, ExecutionContext ec) -
checkCPReblock
CP Reblock check for spark instructions; in contrast to MR, we can not rely on the input file sizes because inputs might be passed via rdds.- Parameters:
ec- execution contextvarin- variable- Returns:
- true if CP reblock?
-
checkCPCheckpoint
-
executeInMemoryReblock
-
executeInMemoryReblock
public static void executeInMemoryReblock(ExecutionContext ec, String varin, String varout, LineageItem litem)
-