CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxVirtualMachine.h File Reference
#include "ctxBase.h"
#include "ctxInlineFuncs.h"

Go to the source code of this file.

Classes

class  ctxVirtualMachineProgram
struct  ctxVirtualMachineProgramInfo
class  ctxCommandBufferSubRoutine
class  ctxRegisterAccessDependacy
class  ctxRegisterWriter
class  ctxProgramRegisterAccessInfo
struct  ctxParallelExecution
class  ctxExecutionCostModel
class  ctxRegisterUseInfo
class  ctxOptimizerStats
class  ctxReduceProfile
class  ctxRegisterUse
class  ctxDetailedRegisterUse
class  ctxRegisterTranslation
class  ctxVirtualMachine

Typedefs

typedef gzBool(*) ctxVirtualMachineProgramFunc(ctxVirtualMachineProgram *program)

Enumerations

enum  ctxOptimizeFlags {
  CTX_OPTIMIZE_NONE = 0 , CTX_OPTIMIZE_VALUE_USE = 1 << 0 , CTX_OPTIMIZE_REMOVE_DROP_TEST = 1 << 1 , CTX_OPTIMIZE_TRAIN_SAFE = 1 << 2 ,
  CTX_OPTIMIZE_SHARED_PARAMETER_GRADIENTS = 1 << 3 , CTX_OPTIMIZE_COMPACT_DROP_MASKS = 1 << 4
}
enum  ctxCompileStatus {
  CTX_COMPILE_STATUS_NOT_COMPILED = 0 , CTX_COMPILE_STATUS_COMPILED = 1<<0 , CTX_COMPILE_STATUS_OPTIMIZED = 1<<1 , CTX_COMPILE_STATUS_DISPOSE_COMMANDS = 1<<2 ,
  CTX_COMPILE_STATUS_ERROR_IN_COMPILE = 1<<3
}
enum  ctxReduceFlags {
  CTX_REDUCE_DEFAULT = 0 , CTX_REDUCE_STRIP_DROPCONNECT = (1u << 0) , CTX_REDUCE_PRESERVE_BACKPROP_BANKS = (1u << 1) , CTX_REDUCE_MAD_REORDER = (1u << 2) ,
  CTX_REDUCE_SPLIT_VALUE_STORESOURCE = (1u<<3)
}
enum  ctxProgramExecution {
  CTX_PRG_EXEC_COMPILE_ONLY = 1 << 0 , CTX_PRG_EXEC_EXECUTE_ON_WM = 1 << 1 , CTX_PRG_EXEC_PARALLEL = 1 << 2 , CTX_PRG_EXEC_REVERSED_PAGES = 1 << 3 ,
  CTX_PRG_EXEC_NO_REG_DEPS = 1 << 4 , CTX_PRG_EXEC_DEFAULT = CTX_PRG_EXEC_PARALLEL , CTX_PRG_EXEC_SINGLE = 0
}
 Execution flags for ctxVirtualMachine::execute. More...

Functions

 GZ_USE_BIT_LOGIC (ctxOptimizeFlags)
 GZ_USE_BIT_LOGIC (ctxCompileStatus)
 GZ_USE_BIT_LOGIC (ctxReduceFlags)
 GZ_USE_BIT_LOGIC (ctxProgramExecution)
ctxCommandBufferSubRoutine ctxGetCommandBufferInfo (const gzUInt32 *commands, gzUInt32 command_len, gzUInt32 start_index=0)
gzArray< ctxCommandBufferSubRoutine > ctxParallelCommandBufferSubRoutine (gzUInt32 *commands, gzUInt32 *destinationParallelCommands, ctxCommandBufferSubRoutine subroutine, gzBool combineSmallPackages=FALSE)
gzBool ctxUpdateCommandBufferDependancies (gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, ctxRegisterUseInfo *updates=NULL)
gzBool ctxBuildCommandBufferPasses (gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, ctxRegisterUseInfo *updates=NULL)
 Build the same hazard-safe passes without retaining diagnostic dependency lists.
gzBool ctxGetProgramRegisterAccessInfo (gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines, gzArray< ctxProgramRegisterAccessInfo > &access, gzRefList< ctxRegisterAccessDependacy > &depends, ctxRegisterUseInfo *updates=NULL)
gzUInt32 ctxBuildParallelExecutionInfo (gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzArray< ctxCommandBufferSubRoutine > &subroutines)
gzDouble ctxGetParallelProgramExecCost (const gzUInt32 *commands, const ctxParallelExecution &execution, const ctxExecutionCostModel &costModel)
gzDouble ctxGetParallelPassExecCost (const gzUInt32 *commands, const ctxParallelExecution &passInfo, const gzArray< ctxParallelExecution > &executionData, const ctxExecutionCostModel &costModel)
gzDouble ctxGetParallelPlanExecCost (const gzUInt32 *commands, const gzArray< ctxParallelExecution > &executionInfo, const gzArray< ctxParallelExecution > &executionData, const ctxExecutionCostModel &costModel)
gzUInt32 ctxHasRecallValues (gzUInt32 *commands, gzUInt32 search_index)
gzBool ctxBuildParallelCommandOrigins (const ctxVirtualMachineProgram *program, const gzArray< gzUInt32 > &parallelCommands, const gzArray< ctxCommandBufferSubRoutine > &routines, gzArray< gzUInt32 > &origins, gzBool &preserveDropCommands)
 Preserve original CAL word positions after backend partitioning.
gzUInt32 ctxGetSubRoutineLength (gzArray< ctxCommandBufferSubRoutine > &subroutines)
gzUInt32 ctxGetProgramMaxRegisterSize (gzUInt32 *commands, gzArray< ctxCommandBufferSubRoutine > &subroutines)
gzVoid ctxRebuildSubroutines (gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzArray< ctxCommandBufferSubRoutine > &result)
gzUInt32 ctxCopyCommandBuffer (gzUInt32 *destination, gzUInt32 *source, gzUInt32 length, gzBool addSkipCommand=FALSE, gzUInt32 *instructions=nullptr)
ctxRegisterUseInfo ctxGetRegisterUsage (gzUInt32 *commands, gzUInt32 length, ctxDetailedRegisterUse *detail=NULL, gzUInt32 pass=0, gzUInt32 program=0)
gzArray< ctxRegisterUseInfo > ctxGetRegisterUsage (gzUInt32 program, gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzUInt32 *source, ctxDetailedRegisterUse *detail=NULL)
gzUInt32 ctxCombineParallelExecutionInfo (gzUInt32 *commands, gzUInt32 length, gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzUInt32 targetThreads)
gzUInt32 ctxCombineParallelExecutionInfo (gzUInt32 *commands, gzUInt32 length, gzArray< ctxParallelExecution > &executionInfo, gzArray< ctxParallelExecution > &executionData, gzUInt32 targetThreads, gzArray< gzUInt32 > *commandOrigins)
 Repack CAL and its original-word metadata together; preserve both on failure.
gzArray< gzUInt32 > ctxOptimizeRegisterUsage (gzDynamicArray< ctxRegisterUse > &register_use, gzBool sequential=FALSE, gzUInt32 *max_register_index=NULL)
gzUInt32 ctxGetOptimizeLocalRegisterReductions (gzDynamicArray< ctxRegisterUse > &register_use, gzUInt32 *source, gzUInt32 command, gzUInt32 anti_command)
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)
gzUInt32 ctxGetStackSize (gzUInt32 *commands, gzUInt32 length)
ctxRegisterTranslation ctxOptimizeRegisterUsage (ctxDetailedRegisterUse &register_use, gzBool sequential=FALSE)
ctxOptimizerStats ctxGetOptimizerStats (const gzUInt32 *source, gzUInt32 length, ctxReduceFlags reduceFlags=CTX_REDUCE_PRESERVE_BACKPROP_BANKS, const gzDynamicArray< gzUInt32 > *valueKeepList=nullptr, gzBool includeParallelStats=TRUE)
gzBool ctxTranslateRegisterUsage (ctxDetailedRegisterUse &detailUse, ctxRegisterTranslation &translation, gzUInt32 *source, gzUInt32 length)
 Translate scalar operands and complete representable ranged sequences.

Typedef Documentation

◆ ctxVirtualMachineProgramFunc

typedef gzBool(*) ctxVirtualMachineProgramFunc(ctxVirtualMachineProgram *program)

Definition at line 147 of file ctxVirtualMachine.h.

Enumeration Type Documentation

◆ ctxCompileStatus

Enumerator
CTX_COMPILE_STATUS_NOT_COMPILED 
CTX_COMPILE_STATUS_COMPILED 
CTX_COMPILE_STATUS_OPTIMIZED 
CTX_COMPILE_STATUS_DISPOSE_COMMANDS 
CTX_COMPILE_STATUS_ERROR_IN_COMPILE 

Definition at line 48 of file ctxVirtualMachine.h.

◆ ctxOptimizeFlags

Enumerator
CTX_OPTIMIZE_NONE 
CTX_OPTIMIZE_VALUE_USE 
CTX_OPTIMIZE_REMOVE_DROP_TEST 
CTX_OPTIMIZE_TRAIN_SAFE 
CTX_OPTIMIZE_SHARED_PARAMETER_GRADIENTS 
CTX_OPTIMIZE_COMPACT_DROP_MASKS 

Compact used mask indices without reusing a mask across forward/backward lifetime.

Definition at line 35 of file ctxVirtualMachine.h.

◆ ctxProgramExecution

Execution flags for ctxVirtualMachine::execute.

Enumerator
CTX_PRG_EXEC_COMPILE_ONLY 
CTX_PRG_EXEC_EXECUTE_ON_WM 

Only compile the program don't execute.

CTX_PRG_EXEC_PARALLEL 

Execute using built in WM and ignore compile backed.

CTX_PRG_EXEC_REVERSED_PAGES 

Execute in parallel if possible.

CTX_PRG_EXEC_NO_REG_DEPS 

Execute pages in reversed order (for backprop).

CTX_PRG_EXEC_DEFAULT 

Ignore register dependancies.

CTX_PRG_EXEC_SINGLE 

Definition at line 491 of file ctxVirtualMachine.h.

◆ ctxReduceFlags

Enumerator
CTX_REDUCE_DEFAULT 
CTX_REDUCE_STRIP_DROPCONNECT 
CTX_REDUCE_PRESERVE_BACKPROP_BANKS 
CTX_REDUCE_MAD_REORDER 
CTX_REDUCE_SPLIT_VALUE_STORESOURCE 

Definition at line 59 of file ctxVirtualMachine.h.

Function Documentation

◆ ctxBuildCommandBufferPasses()

gzBool ctxBuildCommandBufferPasses ( gzUInt32 * commands,
gzArray< ctxCommandBufferSubRoutine > & subroutines,
ctxRegisterUseInfo * updates = NULL )

Build the same hazard-safe passes without retaining diagnostic dependency lists.

Clears old dependency lists and pass numbers, checks complete RAW/WAR/WAW ordering and cycles, and reports the same register update flags. On success each subroutine has its execution pass and an empty dependencies list. Call ctxUpdateCommandBufferDependancies when dependency details are needed.

References CTX_EXPORT, and ctxBuildCommandBufferPasses().

Referenced by ctxBuildCommandBufferPasses().

◆ ctxBuildParallelCommandOrigins()

gzBool ctxBuildParallelCommandOrigins ( const ctxVirtualMachineProgram * program,
const gzArray< gzUInt32 > & parallelCommands,
const gzArray< ctxCommandBufferSubRoutine > & routines,
gzArray< gzUInt32 > & origins,
gzBool & preserveDropCommands )

Preserve original CAL word positions after backend partitioning.

A one-word placeholder is sufficient for programs without forward masks. Returns failure for inconsistent or out-of-range partition metadata.

References CTX_EXPORT, and ctxBuildParallelCommandOrigins().

Referenced by ctxBuildParallelCommandOrigins().

◆ ctxBuildParallelExecutionInfo()

gzUInt32 ctxBuildParallelExecutionInfo ( gzArray< ctxParallelExecution > & executionInfo,
gzArray< ctxParallelExecution > & executionData,
gzArray< ctxCommandBufferSubRoutine > & subroutines )

◆ ctxCombineParallelExecutionInfo() [1/2]

gzUInt32 ctxCombineParallelExecutionInfo ( gzUInt32 * commands,
gzUInt32 length,
gzArray< ctxParallelExecution > & executionInfo,
gzArray< ctxParallelExecution > & executionData,
gzUInt32 targetThreads )

◆ ctxCombineParallelExecutionInfo() [2/2]

gzUInt32 ctxCombineParallelExecutionInfo ( gzUInt32 * commands,
gzUInt32 length,
gzArray< ctxParallelExecution > & executionInfo,
gzArray< ctxParallelExecution > & executionData,
gzUInt32 targetThreads,
gzArray< gzUInt32 > * commandOrigins )

Repack CAL and its original-word metadata together; preserve both on failure.

References CTX_EXPORT, and ctxCombineParallelExecutionInfo().

◆ ctxCopyCommandBuffer()

gzUInt32 ctxCopyCommandBuffer ( gzUInt32 * destination,
gzUInt32 * source,
gzUInt32 length,
gzBool addSkipCommand = FALSE,
gzUInt32 * instructions = nullptr )

References CTX_EXPORT, and ctxCopyCommandBuffer().

Referenced by ctxCopyCommandBuffer().

◆ ctxCopyReducedBuffer()

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 )

◆ ctxGetCommandBufferInfo()

ctxCommandBufferSubRoutine ctxGetCommandBufferInfo ( const gzUInt32 * commands,
gzUInt32 command_len,
gzUInt32 start_index = 0 )

◆ ctxGetOptimizeLocalRegisterReductions()

gzUInt32 ctxGetOptimizeLocalRegisterReductions ( gzDynamicArray< ctxRegisterUse > & register_use,
gzUInt32 * source,
gzUInt32 command,
gzUInt32 anti_command )

◆ ctxGetOptimizerStats()

ctxOptimizerStats ctxGetOptimizerStats ( const gzUInt32 * source,
gzUInt32 length,
ctxReduceFlags reduceFlags = CTX_REDUCE_PRESERVE_BACKPROP_BANKS,
const gzDynamicArray< gzUInt32 > * valueKeepList = nullptr,
gzBool includeParallelStats = TRUE )

◆ ctxGetParallelPassExecCost()

gzDouble ctxGetParallelPassExecCost ( const gzUInt32 * commands,
const ctxParallelExecution & passInfo,
const gzArray< ctxParallelExecution > & executionData,
const ctxExecutionCostModel & costModel )

◆ ctxGetParallelPlanExecCost()

gzDouble ctxGetParallelPlanExecCost ( const gzUInt32 * commands,
const gzArray< ctxParallelExecution > & executionInfo,
const gzArray< ctxParallelExecution > & executionData,
const ctxExecutionCostModel & costModel )

◆ ctxGetParallelProgramExecCost()

gzDouble ctxGetParallelProgramExecCost ( const gzUInt32 * commands,
const ctxParallelExecution & execution,
const ctxExecutionCostModel & costModel )

◆ ctxGetProgramMaxRegisterSize()

gzUInt32 ctxGetProgramMaxRegisterSize ( gzUInt32 * commands,
gzArray< ctxCommandBufferSubRoutine > & subroutines )

◆ ctxGetProgramRegisterAccessInfo()

gzBool ctxGetProgramRegisterAccessInfo ( gzUInt32 * commands,
gzArray< ctxCommandBufferSubRoutine > & subroutines,
gzArray< ctxProgramRegisterAccessInfo > & access,
gzRefList< ctxRegisterAccessDependacy > & depends,
ctxRegisterUseInfo * updates = NULL )

◆ ctxGetRegisterUsage() [1/2]

ctxRegisterUseInfo ctxGetRegisterUsage ( gzUInt32 * commands,
gzUInt32 length,
ctxDetailedRegisterUse * detail = NULL,
gzUInt32 pass = 0,
gzUInt32 program = 0 )

◆ ctxGetRegisterUsage() [2/2]

gzArray< ctxRegisterUseInfo > ctxGetRegisterUsage ( gzUInt32 program,
gzArray< ctxParallelExecution > & executionInfo,
gzArray< ctxParallelExecution > & executionData,
gzUInt32 * source,
ctxDetailedRegisterUse * detail = NULL )

◆ ctxGetStackSize()

gzUInt32 ctxGetStackSize ( gzUInt32 * commands,
gzUInt32 length )

References CTX_EXPORT, and ctxGetStackSize().

Referenced by ctxGetStackSize().

◆ ctxGetSubRoutineLength()

gzUInt32 ctxGetSubRoutineLength ( gzArray< ctxCommandBufferSubRoutine > & subroutines)

◆ ctxHasRecallValues()

gzUInt32 ctxHasRecallValues ( gzUInt32 * commands,
gzUInt32 search_index )

References CTX_EXPORT, and ctxHasRecallValues().

Referenced by ctxHasRecallValues().

◆ ctxOptimizeRegisterUsage() [1/2]

ctxRegisterTranslation ctxOptimizeRegisterUsage ( ctxDetailedRegisterUse & register_use,
gzBool sequential = FALSE )

◆ ctxOptimizeRegisterUsage() [2/2]

gzArray< gzUInt32 > ctxOptimizeRegisterUsage ( gzDynamicArray< ctxRegisterUse > & register_use,
gzBool sequential = FALSE,
gzUInt32 * max_register_index = NULL )

◆ ctxParallelCommandBufferSubRoutine()

gzArray< ctxCommandBufferSubRoutine > ctxParallelCommandBufferSubRoutine ( gzUInt32 * commands,
gzUInt32 * destinationParallelCommands,
ctxCommandBufferSubRoutine subroutine,
gzBool combineSmallPackages = FALSE )

◆ ctxRebuildSubroutines()

gzVoid ctxRebuildSubroutines ( gzArray< ctxParallelExecution > & executionInfo,
gzArray< ctxParallelExecution > & executionData,
gzArray< ctxCommandBufferSubRoutine > & result )

◆ ctxTranslateRegisterUsage()

gzBool ctxTranslateRegisterUsage ( ctxDetailedRegisterUse & detailUse,
ctxRegisterTranslation & translation,
gzUInt32 * source,
gzUInt32 length )

Translate scalar operands and complete representable ranged sequences.

Non-affine, undefined or overflowing range mappings return FALSE before changing commands or register-use metadata. This in-place API cannot encode a gather; callers must provide a layout compatible with the addressed ranges.

References CTX_EXPORT, and ctxTranslateRegisterUsage().

Referenced by ctxTranslateRegisterUsage().

◆ ctxUpdateCommandBufferDependancies()

gzBool ctxUpdateCommandBufferDependancies ( gzUInt32 * commands,
gzArray< ctxCommandBufferSubRoutine > & subroutines,
ctxRegisterUseInfo * updates = NULL )

◆ GZ_USE_BIT_LOGIC() [1/4]

GZ_USE_BIT_LOGIC ( ctxCompileStatus )

References GZ_USE_BIT_LOGIC().

◆ GZ_USE_BIT_LOGIC() [2/4]

GZ_USE_BIT_LOGIC ( ctxOptimizeFlags )

References GZ_USE_BIT_LOGIC().

◆ GZ_USE_BIT_LOGIC() [3/4]

GZ_USE_BIT_LOGIC ( ctxProgramExecution )

References GZ_USE_BIT_LOGIC().

◆ GZ_USE_BIT_LOGIC() [4/4]

GZ_USE_BIT_LOGIC ( ctxReduceFlags )

References GZ_USE_BIT_LOGIC().