HEBench
|
Class hebench::TestHarness::BenchmarkLatency
offers a default implementation for Latency category. If a Latency category with default workflow needs to be added to a workload, clients should inherit from this class.
The following pseudo-code depicts the default Latency workflow as implemented by hebench::TestHarness::BenchmarkLatency::run()
. Descendants of class hebench::TestHarness::BenchmarkLatency
will inherit this functionality.
Note: all data is cleaned up and handles are released as appropriate. Boiler plate logic has been omited. Exceptions are thrown on errors. ErrorException
objects are used as exceptions with error numbers from backend. Test Harness handles these exceptions as appropriate based on the documentation specified for error codes in the API Bridge.
In the current directory hierarchy, Test Harness workloads are located in hebench/test_harness/benchmarks
. If our workload is "My Workload", the preferred method for structuring the directories is to create a directory in this location called MyWorkload
. Inside MyWorkload
, create directories for each workload category (latency
, offline
, etc.) supported by "My Workload".
For a directory structure example, look at existing workloads such as Element-wise vector addition EltwiseAdd
.
A good starting point to extend TestHarness is to copy an existing workload and renaming directories and files to match "My Workload".
These steps should provide a guide to add a Latency category test to a workload. Assume the workload in question is "My Workload".
Refer to implementation of EltwiseAdd
as a good example.
Create the directory structure to house "My Workload", if not already there. A good starting point to avoid starting from scratch is to copy an existing workload directory to the hebench/test_harness/benchmarks
location, such as directory EltwiseAdd
and rename to MyWorkload
. Rename all files and inner directories in the new directory to match the workload name.
See Directory Structure section above for more information.
Create the MyWorkloadLatency
class that inherits from public hebench::TestHarness::BenchmarkLatency
.
To inherit from hebench::TestHarness::BenchmarkLatency
, include header hebench_benchmark_latency.h
located in hebench/test_harness/benchmarks/categories/include
.
During benchmark creation and initialization the framework will call the methods of a benchmark automatically in the following order:
MyWorkloadLatency::MyWorkloadLatency
MyWorkloadLatency::init()
MyWorkloadLatency::postInit()
Inherited method hebench::TestHarness::BenchmarkLatency::init()
is abstract and always must be implemented . This method is provided to perform initialization steps before the backend itself is initialized. It is a dedicated method to provide the ability of polymorphic initialization if required.
Create a workload compatible hebench::TestHarness::IDataLoader
At any point, during initialization of the benchmark, an object of type IDataLoader::Ptr
that is compatible with the workload must be created. It must contain, at least, the input parameters for the operation. For latency category, only one sample per parameter is needed. Ground truth for the operation with the specified samples per parameter is also recommended to be loaded into the IDataLoader
object.
The task of the data loader is to load input samples and corresponding ground truth for the workload operation. In the case where the data loader generates the input data instead of loading from another source (such as storage), the data loader/generator must also precompute the ground truths for each corresponding input sample generated if ground truths are to be preloaded.
A data loader derived from class hebench::TestHarness::PartialDataLoader
has a head start on common implementations for trivial interface methods. It also takes care of boiler plate code and memory allocation based on parameter information.
If random data needs to be generated, class hebench::TestHarness::DataGeneratorHelper
can be helpful.
Virtual method hebench::TestHarness::BenchmarkLatency::postInit()
allows initialization that requires the backend to already exist. It provides a default implementation and, unless necessary, an override is not required. If one is provided, however, it is required that the base implementation is called as the first step.
Implement the following abstract methods.
hebench::TestHarness::PartialBenchmarkCategory::getDataset()
Default implementation for the virtual methods below exist, so, override if their default behavior does not match the current benchmark.
(optional)
Destructor
hebench::TestHarness::PartialBenchmarkCategory::validateResult()
hebench::TestHarness::PartialBenchmarkCategory::logResult()
hebench::TestHarness::PartialBenchmarkCategory::getStartEventID()
See the method descriptions for more information on the expected functionality and default behavior.
At this point, the MyWorkloadLatency
class should be completed. Refer to documentation on adding a workload to the Test Harness for the final steps to make Test Harness aware of the new class.