Matthew Poremba has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/57710 )
Change subject: gpu-compute: Command processor read path from device
......................................................................
gpu-compute: Command processor read path from device
In full system mode, the AMDKernelCode object can reside in either the
system memory or in the dGPU device memory. Currently only reading from
the host/system memory is supported. This adds the necessary code to
read from the dGPU device memory.
Change-Id: I887fc706b3f9834db14e40f36fd29dd3d4602925
---
M src/gpu-compute/gpu_command_processor.cc
1 file changed, 65 insertions(+), 7 deletions(-)
diff --git a/src/gpu-compute/gpu_command_processor.cc
b/src/gpu-compute/gpu_command_processor.cc
index 0e2ff50..1322130 100644
--- a/src/gpu-compute/gpu_command_processor.cc
+++ b/src/gpu-compute/gpu_command_processor.cc
@@ -39,6 +39,8 @@
#include "debug/GPUKernelInfo.hh"
#include "dev/amdgpu/amdgpu_device.hh"
#include "gpu-compute/dispatcher.hh"
+#include "mem/abstract_mem.hh"
+#include "mem/packet_access.hh"
#include "mem/se_translating_port_proxy.hh"
#include "mem/translating_port_proxy.hh"
#include "params/GPUCommandProcessor.hh"
@@ -77,12 +79,20 @@
TranslationGenPtr
GPUCommandProcessor::translate(Addr vaddr, Addr size)
{
- // Grab the process and try to translate the virtual address with it;
with
- // new extensions, it will likely be wrong to just arbitrarily grab
context
- // zero.
- auto process = sys->threads[0]->getProcessPtr();
+ if (!FullSystem) {
+ // Grab the process and try to translate the virtual address with
it;
+ // with new extensions, it will likely be wrong to just arbitrarily
+ // grab context zero.
+ auto process = sys->threads[0]->getProcessPtr();
- return process->pTable->translateRange(vaddr, size);
+ return process->pTable->translateRange(vaddr, size);
+ }
+
+ // In full system use the page tables setup by the kernel driver rather
+ // than the CPU page tables.
+ return TranslationGenPtr(
+ new AMDGPUVM::UserTranslationGen(&gpuDevice->getVM(), walker,
+ 1 /* vmid */, vaddr, size));
}
/**
@@ -120,6 +130,20 @@
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
/**
+ * In full system mode, the page table entry may point to a system page
+ * or a device page. System pages use the proxy as normal, but a device
+ * page needs to be read from device memory. Check what type it is
here.
+ */
+ bool is_system_page = true;
+ Addr phys_addr = disp_pkt->kernel_object;
+ if (FullSystem) {
+ unsigned tmp_bytes;
+ walker->startFunctional(gpuDevice->getVM().getPageTableBase(1),
+ phys_addr, tmp_bytes, BaseMMU::Mode::Read,
+ is_system_page);
+ }
+
+ /**
* The kernel_object is a pointer to the machine code, whose entry
* point is an 'amd_kernel_code_t' type, which is included in the
* kernel binary, and describes various aspects of the kernel. The
@@ -129,8 +153,28 @@
* instructions.
*/
AMDKernelCode akc;
- virt_proxy.readBlob(disp_pkt->kernel_object, (uint8_t*)&akc,
- sizeof(AMDKernelCode));
+ if (is_system_page) {
+ DPRINTF(GPUCommandProc, "kernel_object in system, using proxy\n");
+ virt_proxy.readBlob(disp_pkt->kernel_object, (uint8_t*)&akc,
+ sizeof(AMDKernelCode));
+ } else {
+ assert(FullSystem);
+ DPRINTF(GPUCommandProc, "kernel_object in device, using device
mem\n");
+ // Read from GPU memory manager
+ uint8_t raw_akc[sizeof(AMDKernelCode)];
+ for (int i = 0; i < sizeof(AMDKernelCode) / sizeof(uint8_t); ++i) {
+ Addr mmhubAddr = phys_addr + i*sizeof(uint8_t);
+ Request::Flags flags = Request::PHYSICAL;
+ RequestPtr request = std::make_shared<Request>(
+ mmhubAddr, sizeof(uint8_t), flags,
walker->getDevRequestor());
+ Packet *readPkt = new Packet(request, MemCmd::ReadReq);
+ readPkt->allocate();
+ system()->getDeviceMemory(readPkt)->access(readPkt);
+ raw_akc[i] = readPkt->getLE<uint8_t>();
+ delete readPkt;
+ }
+ memcpy(&akc, &raw_akc, sizeof(AMDKernelCode));
+ }
DPRINTF(GPUCommandProc, "GPU machine code is %lli bytes from start of
the "
"kernel object\n", akc.kernel_code_entry_byte_offset);
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57710
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I887fc706b3f9834db14e40f36fd29dd3d4602925
Gerrit-Change-Number: 57710
Gerrit-PatchSet: 1
Gerrit-Owner: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s