Matthew Poremba has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/53069 )

 (

6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
 )Change subject: dev-amdgpu: Add checkpoint support to AMDGPUDevice
......................................................................

dev-amdgpu: Add checkpoint support to AMDGPUDevice

These will be needed for the second checkpoint.

Change-Id: I85ee2cbc0df130868d19376c4d98dbe4d424698e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/53069
Reviewed-by: Matt Sinclair <mattdsincl...@gmail.com>
Maintainer: Matt Sinclair <mattdsincl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/dev/amdgpu/amdgpu_device.cc
1 file changed, 117 insertions(+), 0 deletions(-)

Approvals:
  Matt Sinclair: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/dev/amdgpu/amdgpu_device.cc b/src/dev/amdgpu/amdgpu_device.cc
index 81fe9f4..7ba4f91 100644
--- a/src/dev/amdgpu/amdgpu_device.cc
+++ b/src/dev/amdgpu/amdgpu_device.cc
@@ -437,6 +437,55 @@
 {
     // Serialize the PciDevice base class
     PciDevice::serialize(cp);
+
+    uint64_t regs_size = regs.size();
+    uint64_t doorbells_size = doorbells.size();
+    uint64_t sdma_engs_size = sdmaEngs.size();
+
+    SERIALIZE_SCALAR(regs_size);
+    SERIALIZE_SCALAR(doorbells_size);
+    SERIALIZE_SCALAR(sdma_engs_size);
+
+    // Make a c-style array of the regs to serialize
+    uint32_t reg_addrs[regs_size];
+    uint64_t reg_values[regs_size];
+    uint32_t doorbells_offset[doorbells_size];
+    QueueType doorbells_queues[doorbells_size];
+    uint32_t sdma_engs_offset[sdma_engs_size];
+    int sdma_engs[sdma_engs_size];
+
+    int idx = 0;
+    for (auto & it : regs) {
+        reg_addrs[idx] = it.first;
+        reg_values[idx] = it.second;
+        ++idx;
+    }
+
+    idx = 0;
+    for (auto & it : doorbells) {
+        doorbells_offset[idx] = it.first;
+        doorbells_queues[idx] = it.second;
+        ++idx;
+    }
+
+    idx = 0;
+    for (auto & it : sdmaEngs) {
+        sdma_engs_offset[idx] = it.first;
+        sdma_engs[idx] = it.second == sdma0 ? 0 : 1;
+        ++idx;
+    }
+
+    SERIALIZE_ARRAY(reg_addrs, sizeof(reg_addrs)/sizeof(reg_addrs[0]));
+    SERIALIZE_ARRAY(reg_values, sizeof(reg_values)/sizeof(reg_values[0]));
+    SERIALIZE_ARRAY(doorbells_offset, sizeof(doorbells_offset)/
+        sizeof(doorbells_offset[0]));
+    SERIALIZE_ARRAY(doorbells_queues, sizeof(doorbells_queues)/
+        sizeof(doorbells_queues[0]));
+    SERIALIZE_ARRAY(sdma_engs_offset, sizeof(sdma_engs_offset)/
+        sizeof(sdma_engs_offset[0]));
+    SERIALIZE_ARRAY(sdma_engs, sizeof(sdma_engs)/sizeof(sdma_engs[0]));
+
+    // Serialize the device memory
 }

 void
@@ -444,6 +493,59 @@
 {
     // Unserialize the PciDevice base class
     PciDevice::unserialize(cp);
+
+    uint64_t regs_size = 0;
+    uint64_t doorbells_size = 0;
+    uint64_t sdma_engs_size = 0;
+
+    UNSERIALIZE_SCALAR(regs_size);
+    UNSERIALIZE_SCALAR(doorbells_size);
+    UNSERIALIZE_SCALAR(sdma_engs_size);
+
+    if (regs_size > 0) {
+        uint32_t reg_addrs[regs_size];
+        uint64_t reg_values[regs_size];
+
+ UNSERIALIZE_ARRAY(reg_addrs, sizeof(reg_addrs)/sizeof(reg_addrs[0]));
+        UNSERIALIZE_ARRAY(reg_values,
+                          sizeof(reg_values)/sizeof(reg_values[0]));
+
+        for (int idx = 0; idx < regs_size; ++idx) {
+            regs.insert(std::make_pair(reg_addrs[idx], reg_values[idx]));
+        }
+    }
+
+    if (doorbells_size > 0) {
+        uint32_t doorbells_offset[doorbells_size];
+        QueueType doorbells_queues[doorbells_size];
+
+        UNSERIALIZE_ARRAY(doorbells_offset, sizeof(doorbells_offset)/
+                sizeof(doorbells_offset[0]));
+        UNSERIALIZE_ARRAY(doorbells_queues, sizeof(doorbells_queues)/
+                sizeof(doorbells_queues[0]));
+
+        for (int idx = 0; idx < doorbells_size; ++idx) {
+            regs.insert(std::make_pair(doorbells_offset[idx],
+                      doorbells_queues[idx]));
+            doorbells[doorbells_offset[idx]] = doorbells_queues[idx];
+        }
+    }
+
+    if (sdma_engs_size > 0) {
+        uint32_t sdma_engs_offset[sdma_engs_size];
+        int sdma_engs[sdma_engs_size];
+
+        UNSERIALIZE_ARRAY(sdma_engs_offset, sizeof(sdma_engs_offset)/
+            sizeof(sdma_engs_offset[0]));
+ UNSERIALIZE_ARRAY(sdma_engs, sizeof(sdma_engs)/sizeof(sdma_engs[0]));
+
+        for (int idx = 0; idx < sdma_engs_size; ++idx) {
+            SDMAEngine *sdma = sdma_engs[idx] == 0 ? sdma0 : sdma1;
+            sdmaEngs.insert(std::make_pair(sdma_engs_offset[idx], sdma));
+        }
+    }
+
+    // Unserialize the device memory
 }

 uint16_t

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/53069
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: I85ee2cbc0df130868d19376c4d98dbe4d424698e
Gerrit-Change-Number: 53069
Gerrit-PatchSet: 18
Gerrit-Owner: Alexandru Duțu <alexandru.d...@amd.com>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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

Reply via email to