HEBench
|
Class hebench::TestHarness::BenchmarkOffline
offers a default implementation for Offline category. If a Offline category with default workflow needs to be added to a workload, clients should inherit from this class.
The following pseudo-code depicts the default Offline workflow as implemented by hebench::TestHarness::BenchmarkOffline::run()
. Descendants of class hebench::TestHarness::BenchmarkOffline
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 Offline 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 MyWorkloadOffline
class that inherits from public hebench::TestHarness::BenchmarkOffline
.
To inherit from hebench::TestHarness::BenchmarkOffline
, include header hebench_benchmark_offline.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:
MyWorkloadOffline::MyWorkloadLatency
MyWorkloadOffline::init()
MyWorkloadOffline::postInit()
Inherited method hebench::TestHarness::BenchmarkOffline::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.
Inherited method hebench::TestHarness::BenchmarkOffline::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 MyWorkloadOffline
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.