Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/generators/spatterGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void SpatterGenerator::build(Params& params)
targetAddr = 0;

datawidth = params.find<uint32_t>("datawidth", 8);
cacheLine = params.find<uint64_t>("cache_line_size", 64);

maxWarmupRuns = params.find<uint32_t>("warmup_runs", 1);
remainingWarmupRuns = maxWarmupRuns;
Expand All @@ -63,8 +64,9 @@ void SpatterGenerator::build(Params& params)
out->fatal(CALL_INFO, -1, "Error: failed to parse provided arguments.\n");
}

startSource = params.find<uint32_t>("start_source", 0);
startTarget = params.find<uint32_t>("start_target", std::max(cl.sparse_size, cl.sparse_gather_size));
startSource = alignAddress(cacheLine, params.find<uint64_t>("start_source", 0));
startTarget = alignAddress(cacheLine, params.find<uint64_t>("start_target",
std::max(cl.sparse_size, cl.sparse_gather_size)));

if (startTarget > startSource) {
if (startTarget <= (startSource + std::max(cl.sparse_size, cl.sparse_gather_size) - 1)) {
Expand Down Expand Up @@ -312,6 +314,18 @@ bool SpatterGenerator::initConfigs(const std::string& args)
return (0 == result);
}

/**
* @brief Aligns an unaligned address to the next cache line.
*
* @param cacheLineSize Size of the cache line used to align the address.
* @param address Address to be cache line aligned.
* @return Address aligned to the next cache line if address was unaligned.
* Otherwise, returns the address as provided if already aligned.
*/
uint64_t SpatterGenerator::alignAddress(const uint64_t cacheLineSize, const uint64_t address) {
return (address + cacheLineSize - 1) / cacheLineSize * cacheLineSize;
}

/**
* @brief Return the number of elements in the pattern.
*
Expand Down
8 changes: 6 additions & 2 deletions src/generators/spatterGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class SpatterGenerator : public RequestGenerator {
{ "verbose", "Sets the verbosity of the output", "0" },
{ "args", "Sets the arguments to describe Spatter pattern(s)", "" },
{ "datawidth", "Sets the width of the memory operation", "8" },
{ "cache_line_size", "Size of the cache line the prefetcher is attached to", "64" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radelja - we wanted to note here that if the user doesn't want aligned addresses they may need to set this value to 1.

Copy link
Collaborator Author

@radelja radelja Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a new align_start_addresses argument instead of requiring cache_line_size to be set to 1 to not align the addresses.

{ "start_source", "Sets the start address of the source array", "0" },
{ "start_target", "Sets the start address of the target array", "0" },
{ "warmup_runs", "Sets the the number of warm-up runs", "1" }
Expand All @@ -71,6 +72,8 @@ class SpatterGenerator : public RequestGenerator {
void tokenizeArgs(const std::string &args, const int32_t &argc, char ***argv);
bool initConfigs(const std::string& args);

uint64_t alignAddress(const uint64_t cacheLineSize, const uint64_t address);

size_t getPatternSize(const Spatter::ConfigurationBase *config);
void updateIndices();

Expand All @@ -84,8 +87,9 @@ class SpatterGenerator : public RequestGenerator {
uint64_t sourceAddr;
uint64_t targetAddr;
uint32_t datawidth;
uint32_t startSource;
uint32_t startTarget;
uint64_t cacheLine;
uint64_t startSource;
uint64_t startTarget;
uint32_t maxWarmupRuns;
uint32_t remainingWarmupRuns;

Expand Down