Skip to content

Commit 8758066

Browse files
committed
--only option allows specifying which kernel
1 parent 147c5e3 commit 8758066

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/main.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,43 @@ void parseArguments(int argc, char *argv[])
415415
{
416416
use_float = true;
417417
}
418-
else if (!string("--triad-only").compare(argv[i]))
418+
else if (!string("--print-names").compare(argv[i]))
419419
{
420-
selection = Benchmark::Triad;
420+
cout << "Available benchmarks: ";
421+
print_labels(cout);
422+
cout << endl;
423+
exit(0);
421424
}
422-
else if (!string("--nstream-only").compare(argv[i]))
425+
else if (!string("--only").compare(argv[i]) || !string("-o").compare(argv[i]))
423426
{
424-
selection = Benchmark::Nstream;
427+
if (++i >= argc)
428+
{
429+
cerr << "Expected benchmark name after --only" << endl;
430+
exit(1);
431+
}
432+
auto key = string(argv[i]);
433+
if (key == "Classic")
434+
{
435+
selection = Benchmark::Classic;
436+
}
437+
else if (key == "All")
438+
{
439+
selection = Benchmark::All;
440+
}
441+
else
442+
{
443+
auto p = find_if(labels.begin(), labels.end(), [&](char const* label) {
444+
return string(label) == key;
445+
});
446+
if (p == labels.end()) {
447+
cerr << "Unknown benchmark name \"" << argv[i] << "\" after --only" << endl;
448+
cerr << "Available benchmarks: All,Classic,";
449+
print_labels(cerr);
450+
cerr << endl;
451+
exit(1);
452+
}
453+
selection = (Benchmark)(distance(labels.begin(), p));
454+
}
425455
}
426456
else if (!string("--csv").compare(argv[i]))
427457
{
@@ -443,8 +473,8 @@ void parseArguments(int argc, char *argv[])
443473
cout << " -s --arraysize SIZE Use SIZE elements in the array" << endl;
444474
cout << " -n --numtimes NUM Run the test NUM times (NUM >= 2)" << endl;
445475
cout << " --float Use floats (rather than doubles)" << endl;
446-
cout << " --triad-only Only run triad" << endl;
447-
cout << " --nstream-only Only run nstream" << endl;
476+
cout << " -o --only NAME Only run one benchmark (see --print-names)" << endl;
477+
cout << " --print-names Prints all available benchmark names" << endl;
448478
cout << " --csv Output as csv table" << endl;
449479
cout << " --mibibytes Use MiB=2^20 for bandwidth calculation (default MB=10^6)" << endl;
450480
cout << endl;

0 commit comments

Comments
 (0)