dev-amdgpu: Add memory manager readRequest method
This method reads arbitrary sized requests from *device* memory with the ability to call a callback after the last chunk, similar to writeRequest method. Change-Id: I8fc22c45b650a632ea48dbed1e978ceeda34ffdd Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62712 Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com> Maintainer: Matt Sinclair <mattdsinclair@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -82,6 +82,35 @@ AMDGPUMemoryManager::writeRequest(Addr addr, uint8_t *data, int size,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AMDGPUMemoryManager::readRequest(Addr addr, uint8_t *data, int size,
|
||||
Request::Flags flag, Event *callback)
|
||||
{
|
||||
assert(data);
|
||||
uint8_t *dataPtr = data;
|
||||
|
||||
ChunkGenerator gen(addr, size, cacheLineSize);
|
||||
for (; !gen.done(); gen.next()) {
|
||||
RequestPtr req = std::make_shared<Request>(gen.addr(), gen.size(),
|
||||
flag, _requestorId);
|
||||
|
||||
PacketPtr pkt = Packet::createRead(req);
|
||||
pkt->dataStatic<uint8_t>(dataPtr);
|
||||
dataPtr += gen.size();
|
||||
|
||||
// Only issue the callback on the last request completing
|
||||
pkt->pushSenderState(new GPUMemPort::SenderState(
|
||||
gen.last() ? callback : nullptr, addr));
|
||||
|
||||
if (!_gpuMemPort.sendTimingReq(pkt)) {
|
||||
DPRINTF(AMDGPUMem, "Request to %#lx needs retry\n", gen.addr());
|
||||
_gpuMemPort.retries.push_back(pkt);
|
||||
} else {
|
||||
DPRINTF(AMDGPUMem, "Read request to %#lx sent\n", gen.addr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AMDGPUMemoryManager::GPUMemPort::recvTimingResp(PacketPtr pkt)
|
||||
{
|
||||
|
||||
@@ -89,6 +89,19 @@ class AMDGPUMemoryManager : public ClockedObject
|
||||
void writeRequest(Addr addr, uint8_t *data, int size,
|
||||
Request::Flags flag = 0, Event *callback = nullptr);
|
||||
|
||||
/**
|
||||
* Read size amount of data from device memory at addr using flags and
|
||||
* callback.
|
||||
*
|
||||
* @param addr Device address to read.
|
||||
* @param data Pointer to data to read into.
|
||||
* @param size Number of bytes to read.
|
||||
* @param flag Additional request flags for read packets.
|
||||
* @param callback Event callback to call after all bytes are read.
|
||||
*/
|
||||
void readRequest(Addr addr, uint8_t *data, int size,
|
||||
Request::Flags flag = 0, Event *callback = nullptr);
|
||||
|
||||
/**
|
||||
* Get the requestorID for the memory manager. This ID is used for all
|
||||
* packets which should be routed through the device network.
|
||||
|
||||
Reference in New Issue
Block a user