Kyle Roarty has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/34677 )
Change subject: gpu-compute: replace uint32_t* casts with bits API calls
......................................................................
gpu-compute: replace uint32_t* casts with bits API calls
The uint32_t* casting was challenging to fully understand what was
being done at a glance. Replaced with calls to various bits functions
as it's functionally equivalent and much more clear.
This also fixes a segfault in GPUInitAbi DPRINTFs from a mis-typed
uint32_t* cast.
Change-Id: Id5d1863942848dd7a9e5e17e8180c33adbc72f15
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34677
Reviewed-by: Anthony Gutierrez <[email protected]>
Reviewed-by: Matt Sinclair <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Anthony Gutierrez <[email protected]>
Maintainer: Matt Sinclair <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/gpu-compute/fetch_unit.cc
M src/gpu-compute/wavefront.cc
2 files changed, 16 insertions(+), 13 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved
Anthony Gutierrez: Looks good to me, approved; Looks good to me, approved
Matt Sinclair: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/gpu-compute/fetch_unit.cc b/src/gpu-compute/fetch_unit.cc
index 098b783..5d98288 100644
--- a/src/gpu-compute/fetch_unit.cc
+++ b/src/gpu-compute/fetch_unit.cc
@@ -33,6 +33,7 @@
#include "gpu-compute/fetch_unit.hh"
+#include "base/bitfield.hh"
#include "debug/GPUFetch.hh"
#include "debug/GPUPort.hh"
#include "debug/GPUTLB.hh"
@@ -576,7 +577,8 @@
int num_dwords = sizeof(TheGpuISA::RawMachInst) / dword_size;
for (int i = 0; i < num_dwords; ++i) {
- ((uint32_t*)(&split_inst))[i] =
*reinterpret_cast<uint32_t*>(readPtr);
+ replaceBits(split_inst, 32*(i+1)-1, 32*i,
+ *reinterpret_cast<uint32_t*>(readPtr));
if (readPtr + dword_size >= bufEnd) {
readPtr = bufStart;
}
diff --git a/src/gpu-compute/wavefront.cc b/src/gpu-compute/wavefront.cc
index 0e737db..dd914ca 100644
--- a/src/gpu-compute/wavefront.cc
+++ b/src/gpu-compute/wavefront.cc
@@ -33,6 +33,7 @@
#include "gpu-compute/wavefront.hh"
+#include "base/bitfield.hh"
#include "debug/GPUExec.hh"
#include "debug/GPUInitAbi.hh"
#include "debug/WavefrontStack.hh"
@@ -257,23 +258,23 @@
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&host_disp_pkt_addr)[0]);
+ bits(host_disp_pkt_addr, 31, 0));
++regInitIdx;
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting DispatchPtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)&host_disp_pkt_addr)[0]);
+ bits(host_disp_pkt_addr, 31, 0));
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&host_disp_pkt_addr)[1]);
+ bits(host_disp_pkt_addr, 63, 32));
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting DispatchPtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)&host_disp_pkt_addr)[1]);
+ bits(host_disp_pkt_addr, 63, 32));
++regInitIdx;
break;
@@ -281,23 +282,23 @@
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&task->hostAMDQueueAddr)[0]);
+ bits(task->hostAMDQueueAddr, 31, 0));
++regInitIdx;
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting QueuePtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)&task->hostAMDQueueAddr)[0]);
+ bits(task->hostAMDQueueAddr, 31, 0));
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&task->hostAMDQueueAddr)[1]);
+ bits(task->hostAMDQueueAddr, 63, 32));
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting QueuePtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)&task->hostAMDQueueAddr)[1]);
+ bits(task->hostAMDQueueAddr, 63, 32));
++regInitIdx;
break;
@@ -305,23 +306,23 @@
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&kernarg_addr)[0]);
+ bits(kernarg_addr, 31, 0));
++regInitIdx;
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting KernargSegPtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)kernarg_addr)[0]);
+ bits(kernarg_addr, 31, 0));
physSgprIdx =
computeUnit->registerManager->mapSgpr(this,
regInitIdx);
computeUnit->srf[simdId]->write(physSgprIdx,
- ((uint32_t*)&kernarg_addr)[1]);
+ bits(kernarg_addr, 63, 32));
DPRINTF(GPUInitAbi, "CU%d: WF[%d][%d]: wave[%d] "
"Setting KernargSegPtr: s[%d] = %x\n",
computeUnit->cu_id, simdId,
wfSlotId, wfDynId, physSgprIdx,
- ((uint32_t*)kernarg_addr)[1]);
+ bits(kernarg_addr, 63, 32));
++regInitIdx;
break;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34677
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: Id5d1863942848dd7a9e5e17e8180c33adbc72f15
Gerrit-Change-Number: 34677
Gerrit-PatchSet: 3
Gerrit-Owner: Kyle Roarty <[email protected]>
Gerrit-Reviewer: Anthony Gutierrez <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Kyle Roarty <[email protected]>
Gerrit-Reviewer: Matt Sinclair <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-CC: Alexandru Duțu <[email protected]>
Gerrit-CC: Matthew Poremba <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s