-
Notifications
You must be signed in to change notification settings - Fork 9
/
context.go
51 lines (41 loc) · 927 Bytes
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package driver
import (
"sync"
"github.com/sarchlab/akita/v3/mem/vm"
)
type buffer struct {
vAddr Ptr
size uint64
freed bool
// After a kernel is launched, the l2 cache contain dirty data that belongs
// to this buffer. Therefore, copying from or to this buffer triggers L2
// flushing.
l2Dirty bool
}
// Context is an opaque struct that carries the information used by the driver.
type Context struct {
pid vm.PID
currentGPUID int
prevPageVAddr uint64
l2Dirty bool
queueMutex sync.Mutex
queues []*CommandQueue
buffers []*buffer
}
func (c *Context) markAllBuffersDirty() {
for _, b := range c.buffers {
b.l2Dirty = true
}
}
func (c *Context) markAllBuffersClean() {
for _, b := range c.buffers {
b.l2Dirty = false
}
}
func (c *Context) removeFreedBuffers() {
for i, b := range c.buffers {
if b.freed {
c.buffers = append(c.buffers[:i], c.buffers[i+1:]...)
}
}
}