Skip to content

Commit

Permalink
Enable Separate GMMU Page Table Support
Browse files Browse the repository at this point in the history
  • Loading branch information
YuWei-CH committed Nov 1, 2024
1 parent 00ebf5b commit 8da82c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type DeviceProperties struct {
func (d *Driver) RegisterGPU(
commandProcessorPort sim.Port,
properties DeviceProperties,
gmmuPageTable vm.PageTable,
) {
d.GPUs = append(d.GPUs, commandProcessorPort)

Expand All @@ -157,8 +158,13 @@ func (d *Driver) RegisterGPU(
}
gpuDevice.SetTotalMemSize(properties.DRAMSize)
d.memAllocator.RegisterDevice(gpuDevice)

d.devices = append(d.devices, gpuDevice)

for _, page := range d.memAllocator.GetVAddrToPageMapping() {
if page.DeviceID == uint64(gpuDevice.ID) {
gmmuPageTable.Insert(page)
}
}
}

// Tick ticks
Expand Down
12 changes: 12 additions & 0 deletions driver/internal/memoryallocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type MemoryAllocator interface {
vAddr uint64,
unified bool,
) vm.Page

GetVAddrToPageMapping() map[uint64]vm.Page
}

// NewMemoryAllocator creates a new memory allocator.
Expand Down Expand Up @@ -285,3 +287,13 @@ func (a *memoryAllocatorImpl) Free(ptr uint64) {

a.removePage(ptr)
}

func (a *memoryAllocatorImpl) GetVAddrToPageMapping() map[uint64]vm.Page {
a.Lock()
defer a.Unlock()
copy := make(map[uint64]vm.Page, len(a.vAddrToPageMapping))
for vAddr, page := range a.vAddrToPageMapping {
copy[vAddr] = page
}
return copy
}

0 comments on commit 8da82c3

Please sign in to comment.