Skip to content

Commit

Permalink
Continue footprint building even if an error occur in another API com…
Browse files Browse the repository at this point in the history
…mand (#1256)

* Continue footprint building even if an error occur in another API command

* Remove error log for faults in a trace, make sure don't crash due to out-of-bound in the behavior list, fallback to dce disabled mode if dependency tracking info is broken.
  • Loading branch information
Qining authored Oct 25, 2017
1 parent a1c3484 commit e2d132f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions gapis/api/transform/dce.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (s *commandIndicesSet) contains(fci api.SubCmdIdx) bool {
type DCE struct {
footprint *dependencygraph.Footprint
endBehaviorIndex uint64
endCmdIndex api.CmdID
requests *commandIndicesSet
requestCount uint64
}
Expand All @@ -90,6 +91,9 @@ func (t *DCE) Request(ctx context.Context, fci api.SubCmdIdx) {
if bi > t.endBehaviorIndex {
t.endBehaviorIndex = bi
}
if api.CmdID(fci[0]) > t.endCmdIndex {
t.endCmdIndex = api.CmdID(fci[0])
}
}

// Transform is to comform the interface of Transformer, but does not accept
Expand All @@ -106,6 +110,15 @@ func (t *DCE) Transform(ctx context.Context, id api.CmdID, c api.Cmd,
// the alive commands to the following transforms to mutate them and write them
// to build instructions for replay.
func (t *DCE) Flush(ctx context.Context, out Writer) {
if t.endBehaviorIndex >= uint64(len(t.footprint.Behaviors)) {
log.E(ctx, "DCE: Cannot backpropagate through def-use chain from behavior index: %v, "+
"with length of behavior list: %v.", t.endBehaviorIndex, len(t.footprint.Behaviors))
log.W(ctx, "DCE: Fallback to disable DCE.")
for i := api.CmdID(0); i <= t.endCmdIndex; i++ {
out.MutateAndWrite(ctx, i, t.footprint.Commands[int(i)])
}
return
}
t0 := dCECounter.Start()
livenessBoard, aliveCmds := t.backPropagate(ctx)
dCECounter.Stop(t0)
Expand Down
3 changes: 2 additions & 1 deletion gapis/api/vulkan/footprint_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,8 @@ func (vb *FootprintBuilder) BuildFootprint(ctx context.Context,

// Mutate
if err := cmd.Mutate(ctx, id, s, nil); err != nil {
log.E(ctx, "Command %v %v: %v", id, cmd, err)
// Continue the footprint building without emitting errors here. It is the
// following mutate() calls' responsibility to catch the error.
return
}

Expand Down
6 changes: 4 additions & 2 deletions gapis/resolve/dependencygraph/footprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (f *Footprint) BehaviorIndex(ctx context.Context,
if u, ok := v.(uint64); ok {
return u
}
log.E(ctx, "Invalid behavior index: %v is not a uint64", v)
log.E(ctx, "Invalid behavior index: %v is not a uint64. Request command index: %v", v, fci)
return uint64(0)
}
log.E(ctx, "Cannot get behavior index for command indexed with: %v", fci)
Expand Down Expand Up @@ -229,8 +229,10 @@ func (r *FootprintResolvable) Resolve(ctx context.Context) (interface{}, error)
// side effect of the this command.
if err := cmd.Mutate(ctx, id, s, nil); err != nil {
bh.Aborted = true
// Continue the footprint building even if errors are found. It is
// following mutate calls, which are to build the replay
// instructions, that are responsible to catch the error.
// TODO: This error should be moved to report view.
return fmt.Errorf("Command %v %v: %v", id, cmd, err)
}
ft.AddBehavior(ctx, bh)
return nil
Expand Down

0 comments on commit e2d132f

Please sign in to comment.