Commit 99c1f8c3 authored by Ondrej Mosnáček's avatar Ondrej Mosnáček

Add kernel type option to the benchmark tool

parent 8a00d83f
......@@ -23,6 +23,7 @@ private:
argon2::Version version;
std::size_t t_cost, m_cost, lanes;
std::size_t batchSize, samples;
bool bySegment;
std::string outputMode, outputType;
bool beVerbose;
......@@ -34,17 +35,19 @@ public:
std::size_t getMemoryCost() const { return m_cost; }
std::size_t getLanes() const { return lanes; }
std::size_t getBatchSize() const { return batchSize; }
bool isBySegment() const { return bySegment; }
bool isVerbose() const { return beVerbose; }
BenchmarkDirector(const std::string &progname,
argon2::Type type, argon2::Version version,
std::size_t t_cost, std::size_t m_cost, std::size_t lanes,
std::size_t batchSize, std::size_t samples,
std::size_t batchSize, bool bySegment,
std::size_t samples,
const std::string &outputMode,
const std::string &outputType)
: progname(progname), type(type), version(version),
t_cost(t_cost), m_cost(m_cost), lanes(lanes),
batchSize(batchSize), samples(samples),
batchSize(batchSize), samples(samples), bySegment(bySegment),
outputMode(outputMode), outputType(outputType),
beVerbose(outputMode == "verbose")
{
......
......@@ -19,7 +19,8 @@ public:
: params(HASH_LENGTH, NULL, 0, NULL, 0, NULL, 0,
director.getTimeCost(), director.getMemoryCost(),
director.getLanes()),
unit(&pc, &params, &device, director.getBatchSize())
unit(&pc, &params, &device, director.getBatchSize(),
director.isBySegment())
{
}
......
......@@ -27,6 +27,7 @@ struct Arguments
std::size_t m_cost = 1024;
std::size_t lanes = 1;
std::size_t batchSize = 16;
std::string kernelType = "by-segment";
std::size_t sampleCount = 10;
};
......@@ -82,6 +83,9 @@ static CommandLineParser<Arguments> buildCmdLineParser()
makeNumericHandler<Arguments, std::size_t>([] (Arguments &state, std::size_t num) {
state.sampleCount = (std::size_t)num;
}), "samples", 's', "number of batches to run and measure", "10", "N"),
new ArgumentOption<Arguments>(
[] (Arguments &state, const std::string &type) { state.kernelType = type; },
"kernel-type", 'k', "Kernel type (by-segment|oneshot)", "by-segment", "TYPE"),
new FlagOption<Arguments>(
[] (Arguments &state) { state.showHelp = true; },
......@@ -113,7 +117,7 @@ int main(int, const char * const *argv)
} else if (args.type == "d") {
type = argon2::ARGON2_D;
} else {
// TODO
std::cerr << argv[0] << ": Invalid Argon2 type!" << std::endl;
return 1;
}
......@@ -123,13 +127,23 @@ int main(int, const char * const *argv)
} else if (args.version == "1.3") {
version = argon2::ARGON2_VERSION_13;
} else {
// TODO
std::cerr << argv[0] << ": Invalid Argon2 version!" << std::endl;
return 1;
}
bool bySegment;
if (args.kernelType == "by-segment") {
bySegment = true;
} else if (args.kernelType == "oneshot") {
bySegment = false;
} else {
std::cerr << argv[0] << ": Invalid kernel type!" << std::endl;
return 1;
}
BenchmarkDirector director(argv[0], type, version,
args.t_cost, args.m_cost, args.lanes,
args.batchSize, args.sampleCount,
args.batchSize, bySegment, args.sampleCount,
args.outputMode, args.outputType);
if (args.mode == "opencl") {
OpenCLExecutive exec(args.deviceIndex, args.listDevices);
......@@ -138,7 +152,7 @@ int main(int, const char * const *argv)
CudaExecutive exec(args.deviceIndex, args.listDevices);
return exec.runBenchmark(director);
} else if (args.mode == "cpu") {
// TODO
std::cerr << argv[0] << ": CPU mode not yet supported!" << std::endl;
return 1;
} else {
std::cerr << argv[0] << ": invalid mode: " << args.mode << std::endl;
......
......@@ -19,7 +19,8 @@ public:
: params(HASH_LENGTH, NULL, 0, NULL, 0, NULL, 0,
director.getTimeCost(), director.getMemoryCost(),
director.getLanes()),
unit(&pc, &params, &device, director.getBatchSize())
unit(&pc, &params, &device, director.getBatchSize(),
director.isBySegment())
{
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment