Add option to run nstream in isolation
This commit is contained in:
parent
9715ffff27
commit
a6f23ba900
75
main.cpp
75
main.cpp
@ -58,13 +58,11 @@ void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void run_triad();
|
|
||||||
|
|
||||||
// Options for running the benchmark:
|
// Options for running the benchmark:
|
||||||
// - All 5 kernels (Copy, Add, Mul, Triad, Dot).
|
// - All 5 kernels (Copy, Add, Mul, Triad, Dot).
|
||||||
// - Triad only.
|
// - Triad only.
|
||||||
enum class Benchmark {All, Triad};
|
// - Nstream only.
|
||||||
|
enum class Benchmark {All, Triad, Nstream};
|
||||||
|
|
||||||
// Selected run options.
|
// Selected run options.
|
||||||
Benchmark selection = Benchmark::All;
|
Benchmark selection = Benchmark::All;
|
||||||
@ -166,6 +164,27 @@ std::vector<std::vector<double>> run_triad(Stream<T> *stream)
|
|||||||
return timings;
|
return timings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run the Nstream kernel
|
||||||
|
template <typename T>
|
||||||
|
std::vector<std::vector<double>> run_nstream(Stream<T> *stream)
|
||||||
|
{
|
||||||
|
std::vector<std::vector<double>> timings(1);
|
||||||
|
|
||||||
|
// Declare timers
|
||||||
|
std::chrono::high_resolution_clock::time_point t1, t2;
|
||||||
|
|
||||||
|
// Run nstream in loop
|
||||||
|
for (int k = 0; k < num_times; k++) {
|
||||||
|
t1 = std::chrono::high_resolution_clock::now();
|
||||||
|
stream->nstream();
|
||||||
|
t2 = std::chrono::high_resolution_clock::now();
|
||||||
|
timings[0].push_back(std::chrono::duration_cast<std::chrono::duration<double> >(t2 - t1).count());
|
||||||
|
}
|
||||||
|
|
||||||
|
return timings;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Generic run routine
|
// Generic run routine
|
||||||
// Runs the kernel(s) and prints output.
|
// Runs the kernel(s) and prints output.
|
||||||
@ -275,6 +294,10 @@ void run()
|
|||||||
break;
|
break;
|
||||||
case Benchmark::Triad:
|
case Benchmark::Triad:
|
||||||
timings = run_triad<T>(stream);
|
timings = run_triad<T>(stream);
|
||||||
|
break;
|
||||||
|
case Benchmark::Nstream:
|
||||||
|
timings = run_nstream<T>(stream);
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check solutions
|
// Check solutions
|
||||||
@ -313,17 +336,26 @@ void run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (selection == Benchmark::All)
|
if (selection == Benchmark::All || selection == Benchmark::Nstream)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string labels[5] = {"Copy", "Mul", "Add", "Triad", "Dot"};
|
std::vector<std::string> labels;
|
||||||
size_t sizes[5] = {
|
std::vector<size_t> sizes;
|
||||||
2 * sizeof(T) * ARRAY_SIZE,
|
|
||||||
2 * sizeof(T) * ARRAY_SIZE,
|
if (selection == Benchmark::All)
|
||||||
3 * sizeof(T) * ARRAY_SIZE,
|
{
|
||||||
3 * sizeof(T) * ARRAY_SIZE,
|
labels = {"Copy", "Mul", "Add", "Triad", "Dot"};
|
||||||
2 * sizeof(T) * ARRAY_SIZE
|
sizes = {
|
||||||
};
|
2 * sizeof(T) * ARRAY_SIZE,
|
||||||
|
2 * sizeof(T) * ARRAY_SIZE,
|
||||||
|
3 * sizeof(T) * ARRAY_SIZE,
|
||||||
|
3 * sizeof(T) * ARRAY_SIZE,
|
||||||
|
2 * sizeof(T) * ARRAY_SIZE};
|
||||||
|
} else if (selection == Benchmark::Nstream)
|
||||||
|
{
|
||||||
|
labels = {"Nstream"};
|
||||||
|
sizes = {4 * sizeof(T) * ARRAY_SIZE };
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < timings.size(); ++i)
|
for (int i = 0; i < timings.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -416,13 +448,19 @@ void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>
|
|||||||
for (unsigned int i = 0; i < ntimes; i++)
|
for (unsigned int i = 0; i < ntimes; i++)
|
||||||
{
|
{
|
||||||
// Do STREAM!
|
// Do STREAM!
|
||||||
if (! (selection == Benchmark::Triad))
|
if (selection == Benchmark::All)
|
||||||
{
|
{
|
||||||
goldC = goldA;
|
goldC = goldA;
|
||||||
goldB = scalar * goldC;
|
goldB = scalar * goldC;
|
||||||
goldC = goldA + goldB;
|
goldC = goldA + goldB;
|
||||||
|
goldA = goldB + scalar * goldC;
|
||||||
|
} else if (selection == Benchmark::Triad)
|
||||||
|
{
|
||||||
|
goldA = goldB + scalar * goldC;
|
||||||
|
} else if (selection == Benchmark::Nstream)
|
||||||
|
{
|
||||||
|
goldA += goldB + scalar * goldC;
|
||||||
}
|
}
|
||||||
goldA = goldB + scalar * goldC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the reduction
|
// Do the reduction
|
||||||
@ -452,7 +490,7 @@ void check_solution(const unsigned int ntimes, std::vector<T>& a, std::vector<T>
|
|||||||
<< "Validation failed on c[]. Average error " << errC
|
<< "Validation failed on c[]. Average error " << errC
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
// Check sum to 8 decimal places
|
// Check sum to 8 decimal places
|
||||||
if (!(selection == Benchmark::Triad) && errSum > 1.0E-8)
|
if (selection == Benchmark::All && errSum > 1.0E-8)
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Validation failed on sum. Error " << errSum
|
<< "Validation failed on sum. Error " << errSum
|
||||||
<< std::endl << std::setprecision(15)
|
<< std::endl << std::setprecision(15)
|
||||||
@ -523,6 +561,10 @@ void parseArguments(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
selection = Benchmark::Triad;
|
selection = Benchmark::Triad;
|
||||||
}
|
}
|
||||||
|
else if (!std::string("--nstream-only").compare(argv[i]))
|
||||||
|
{
|
||||||
|
selection = Benchmark::Nstream;
|
||||||
|
}
|
||||||
else if (!std::string("--csv").compare(argv[i]))
|
else if (!std::string("--csv").compare(argv[i]))
|
||||||
{
|
{
|
||||||
output_as_csv = true;
|
output_as_csv = true;
|
||||||
@ -544,6 +586,7 @@ void parseArguments(int argc, char *argv[])
|
|||||||
std::cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << std::endl;
|
std::cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << std::endl;
|
||||||
std::cout << " --float Use floats (rather than doubles)" << std::endl;
|
std::cout << " --float Use floats (rather than doubles)" << std::endl;
|
||||||
std::cout << " --triad-only Only run triad" << std::endl;
|
std::cout << " --triad-only Only run triad" << std::endl;
|
||||||
|
std::cout << " --nstream-only Only run nstream" << std::endl;
|
||||||
std::cout << " --csv Output as csv table" << std::endl;
|
std::cout << " --csv Output as csv table" << std::endl;
|
||||||
std::cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << std::endl;
|
std::cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user