Skip to content

Commit

Permalink
workd except compile warn
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu committed Nov 11, 2024
1 parent 98aac95 commit 260d72a
Show file tree
Hide file tree
Showing 2 changed files with 312 additions and 112 deletions.
49 changes: 44 additions & 5 deletions benchmarks/babelstream/src/babelStreamCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace
// To prevent timeouts in CI, a smaller default value is used.
[[maybe_unused]] auto arraySizeMain = 1024 * 1024;


// Minimum array size to be used.
[[maybe_unused]] constexpr auto minArrSize = 1024 * 128;

Expand All @@ -39,8 +40,19 @@ namespace
// To prevent timeouts in CI, a small value is used.
[[maybe_unused]] auto numberOfRuns = 2;

// Data input value for babelstream.
// Data input values for babelstream.
[[maybe_unused]] constexpr double valA = 0.1;
[[maybe_unused]] constexpr double valB = 0.2;
[[maybe_unused]] constexpr double valC = 0.2;

enum class KernelsToRun
{
All, // init, add, copy, mul, triad
Triad, // only init and triad
NStream // only init and nstream
};

[[maybe_unused]] KernelsToRun kernelsToBeExecuted{KernelsToRun::All};

//! handleCustomArguments Gets custom cmd line arguments from the all arguments.
//! Namely gets --array-size=1234 and --number-runs=1234 and keeps the others which are
Expand Down Expand Up @@ -80,6 +92,26 @@ namespace
std::cout << "Using default number of runs: " << numberOfRuns << std::endl;
}
}
else if(arg.rfind("--run-kernels=", 0) == 0)
{
auto const kernelsString = std::string(arg.substr(14)); // Convert to integer
if(kernelsString == "nstream")
{
std::cout << "Only nstream kernel will be executed." << std::endl;
kernelsToBeExecuted = KernelsToRun::NStream;
}
else if(kernelsString == "triad")
{
kernelsToBeExecuted = KernelsToRun::Triad;
std::cout << "Only triad kernel will be executed." << std::endl;
}
else if(kernelsString == "all")
{
// The variable kernelsToBeExecuted default value is "all";
kernelsToBeExecuted = KernelsToRun::All;
std::cout << "All 5 babelstream kernels are going to be executed." << std::endl;
}
}
else
{
// If it's not a custom argument, keep it for Catch2
Expand All @@ -90,6 +122,10 @@ namespace
std::cout << "Usage of custom arguments (arguments which are not Catch2): --array-size=33554432 and "
"--number-runs=100"
<< std::endl;
std::cout << "If you want to run only nstream kernel or triad kernel use --run-kernels=nstream or "
"--run-kernels=triad. Otherwise all 5 standar kernels will be run. Init, Copy, Mul, Add, "
"Triad. (and Dot if multithreaded acc is set)"
<< std::endl;
}
}

Expand Down Expand Up @@ -220,6 +256,7 @@ namespace
WorkDivTriad,
WorkDivMult,
WorkDivDot,
WorkDivNStream,
DeviceName,
TimeUnit,
KernelNames,
Expand Down Expand Up @@ -354,11 +391,13 @@ namespace
{
std::stringstream ss;
// define lambda to add values to a string stream created already
auto addItemValue = [&, this](BMInfoDataType item) {
ss << "\n" << typeToTypeStr(item) << ":" << metaDataMap.at(item);
auto addItemValue = [&, this](BMInfoDataType item)
{
if(metaDataMap.count(item) != 0)
ss << "\n" << typeToTypeStr(item) << ":" << metaDataMap.at(item);
};

// Initially chose some data to serialize
// Initially chose some data to serialize from the meta-data map to add to string stream
ss << "\n";
addItemValue(BMInfoDataType::AcceleratorType);
addItemValue(BMInfoDataType::NumRuns);
Expand All @@ -372,7 +411,7 @@ namespace
addItemValue(BMInfoDataType::WorkDivTriad);
if(metaDataMap.count(BMInfoDataType::WorkDivDot) != 0)
addItemValue(BMInfoDataType::WorkDivDot);

addItemValue(BMInfoDataType::WorkDivNStream);
auto getItemFromStrList = [this](BMInfoDataType item, int index) -> std::string
{
std::string const str = metaDataMap.at(item);
Expand Down
Loading

0 comments on commit 260d72a

Please sign in to comment.