27#ifndef __CTX_VIRTUAL_MACHINE_H__
28#define __CTX_VIRTUAL_MACHINE_H__
217 gzDouble instruction_cost = 1.0,
218 gzDouble program_launch_cost = 0.0,
219 gzDouble pass_barrier_cost = 0.0)
455 gzUInt32& mappedIndex)
const;
537 gzArray<ctxCommandBufferSubRoutine>& subroutines,
ctxRegisterUseInfo* updates = NULL);
553 const gzArray<gzUInt32>& parallelCommands,
const gzArray<ctxCommandBufferSubRoutine>& routines,
554 gzArray<gzUInt32>& origins, gzBool& preserveDropCommands);
560CTX_EXPORT gzVoid
ctxRebuildSubroutines(gzArray<ctxParallelExecution> &executionInfo, gzArray<ctxParallelExecution> &executionData, gzArray<ctxCommandBufferSubRoutine> &result);
579 gzArray<ctxParallelExecution>& executionInfo, gzArray<ctxParallelExecution>& executionData,
580 gzUInt32 targetThreads, gzArray<gzUInt32>* commandOrigins);
gzUInt32 origin_start_index
ctxCommandBufferSubRoutine()
gzList< gzVoid > dependencies
gzDynamicArray< ctxRegisterUse > paramRegister
gzDynamicArray< ctxRegisterUse > generalRegister
gzDynamicArray< ctxRegisterUse > inputRegister
gzDynamicArray< ctxRegisterUse > dropConnections
gzDynamicArray< ctxRegisterUse > valueRegister
gzDynamicArray< ctxRegisterUse > deltaSumRegister
gzDynamicArray< ctxRegisterUse > deltaRegister
gzDynamicArray< ctxRegisterUse > tempRegisters
gzDynamicArray< ctxRegisterUse > expectedRegister
gzVoid reset(gzUInt32 chunkSize)
ctxDetailedRegisterUse(gzUInt32 chunkSize=1000)
gzDynamicArray< ctxRegisterUse > wbRegister
ctxExecutionCostModel(gzUInt32 parallel_capacity=1, gzDouble instruction_cost=1.0, gzDouble program_launch_cost=0.0, gzDouble pass_barrier_cost=0.0)
gzUInt32 parallelCapacity
gzDouble programLaunchCost
gzUInt32 sourceStoreValue
gzUInt32 reducedRecallValue
gzUInt32 sourceRecallGeneral
gzUInt32 reducedInstructions
gzUInt32 reducedRecallTemp
gzUInt32 reducedStoreTemp
gzUInt32 sourceRecallValue
gzUInt32 sourceInstructions
gzUInt32 reducedStoreValue
gzUInt32 reducedStoreGeneral
gzUInt32 reducedRecallGeneral
gzUInt32 sourceStoreGeneral
gzUInt32 reducedSubroutines
gzUInt32 sourceRecallTemp
gzUInt32 sourceSubroutines
ctxRegisterWriter deltaRMSRegister
ctxRegisterWriter tempRegisters
ctxRegisterWriter generalRegister
ctxRegisterWriter deltaRegister
ctxRegisterWriter paramRegister
ctxRegisterWriter latencyValueRegister
ctxRegisterWriter deltaSumRegister
ctxRegisterWriter valueRegister
ctxRegisterWriter parameterUpdateRegister
ctxRegisterWriter wbRegister
ctxRegisterWriter dropConnections
gzUInt32 emitPerfectMadHits
gzUInt32 emitMixedSoPHits
gzDouble emitPerfectMadMs
ctxRegisterAccessDependacy(gzUInt32 reader_, gzUInt32 writer_)
gzArray< gzUInt32 > paramRegister
gzUInt32 maxInputRegister
gzArray< gzUInt32 > valueRegister
gzArray< gzUInt32 > tempRegisters
gzArray< gzUInt32 > wbRegister
gzUInt32 maxExpectedRegister
gzArray< gzUInt32 > inputRegister
gzArray< gzUInt32 > dropConnections
gzUInt32 maxValueRegister
gzArray< gzUInt32 > deltaRegister
gzUInt32 maxDropConnections
gzUInt32 maxGeneralRegister
gzBool mapIndex(ctxRegistrySourceIndex bank, gzUInt32 sourceIndex, gzUInt32 &mappedIndex) const
Resolve an original register index through this optimizer placement.
gzArray< gzUInt32 > deltaSumRegister
gzArray< gzUInt32 > generalRegister
gzUInt32 maxDeltaRegister
gzUInt32 maxParamRegister
gzArray< gzUInt32 > expectedRegister
gzUInt32 maxDeltaSumRegister
static gzBool optimize(ctxVirtualMachineProgram *program, ctxDetailedRegisterUse &detailUse, ctxOptimizeFlags flags, const gzDynamicArray< gzUInt32 > *valueKeepList=nullptr, ctxRegisterTranslation *translationOut=nullptr)
Reduce transports and place registers before emitting evaluate MAD groups.
static gzBool execute(ctxVirtualMachineProgram *program, const ctxProgramExecution &flags=CTX_PRG_EXEC_DEFAULT, ctxDetailedRegisterUse *register_use=NULL)
static gzBool checkConsistency(ctxVirtualMachineProgram *program)
gzUInt32 * tempRegister_updateID
gzUInt32 * input_updateID
ctxVirtualMachineProgram()
gzUInt32 * deltaValueMean_updateID
gzUInt32 * drop_connection_updateID
ctxCompileStatus compile_status
gzUInt32 * deltaValue_updateID
gzUByte * dropConnections
gzRefPointer< gzReference > nativeProgram
gzUInt32 * deltaValueRMS_updateID
gzUInt32 * generalValue_updateID
gzUInt32 * value_updateID
gzUInt32 * parameter_updateID
gzUInt32 * deltaValueSum_updateID
gzUInt32 * expectedValue_updateID
ctxBackpropInfo backprop_info
virtual ~ctxVirtualMachineProgram()
gzUInt32 * weightAndBias_updateID
gzString errorInformation
GZ_USE_BIT_LOGIC(ctxInstrumentationFlags)
const gzUInt32 CTX_UNDEFINED_INDEX
gzBool ctxGetProgramRegisterAccessInfo(gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, gzArray< ctxProgramRegisterAccessInfo > &access, gzRefList< ctxRegisterAccessDependacy > &depends, ctxRegisterUseInfo *updates=NULL)
ctxProgramExecution
Execution flags for ctxVirtualMachine::execute.
@ CTX_PRG_EXEC_DEFAULT
Ignore register dependancies.
@ CTX_PRG_EXEC_EXECUTE_ON_WM
Only compile the program don't execute.
@ CTX_PRG_EXEC_NO_REG_DEPS
Execute pages in reversed order (for backprop).
@ CTX_PRG_EXEC_PARALLEL
Execute using built in WM and ignore compile backed.
@ CTX_PRG_EXEC_COMPILE_ONLY
@ CTX_PRG_EXEC_REVERSED_PAGES
Execute in parallel if possible.
gzUInt32 ctxGetOptimizeLocalRegisterReductions(gzDynamicArray< ctxRegisterUse > ®ister_use, gzUInt32 *source, gzUInt32 command, gzUInt32 anti_command)
gzArray< gzUInt32 > ctxOptimizeRegisterUsage(gzDynamicArray< ctxRegisterUse > ®ister_use, gzBool sequential=FALSE, gzUInt32 *max_register_index=NULL)
gzUInt32 ctxCopyReducedBuffer(const gzUInt32 *source, gzUInt32 length, gzDynamicArray< gzUInt32 > &destination, ctxDetailedRegisterUse &detailUse, gzUInt32 pass=0, gzUInt32 program=0, ctxReduceFlags reduceFlags=CTX_REDUCE_PRESERVE_BACKPROP_BANKS, const gzDynamicArray< gzUInt32 > *valueKeepList=nullptr, ctxReduceProfile *profile=nullptr)
ctxOptimizerStats ctxGetOptimizerStats(const gzUInt32 *source, gzUInt32 length, ctxReduceFlags reduceFlags=CTX_REDUCE_PRESERVE_BACKPROP_BANKS, const gzDynamicArray< gzUInt32 > *valueKeepList=nullptr, gzBool includeParallelStats=TRUE)
@ CTX_REDUCE_SPLIT_VALUE_STORESOURCE
@ CTX_REDUCE_STRIP_DROPCONNECT
@ CTX_REDUCE_PRESERVE_BACKPROP_BANKS
gzBool(*) ctxVirtualMachineProgramFunc(ctxVirtualMachineProgram *program)
gzUInt32 ctxGetStackSize(gzUInt32 *commands, gzUInt32 length)
ctxRegisterUseInfo ctxGetRegisterUsage(gzUInt32 *commands, gzUInt32 length, ctxDetailedRegisterUse *detail=NULL, gzUInt32 pass=0, gzUInt32 program=0)
@ CTX_COMPILE_STATUS_OPTIMIZED
@ CTX_COMPILE_STATUS_DISPOSE_COMMANDS
@ CTX_COMPILE_STATUS_NOT_COMPILED
@ CTX_COMPILE_STATUS_ERROR_IN_COMPILE
@ CTX_COMPILE_STATUS_COMPILED
gzBool ctxTranslateRegisterUsage(ctxDetailedRegisterUse &detailUse, ctxRegisterTranslation &translation, gzUInt32 *source, gzUInt32 length)
Translate scalar operands and complete representable ranged sequences.
gzUInt32 ctxCopyCommandBuffer(gzUInt32 *destination, gzUInt32 *source, gzUInt32 length, gzBool addSkipCommand=FALSE, gzUInt32 *instructions=nullptr)
gzVoid ctxRebuildSubroutines(gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzArray< ctxCommandBufferSubRoutine > &result)
gzDouble ctxGetParallelPlanExecCost(const gzUInt32 *commands, const gzArray< ctxParallelExecution > &executionInfo, const gzArray< ctxParallelExecution > &executionData, const ctxExecutionCostModel &costModel)
gzBool ctxBuildCommandBufferPasses(gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, ctxRegisterUseInfo *updates=NULL)
Build the same hazard-safe passes without retaining diagnostic dependency lists.
gzDouble ctxGetParallelPassExecCost(const gzUInt32 *commands, const ctxParallelExecution &passInfo, const gzArray< ctxParallelExecution > &executionData, const ctxExecutionCostModel &costModel)
gzArray< ctxCommandBufferSubRoutine > ctxParallelCommandBufferSubRoutine(gzUInt32 *commands, gzUInt32 *destinationParallelCommands, ctxCommandBufferSubRoutine subroutine, gzBool combineSmallPackages=FALSE)
gzBool ctxUpdateCommandBufferDependancies(gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, ctxRegisterUseInfo *updates=NULL)
gzUInt32 ctxGetSubRoutineLength(gzArray< ctxCommandBufferSubRoutine > &subroutines)
gzUInt32 ctxBuildParallelExecutionInfo(gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzArray< ctxCommandBufferSubRoutine > &subroutines)
@ CTX_OPTIMIZE_TRAIN_SAFE
@ CTX_OPTIMIZE_COMPACT_DROP_MASKS
Compact used mask indices without reusing a mask across forward/backward lifetime.
@ CTX_OPTIMIZE_REMOVE_DROP_TEST
@ CTX_OPTIMIZE_SHARED_PARAMETER_GRADIENTS
ctxCommandBufferSubRoutine ctxGetCommandBufferInfo(const gzUInt32 *commands, gzUInt32 command_len, gzUInt32 start_index=0)
gzBool ctxBuildParallelCommandOrigins(const ctxVirtualMachineProgram *program, const gzArray< gzUInt32 > ¶llelCommands, const gzArray< ctxCommandBufferSubRoutine > &routines, gzArray< gzUInt32 > &origins, gzBool &preserveDropCommands)
Preserve original CAL word positions after backend partitioning.
gzUInt32 ctxCombineParallelExecutionInfo(gzUInt32 *commands, gzUInt32 length, gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzUInt32 targetThreads)
gzDouble ctxGetParallelProgramExecCost(const gzUInt32 *commands, const ctxParallelExecution &execution, const ctxExecutionCostModel &costModel)
gzUInt32 ctxGetProgramMaxRegisterSize(gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines)
gzUInt32 ctxHasRecallValues(gzUInt32 *commands, gzUInt32 search_index)
ctxVirtualMachineProgramFunc * func