-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support a Separate GMMU Page Table #109
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ type Builder struct { | |
useMagicMemoryCopy bool | ||
middlewareD2HCycles int | ||
middlewareH2DCycles int | ||
memorySize uint64 | ||
} | ||
|
||
// MakeBuilder creates a driver builder with some default configuration | ||
|
@@ -74,6 +75,12 @@ func (b Builder) WithH2DCycles(h2dCycles int) Builder { | |
return b | ||
} | ||
|
||
// WithMemorySize sets the memory size of the CPU. | ||
func (b Builder) WithMemorySize(memorySize uint64) Builder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, since this is for CPU, can we just say |
||
b.memorySize = memorySize | ||
return b | ||
} | ||
|
||
// Build creates a driver. | ||
func (b Builder) Build(name string) *Driver { | ||
driver := new(Driver) | ||
|
@@ -125,7 +132,7 @@ func (b *Builder) createCPU(d *Driver) { | |
Type: internal.DeviceTypeCPU, | ||
MemState: internal.NewDeviceMemoryState(d.Log2PageSize), | ||
} | ||
cpu.SetTotalMemSize(4 * mem.GB) | ||
cpu.SetTotalMemSize(b.memorySize) | ||
|
||
d.memAllocator.RegisterDevice(cpu) | ||
d.devices = append(d.devices, cpu) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package driver | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"reflect" | ||
"runtime/debug" | ||
|
@@ -142,6 +143,7 @@ type DeviceProperties struct { | |
func (d *Driver) RegisterGPU( | ||
commandProcessorPort sim.Port, | ||
properties DeviceProperties, | ||
gmmuPageTable vm.PageTable, | ||
) { | ||
d.GPUs = append(d.GPUs, commandProcessorPort) | ||
|
||
|
@@ -156,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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this required? I think, at the beginning, no page has already been allocated. |
||
if page.DeviceID == uint64(gpuDevice.ID) { | ||
gmmuPageTable.Insert(page) | ||
} | ||
} | ||
} | ||
|
||
// Tick ticks | ||
|
@@ -455,6 +462,9 @@ func (d *Driver) distributeWGToGPUs( | |
panic("not all wg allocated") | ||
} | ||
|
||
// fmt.Sprintln("total WG: %d WG Per CU %d\n", totalWGCount, wgPerCU) | ||
fmt.Printf("total WG: %d WG Per CU %d\n", totalWGCount, wgPerCU) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove prints |
||
|
||
return wgDist | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ type MemoryAllocator interface { | |
vAddr uint64, | ||
unified bool, | ||
) vm.Page | ||
|
||
GetVAddrToPageMapping() map[uint64]vm.Page | ||
} | ||
|
||
// NewMemoryAllocator creates a new memory allocator. | ||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About empty lines. Please consider these general rules. 1. Add an empty line after defer. 2. Add an empty line before |
||
copy[vAddr] = page | ||
} | ||
return copy | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,9 @@ func (b Builder) Build(name string) *CommandProcessor { | |
tracing.CollectTrace(cp, b.visTracer) | ||
} | ||
|
||
if b.perfAnalyzer != nil { | ||
b.perfAnalyzer.RegisterComponent(cp) | ||
} | ||
// if b.perfAnalyzer != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there some problem with |
||
// b.perfAnalyzer.RegisterComponent(cp) | ||
// } | ||
|
||
return cp | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this one as
cpuMemorySize
to avoid confusion?