From 4d18546bfb24570ada5d524260c68d2eb3b92a63 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Mon, 22 May 2023 16:03:58 -0500 Subject: [PATCH] dev-amdgpu: Update SDMA checkpointing Patch https://gem5-review.googlesource.com/c/public/gem5/+/70040 added support for a variable number of SDMA engines to support newer GPU models. As part of this an SDMA IDs map was added to map from SDMA ID number to the SDMA SimObject pointer. In order to get the correct pointer in unserialize now, we need to store the ID in the checkpoint and use that to index the new map. We can't simply assign using the loop variable as the SDMAs might not be in order in the checkpoint and additionally the checkpoint contains both the gfx and page offset for the SDMA engines, so each SDMA is inserted into the SDMA offset map (sdmaEngs) twice. Change-Id: I08e9a8d785f467b6eebff8ab0a9336851c87258d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70878 Maintainer: Matt Sinclair Tested-by: kokoro Reviewed-by: Matt Sinclair --- src/dev/amdgpu/amdgpu_device.cc | 7 ++++--- src/dev/amdgpu/sdma_engine.hh | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dev/amdgpu/amdgpu_device.cc b/src/dev/amdgpu/amdgpu_device.cc index f58d1f7242..7037e6fb1c 100644 --- a/src/dev/amdgpu/amdgpu_device.cc +++ b/src/dev/amdgpu/amdgpu_device.cc @@ -604,7 +604,7 @@ AMDGPUDevice::serialize(CheckpointOut &cp) const idx = 0; for (auto & it : sdmaEngs) { sdma_engs_offset[idx] = it.first; - sdma_engs[idx] = idx; + sdma_engs[idx] = it.second->getId(); ++idx; } @@ -675,8 +675,9 @@ AMDGPUDevice::unserialize(CheckpointIn &cp) UNSERIALIZE_ARRAY(sdma_engs, sizeof(sdma_engs)/sizeof(sdma_engs[0])); for (int idx = 0; idx < sdma_engs_size; ++idx) { - assert(sdmaIds.count(idx)); - SDMAEngine *sdma = sdmaIds[idx]; + int sdma_id = sdma_engs[idx]; + assert(sdmaIds.count(sdma_id)); + SDMAEngine *sdma = sdmaIds[sdma_id]; sdmaEngs.insert(std::make_pair(sdma_engs_offset[idx], sdma)); } } diff --git a/src/dev/amdgpu/sdma_engine.hh b/src/dev/amdgpu/sdma_engine.hh index 1e4f965920..bcbd497e8a 100644 --- a/src/dev/amdgpu/sdma_engine.hh +++ b/src/dev/amdgpu/sdma_engine.hh @@ -165,6 +165,7 @@ class SDMAEngine : public DmaVirtDevice void setGPUDevice(AMDGPUDevice *gpu_device); void setId(int _id) { id = _id; } + int getId() const { return id; } /** * Returns the client id for the Interrupt Handler. */