From 75035f5674df3e497d69404a9093b852d2ccf7aa Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Mon, 15 Oct 2018 12:25:25 +0200 Subject: mem-ruby: Use Packet writing functions instead of memcpy Classes were using memcpy instead of the Packet functions created for writing to/from the packet. This allows these writes to be better checked and tracked. Change-Id: Iae3fba1351330916ee1d4103809c71e151b1639e Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/13915 Reviewed-by: Nikos Nikoleris Reviewed-by: Jason Lowe-Power Maintainer: Nikos Nikoleris --- src/mem/ruby/slicc_interface/AbstractController.cc | 11 ++++------- src/mem/ruby/system/GPUCoalescer.cc | 12 ++++-------- src/mem/ruby/system/Sequencer.cc | 13 +++++-------- 3 files changed, 13 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc b/src/mem/ruby/slicc_interface/AbstractController.cc index de7e03dd7..101a4ce7f 100644 --- a/src/mem/ruby/slicc_interface/AbstractController.cc +++ b/src/mem/ruby/slicc_interface/AbstractController.cc @@ -268,10 +268,8 @@ AbstractController::queueMemoryWrite(const MachineID &id, Addr addr, addr, RubySystem::getBlockSizeBytes(), 0, m_masterId); PacketPtr pkt = Packet::createWrite(req); - uint8_t *newData = new uint8_t[RubySystem::getBlockSizeBytes()]; - pkt->dataDynamic(newData); - memcpy(newData, block.getData(0, RubySystem::getBlockSizeBytes()), - RubySystem::getBlockSizeBytes()); + pkt->allocate(); + pkt->setData(block.getData(0, RubySystem::getBlockSizeBytes())); SenderState *s = new SenderState(id); pkt->pushSenderState(s); @@ -295,9 +293,8 @@ AbstractController::queueMemoryWritePartial(const MachineID &id, Addr addr, RequestPtr req = std::make_shared(addr, size, 0, m_masterId); PacketPtr pkt = Packet::createWrite(req); - uint8_t *newData = new uint8_t[size]; - pkt->dataDynamic(newData); - memcpy(newData, block.getData(getOffset(addr), size), size); + pkt->allocate(); + pkt->setData(block.getData(getOffset(addr), size)); SenderState *s = new SenderState(id); pkt->pushSenderState(s); diff --git a/src/mem/ruby/system/GPUCoalescer.cc b/src/mem/ruby/system/GPUCoalescer.cc index e17bf63fd..8b8c9566f 100644 --- a/src/mem/ruby/system/GPUCoalescer.cc +++ b/src/mem/ruby/system/GPUCoalescer.cc @@ -640,10 +640,8 @@ GPUCoalescer::hitCallback(GPUCoalescerRequest* srequest, (type == RubyRequestType_RMW_Read) || (type == RubyRequestType_Locked_RMW_Read) || (type == RubyRequestType_Load_Linked)) { - memcpy(pkt->getPtr(), - data.getData(getOffset(request_address), - pkt->getSize()), - pkt->getSize()); + pkt->setData( + data.getData(getOffset(request_address), pkt->getSize())); } else { data.setData(pkt->getPtr(), getOffset(request_address), pkt->getSize()); @@ -1097,10 +1095,8 @@ GPUCoalescer::atomicCallback(Addr address, if (pkt->getPtr() && srequest->m_type != RubyRequestType_ATOMIC_NO_RETURN) { /* atomics are done in memory, and return the data *before* the atomic op... */ - memcpy(pkt->getPtr(), - data.getData(getOffset(request_address), - pkt->getSize()), - pkt->getSize()); + pkt->setData( + data.getData(getOffset(request_address), pkt->getSize())); } else { DPRINTF(MemoryAccess, "WARNING. Data not transfered from Ruby to M5 for type " \ diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc index f30369710..41ec6ea6c 100644 --- a/src/mem/ruby/system/Sequencer.cc +++ b/src/mem/ruby/system/Sequencer.cc @@ -476,17 +476,14 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data, (type == RubyRequestType_RMW_Read) || (type == RubyRequestType_Locked_RMW_Read) || (type == RubyRequestType_Load_Linked)) { - memcpy(pkt->getPtr(), - data.getData(getOffset(request_address), pkt->getSize()), - pkt->getSize()); + pkt->setData( + data.getData(getOffset(request_address), pkt->getSize())); DPRINTF(RubySequencer, "read data %s\n", data); } else if (pkt->req->isSwap()) { std::vector overwrite_val(pkt->getSize()); - memcpy(&overwrite_val[0], pkt->getConstPtr(), - pkt->getSize()); - memcpy(pkt->getPtr(), - data.getData(getOffset(request_address), pkt->getSize()), - pkt->getSize()); + pkt->writeData(&overwrite_val[0]); + pkt->setData( + data.getData(getOffset(request_address), pkt->getSize())); data.setData(&overwrite_val[0], getOffset(request_address), pkt->getSize()); DPRINTF(RubySequencer, "swap data %s\n", data); -- cgit v1.2.3