cpu,stdlib: Fix Access Trace for Accessing Indices in SpatterGen (#1258)

This change fixes the way indices are generated in a multi generator
setup.
It changes it from all cores generating the same trace of indices for
accessing the index array to each core generating an interleaved subset
of indices.
For an example look below for traces (indices to index array) in a 2
core setup.

Before:
core_0: 0, 1, 2, 3, 4, 5, 6, 7, ...
core_1: 0, 1, 2, 3, 4, 5, 6, 7, ...
After:
core_0: 0, 1, 2, 3, 8, 9, 10, 11, ...
core_1: 4, 5, 6, 7, 12, 13, 14, 15, ...

Additionally, this change fixes the SpatterKernel class in the standard
library to comply with the change in the SpatterGen source code.
This commit is contained in:
Mahyar Samani
2024-06-20 11:24:44 -07:00
committed by GitHub
parent ed860dfe54
commit 7ff1e381c9
4 changed files with 50 additions and 8 deletions

View File

@@ -205,6 +205,7 @@ void
SpatterGen::addKernel(
uint32_t id, uint32_t delta, uint32_t count,
SpatterKernelType type,
uint32_t base_index, uint32_t indices_per_stride, uint32_t stride,
size_t index_size, Addr base_index_addr,
size_t value_size, Addr base_value_addr,
const std::vector<uint32_t>& indices
@@ -218,6 +219,7 @@ SpatterGen::addKernel(
SpatterKernel new_kernel(
requestorId,
id, delta, count, type,
base_index, indices_per_stride, stride,
index_size, base_index_addr,
value_size, base_value_addr
);

View File

@@ -234,11 +234,11 @@ class SpatterGen: public ClockedObject
void recvReqRetry();
bool recvTimingResp(PacketPtr pkt);
// PyBindMethod to interface adding a kernel with python JSON frontend.
void addKernel(
uint32_t id, uint32_t delta, uint32_t count,
SpatterKernelType type,
uint32_t base_index, uint32_t indices_per_stride, uint32_t stride,
size_t index_size, Addr base_index_addr,
size_t value_size, Addr base_value_addr,
const std::vector<uint32_t>& indices

View File

@@ -161,7 +161,38 @@ class SpatterKernel
typedef enums::SpatterKernelType SpatterKernelType;
typedef SpatterAccess::AccessPair AccessPair;
class IndexGen
{
private:
uint32_t indicesPerStride;
uint32_t stride;
uint32_t next;
public:
IndexGen(): indicesPerStride(0), stride(0), next(0)
{}
IndexGen(uint32_t base_index,
uint32_t indices_per_stride,
uint32_t stride_size):
indicesPerStride(indices_per_stride),
stride(stride_size), next(base_index)
{}
uint32_t nextIndex() {
uint32_t ret = next;
// update next index
next++;
if (next % indicesPerStride == 0) {
next += (stride - indicesPerStride);
}
return ret;
}
};
RequestorID requestorId;
IndexGen indexGen;
uint32_t _id;
uint32_t delta;
uint32_t count;
@@ -174,8 +205,6 @@ class SpatterKernel
size_t valueSize;
Addr baseValueAddr;
// needed to iterate over indices multiple times.
uint32_t index;
// current iteration over indices
uint32_t iteration;
@@ -189,15 +218,17 @@ class SpatterKernel
RequestorID requestor_id,
uint32_t id, uint32_t delta, uint32_t count,
SpatterKernelType type,
uint32_t base_index, uint32_t indices_per_stride, uint32_t stride,
size_t index_size, Addr base_index_addr,
size_t value_size, Addr base_value_addr
):
requestorId(requestor_id),
indexGen(base_index, indices_per_stride, stride),
_id(id), delta(delta), count(count),
_type(type),
indexSize(index_size), baseIndexAddr(base_index_addr),
valueSize(value_size), baseValueAddr(base_value_addr),
index(0), iteration(0), remRolls(0)
iteration(0), remRolls(0)
{}
uint32_t id() const { return _id; }
@@ -215,10 +246,10 @@ class SpatterKernel
SpatterAccess* nextSpatterAccess()
{
std::queue<AccessPair> access_pairs;
// get the next index for the index array
uint32_t index = indexGen.nextIndex();
Addr index_addr = baseIndexAddr + (index * indexSize);
access_pairs.emplace(index_addr, indexSize);
// update index in the index array
index++;
uint32_t front = indices.front();
uint32_t value_index = (delta * iteration) + front;