Documentation
¶
Overview ¶
Package cudataskgraph validates finite task DAGs and tracks epoch-scoped publication and abort state.
This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/host/taskgraph"
)
func main() {
g, _ := taskgraph.New([]taskgraph.Task{{ID: "p", Rank: 0, Scope: taskgraph.ScopeCTA}})
fmt.Println(len(g.Tasks()))
}
Output: 1
Index ¶
- type Epoch
- func (e *Epoch) Abort()
- func (e *Epoch) Aborted() bool
- func (e *Epoch) Claim(id string, g Graph) error
- func (e *Epoch) Clone() *Epoch
- func (e *Epoch) Drain()
- func (e *Epoch) Drained() bool
- func (e *Epoch) Publish(id string, g Graph) error
- func (e *Epoch) PublishEpoch(epoch uint64, id string, g Graph) error
- func (e *Epoch) Published(id string) bool
- func (e *Epoch) Release(id string) error
- func (e *Epoch) Retained() []string
- type Graph
- type Scope
- type Task
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Epoch ¶
type Epoch struct {
Number uint64
// contains filtered or unexported fields
}
func (*Epoch) Clone ¶
Clone returns an independent snapshot of the epoch, including its publication and ownership records. Later changes to either epoch do not affect the other. Like the other epoch methods, Clone does not synchronize direct assignments to the public Number field.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/host/taskgraph"
)
func main() {
e := taskgraph.NewEpoch(1)
clone := e.Clone()
clone.Abort()
fmt.Println(e.Aborted(), clone.Aborted())
}
Output: false true
func (*Epoch) Drain ¶
func (e *Epoch) Drain()
Drain records that the host has observed the launch finish, so nothing is still storing into the claimed buffers.
func (*Epoch) PublishEpoch ¶
PublishEpoch publishes a completion only for the epoch that owns it.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func (Graph) Identity ¶
Identity returns a stable identity for the validated graph: every task's ID, rank, shared-memory bytes, scope, extent, dependencies and data inputs, in task order.
Each string and list is written with its length before it, so no arrangement of bytes inside an ID can be read as a field of another task.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/x/host/taskgraph"
)
func main() {
build := func(inputs []string, extent uint64) string {
g, err := taskgraph.New([]taskgraph.Task{
{ID: "x", Rank: 0, Scope: taskgraph.ScopeDevice},
{ID: "y", Rank: 0, Scope: taskgraph.ScopeDevice},
{ID: "sum", Deps: []string{"x", "y"}, Inputs: inputs, Rank: 1, Scope: taskgraph.ScopeDevice, Extent: extent},
})
if err != nil {
return err.Error()
}
return g.Identity()
}
first := build([]string{"x"}, 256)
fmt.Println(first == build([]string{"x", "y"}, 256))
fmt.Println(first == build([]string{"x"}, 512))
fmt.Println(first == build([]string{"x"}, 256))
}
Output: false false true
type Task ¶
type Task struct {
ID string
Deps []string
// Inputs names the dependencies whose outputs the task reads, in operand
// order. Each must also appear in Deps, at most once; a dependency not
// named here orders the task without supplying it data.
//
// An empty Inputs declares nothing. Consumers that predate this field
// read such a task's first dependency, if any, as its only data input.
Inputs []string
Rank int
// Bytes is the task's dynamic shared-memory claim, in bytes. It is not
// the size of the task's output and not a cost: a scheduler that reads
// it as either will rank tasks by a quantity that says nothing about
// them. The megakernel executor budgets it against the shared memory the
// compiled worker admits (cudamega.Progress); apart from that it is only
// hashed into the graph fingerprint.
Bytes uint64
Scope Scope
// Extent is the number of elements the task produces. Zero means the
// extent is undeclared, not that the task is empty. New records Extent
// in the identity but checks it against nothing; whoever runs the task
// decides whether the elements it is given match.
Extent uint64
}