Documentation ¶
Index ¶
- Constants
- func DCECapture(ctx context.Context, name string, p *path.Capture, ...) (*path.Capture, error)
- func NewForwardWatcher() *forwardWatcher
- func NewFragWatcher() *fragWatcher
- func NewGraphBuilder(ctx context.Context, config DependencyGraphConfig, c *capture.GraphicsCapture, ...) *graphBuilder
- func NewMemWatcher() *memWatcher
- type AccessMode
- type Accesses
- type CmdContext
- type CmdNode
- type DCEBuilder
- func (t *DCEBuilder) BuffersCommands() bool
- func (b *DCEBuilder) Build(ctx context.Context) error
- func (b *DCEBuilder) Flush(ctx context.Context, out transform.Writer) error
- func (b *DCEBuilder) LiveCmdID(oldCmdID api.CmdID) api.CmdID
- func (b *DCEBuilder) LiveCmds() []api.Cmd
- func (b *DCEBuilder) LogStats(ctx context.Context)
- func (b *DCEBuilder) NumLiveInitCmds() int
- func (b *DCEBuilder) OriginalCmdID(liveCmdID api.CmdID) api.CmdID
- func (b *DCEBuilder) PostLoop(ctx context.Context, out transform.Writer)
- func (b *DCEBuilder) PreLoop(ctx context.Context, out transform.Writer)
- func (b *DCEBuilder) Request(ctx context.Context, fci api.SubCmdIdx) error
- func (*DCEBuilder) Transform(ctx context.Context, id api.CmdID, c api.Cmd, out transform.Writer) error
- type DependencyGraph
- func BuildDependencyGraph(ctx context.Context, config DependencyGraphConfig, c *capture.GraphicsCapture, ...) (DependencyGraph, error)
- func GetDependencyGraph(ctx context.Context, c *path.Capture, config DependencyGraphConfig) (DependencyGraph, error)
- func TryGetDependencyGraph(ctx context.Context, c *path.Capture, config DependencyGraphConfig) (DependencyGraph, error)
- type DependencyGraphConfig
- type Distribution
- type ForwardAccess
- type ForwardAccessMode
- type ForwardNodes
- type ForwardWatcher
- type FragWatcher
- type FragmentAccess
- type GraphBuilder
- type GraphBuilderStats
- type MemWatcher
- type MemoryAccess
- type Node
- type NodeAccesses
- type NodeID
- type NodeIDSorter
- type NodeStats
- type ObsNode
- type RecordNodeTrie
- type RefFrag
Constants ¶
const NodeNoID = NodeID(math.MaxUint32)
Variables ¶
This section is empty.
Functions ¶
func DCECapture ¶
func DCECapture(ctx context.Context, name string, p *path.Capture, requestedCmds []*path.Command) (*path.Capture, error)
DCECapture returns a new capture containing only the requested commands and their dependencies.
func NewForwardWatcher ¶
func NewForwardWatcher() *forwardWatcher
func NewFragWatcher ¶
func NewFragWatcher() *fragWatcher
func NewGraphBuilder ¶
func NewGraphBuilder(ctx context.Context, config DependencyGraphConfig, c *capture.GraphicsCapture, initialCmds []api.Cmd, state *api.GlobalState) *graphBuilder
func NewMemWatcher ¶
func NewMemWatcher() *memWatcher
Types ¶
type AccessMode ¶
type AccessMode uint
AccessMode is a bitfield that records read/write accesses
const ( // PLAIN: just plain read/write accesses ACCESS_PLAIN_READ AccessMode = 1 << iota ACCESS_PLAIN_WRITE // DEP: read/write relevant for dependencies ACCESS_DEP_READ ACCESS_DEP_WRITE // Combined values ACCESS_READ AccessMode = ACCESS_DEP_READ | ACCESS_PLAIN_READ ACCESS_WRITE AccessMode = ACCESS_DEP_WRITE | ACCESS_PLAIN_WRITE )
type CmdContext ¶
type CmdContext struct {
// contains filtered or unexported fields
}
type DCEBuilder ¶
type DCEBuilder struct {
// contains filtered or unexported fields
}
DCEBuilder tracks the data necessary to perform dead-command-eliminition on a capture
func NewDCEBuilder ¶
func NewDCEBuilder(graph DependencyGraph) *DCEBuilder
NewDCEBuilder creates a new DCEBuiler using the specified dependency graph
func (*DCEBuilder) BuffersCommands ¶
func (t *DCEBuilder) BuffersCommands() bool
func (*DCEBuilder) Build ¶
func (b *DCEBuilder) Build(ctx context.Context) error
Build runs the dead-code-elimination. The subcommands specified in cmds are marked alive, along with their transitive dependencies.
func (*DCEBuilder) Flush ¶
Flush is to comform the interface of Transformer. Flush performs DCE, and sends the live commands to the writer
func (*DCEBuilder) LiveCmdID ¶
func (b *DCEBuilder) LiveCmdID(oldCmdID api.CmdID) api.CmdID
LiveCmdID maps CmdIDs from the original capture to CmdIDs in within the live commands. If the old CmdID refers to a dead command, the returned command will refer to the next live command; if there is no next live command, api.CmdNoID is returned.
func (*DCEBuilder) LiveCmds ¶
func (b *DCEBuilder) LiveCmds() []api.Cmd
LiveCmds returns the live commands
func (*DCEBuilder) LogStats ¶
func (b *DCEBuilder) LogStats(ctx context.Context)
func (*DCEBuilder) NumLiveInitCmds ¶
func (b *DCEBuilder) NumLiveInitCmds() int
NumLiveInitiCmds returns the number of live commands which are initial commands. (Initial commands are generated commands to recreate the initial state).
func (*DCEBuilder) OriginalCmdID ¶
func (b *DCEBuilder) OriginalCmdID(liveCmdID api.CmdID) api.CmdID
OriginalCmdIDs maps a live CmdID to the CmdID of the corresponding command in the original capture
func (*DCEBuilder) PostLoop ¶
func (b *DCEBuilder) PostLoop(ctx context.Context, out transform.Writer)
func (*DCEBuilder) PreLoop ¶
func (b *DCEBuilder) PreLoop(ctx context.Context, out transform.Writer)
type DependencyGraph ¶
type DependencyGraph interface { // NumNodes returns the number of nodes in the graph NumNodes() int // NumDependencies returns the number of dependencies (edges) in the graph NumDependencies() uint64 // GetNode returns the node data associated with the given NodeID GetNode(NodeID) Node // GetNodeID returns the NodeID associated with given node data GetCmdNodeID(api.CmdID, api.SubCmdIdx) NodeID // GetCmdAncestorNodeIDs returns the NodeIDs associated with the ancestors of the // given subcommand. GetCmdAncestorNodeIDs(api.CmdID, api.SubCmdIdx) []NodeID // ForeachCmd iterates over all API calls in the graph. // If IncludeInitialCommands is true, this includes the initial commands // which reconstruct the initial state. // CmdIDs for initial commands are: // CmdID(0).Derived(), CmdID(1).Derived(), ... // Whether or not IncludeInitialCommands is true, the CmdIDs for captured // commands are: 0, 1, 2, ... ForeachCmd(ctx context.Context, cb func(context.Context, api.CmdID, api.Cmd) error) error // ForeachNode iterates over all nodes in the graph in chronological order. // I.e., the following order: // * For each initial command // * Read observation nodes for this command // * command node // * Write observation nodes for this command // * For each (non-initial) command // * Read observation nodes for this command // * command node // * Write observation nodes for this command ForeachNode(cb func(NodeID, Node) error) error // ForeachDependency iterates over all pairs (src, tgt), where src depends on tgt ForeachDependency(cb func(NodeID, NodeID) error) error // ForeachDependencyFrom iterates over all the nodes tgt, where src depends on tgt ForeachDependencyFrom(src NodeID, cb func(NodeID) error) error // ForeachDependencyTo iterates over all the nodes src, where src depends on tgt. // If Config().ReverseDependencies is false, this will return an error. ForeachDependencyTo(tgt NodeID, cb func(NodeID) error) error // Capture returns the capture whose dependencies are stored in this graph Capture() *capture.GraphicsCapture // GetUnopenedForwardDependencies returns the commands that have dependencies that // are not part of the capture. GetUnopenedForwardDependencies() []api.CmdID // GetCommand returns the command identified by the given CmdID GetCommand(api.CmdID) api.Cmd // NumInitialCommands returns the number of initial commands // (the commands needed to reconstruct the initial state before the // first command in the capture) NumInitialCommands() int GetNodeAccesses(NodeID) NodeAccesses // Config returns the config used to create this graph Config() DependencyGraphConfig }
DependencyGraph stores the dependencies among api calls and memory observations,
func BuildDependencyGraph ¶
func BuildDependencyGraph(ctx context.Context, config DependencyGraphConfig, c *capture.GraphicsCapture, initialCmds []api.Cmd, initialRanges interval.U64RangeList) (DependencyGraph, error)
func GetDependencyGraph ¶
func GetDependencyGraph(ctx context.Context, c *path.Capture, config DependencyGraphConfig) (DependencyGraph, error)
func TryGetDependencyGraph ¶
func TryGetDependencyGraph(ctx context.Context, c *path.Capture, config DependencyGraphConfig) (DependencyGraph, error)
type DependencyGraphConfig ¶
type DependencyGraphConfig struct { // MergeSubCmdNodes indicates whether the graph should have one node per // command (true), or a separate node for each subcommand (false) MergeSubCmdNodes bool // IncludeInitialCommands indicates whether nodes should be created for // the initial (state rebuild) commands IncludeInitialCommands bool // ReverseDependencies indicates whether reverse edges should be created ReverseDependencies bool SaveNodeAccesses bool }
Information about what sort of data to store in a dependency graph
type Distribution ¶
func (Distribution) Add ¶
func (d Distribution) Add(x uint64)
type ForwardAccess ¶
type ForwardAccess struct { Nodes *ForwardNodes DependencyID interface{} Mode ForwardAccessMode }
type ForwardAccessMode ¶
type ForwardAccessMode uint
const ( FORWARD_OPEN ForwardAccessMode = iota + 1 FORWARD_CLOSE FORWARD_DROP )
type ForwardNodes ¶
type ForwardWatcher ¶
type ForwardWatcher interface { OpenForwardDependency(ctx context.Context, cmdCtx CmdContext, dependencyID interface{}) CloseForwardDependency(ctx context.Context, cmdCtx CmdContext, dependencyID interface{}) DropForwardDependency(ctx context.Context, cmdCtx CmdContext, dependencyID interface{}) OnBeginCmd(ctx context.Context, cmdCtx CmdContext) OnEndCmd(ctx context.Context, cmdCtx CmdContext) Accesses OnBeginSubCmd(ctx context.Context, cmdCtx CmdContext, subCmdCtx CmdContext) OnEndSubCmd(ctx context.Context, cmdCtx CmdContext) }
type FragWatcher ¶
type FragWatcher interface { OnReadFrag(ctx context.Context, cmdCtx CmdContext, owner api.RefObject, f api.Fragment, v api.RefObject, track bool) OnWriteFrag(ctx context.Context, cmdCtx CmdContext, owner api.RefObject, f api.Fragment, old api.RefObject, new api.RefObject, track bool) OnBeginCmd(ctx context.Context, cmdCtx CmdContext) OnEndCmd(ctx context.Context, cmdCtx CmdContext) map[NodeID][]FragmentAccess OnBeginSubCmd(ctx context.Context, cmdCtx CmdContext, subCmdCtx CmdContext) OnEndSubCmd(ctx context.Context, cmdCtx CmdContext) GetStateRefs() map[api.RefID]RefFrag }
type FragmentAccess ¶
type GraphBuilder ¶
type GraphBuilder interface { AddDependencies(context.Context, map[NodeID][]FragmentAccess, map[NodeID][]MemoryAccess, map[NodeID][]ForwardAccess, bool) BuildReverseDependencies() GetCmdNodeID(api.CmdID, api.SubCmdIdx) NodeID GetOrCreateCmdNodeID(context.Context, api.CmdID, api.SubCmdIdx, api.Cmd) NodeID GetObsNodeIDs(api.CmdID, []api.CmdObservation, bool) []NodeID GetCmdContext(context.Context, api.CmdID, api.Cmd) CmdContext GetSubCmdContext(api.CmdID, api.SubCmdIdx) CmdContext GetNodeStats(NodeID) *NodeStats GetStats() *GraphBuilderStats GetGraph() *dependencyGraph OnBeginCmd(ctx context.Context, cmdCtx CmdContext) OnBeginSubCmd(ctx context.Context, cmdCtx CmdContext, subCmdCtx CmdContext, recordIdx api.RecordIdx) OnRecordSubCmd(ctx context.Context, cmdCtx CmdContext, recordIdx api.RecordIdx) }
type GraphBuilderStats ¶
type MemWatcher ¶
type MemWatcher interface { OnWriteSlice(ctx context.Context, cmdCtx CmdContext, s memory.Slice) OnReadSlice(ctx context.Context, cmdCtx CmdContext, s memory.Slice) OnWriteObs(ctx context.Context, cmdCtx CmdContext, obs []api.CmdObservation, nodes []NodeID) OnReadObs(ctx context.Context, cmdCtx CmdContext, obs []api.CmdObservation, nodes []NodeID) OnBeginCmd(ctx context.Context, cmdCtx CmdContext) OnEndCmd(ctx context.Context, cmdCtx CmdContext) map[NodeID][]MemoryAccess OnBeginSubCmd(ctx context.Context, cmdCtx CmdContext, subCmdCtx CmdContext) OnEndSubCmd(ctx context.Context, cmdCtx CmdContext) }
type MemoryAccess ¶
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node represents a node in the dependency graph, and holds data about the associated command or memory observation.
type NodeAccesses ¶
type NodeAccesses struct { FragmentAccesses []FragmentAccess MemoryAccesses []MemoryAccess ForwardAccesses []ForwardAccess ParentNode NodeID InitCmdNodes []NodeID }
type NodeIDSorter ¶
type NodeIDSorter struct {
Nodes []NodeID
}
NodeIDSorter is a structure to use for sorting NodeIDs in the sort package
func (*NodeIDSorter) Less ¶
func (s *NodeIDSorter) Less(i, j int) bool
Less returns trus if the elements at index i are less than j
func (*NodeIDSorter) Swap ¶
func (s *NodeIDSorter) Swap(i, j int)
Swap swaps the locations of 2 nodes in the list
type NodeStats ¶
type NodeStats struct { NumFragReads uint64 NumFragWrites uint64 NumMemReads uint64 NumMemWrites uint64 NumForwardDepOpens uint64 NumForwardDepCloses uint64 NumForwardDepDrops uint64 NumDeps uint64 NumFragDeps uint64 NumCompleteFragDeps uint64 NumMemDeps uint64 UniqueFragReads uint64 UniqueFragWrites uint64 UniqueMemReads uint64 UniqueMemWrites uint64 UniqueDeps uint64 }
type RecordNodeTrie ¶
type RecordNodeTrie struct {
api.SubCmdIdxTrie
}
func (*RecordNodeTrie) GetRecordNode ¶
func (t *RecordNodeTrie) GetRecordNode(recordIdx api.RecordIdx) NodeID
func (*RecordNodeTrie) SetRecordNode ¶
func (t *RecordNodeTrie) SetRecordNode(recordIdx api.RecordIdx, nodeID NodeID)