o-du/phy
Intel O-RAN/X-RAN Generated Doxygen Documentation
Data Structures | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
KernelTests Class Reference

#include <common.hpp>

Inheritance diagram for KernelTests:
Inheritance graph
Collaboration diagram for KernelTests:
Collaboration graph

Static Public Member Functions

static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static unsigned get_number_of_cases (const std::string &type)
 

Static Public Attributes

static json conf
 
static std::string test_type
 

Protected Member Functions

void set_division_factor (const double factor)
 Set division factor. More...
 
void set_results_units (const std::string &units)
 Set reults units. More...
 
void set_parallelization_factor (const int factor)
 Set size of processed data. More...
 
template<typename F , typename ... Args>
void performance (const std::string &isa, const std::string &module_name, F function, Args ... args)
 Run performance test case for a given function. More...
 
void print_test_description (const std::string &isa, const std::string &module_name)
 Print unique test description to the results xml file. More...
 
const std::string get_case_name ()
 Get name of the test case from JSON file. More...
 
void init_test (const std::string &type)
 Defines section in the conf.json that is used to load parameters from. More...
 
template<typename T >
get_input_parameter (const std::string &parameter_name)
 Load selected data from a JSON object. get_input_parameter loads data from parameters section of the test case in JSON file and get_reference_parameter does the same thing for references section. More...
 
template<typename T >
get_reference_parameter (const std::string &parameter_name)
 

Protected Attributes

double division_factor = 1.0
 
std::string result_units = "None"
 
int parallelization_factor = 1
 

Detailed Description

Each test class has to inherit from KernelTests class as it provides GTest support and does a lot of setup (including JSON) an provides useful methods to operate on loaded JSON file. Unfortunately GTest is limited in the way that all TEST_P within the class are called for all cases/parameters, but we usually want two different data sets for functional and performance tests (or maybe other types of tests). Because of that to use different data sets we need to create separate classes, hence performance and functional test are in separate classes. it adds an extra overhead, but adds much more flexibility. init_test(...) is used to select data set from the JSON file.

Important note on the JSON file structure. Top JSON object can have as many section (JSON objects) as needed, but each have to have a distinct name that is used by init_test. Then each section must contain an array of objects (test cases) where each object has a name, parameters and references. Everything inside parameters and references can be completely custom as it's loaded by get_input/reference_parameter function. JSON values can be either literal values, e.g. 1, 0.001, 5e-05, etc. or filename. Depends on the get type test framework can either read the value or load data from the file - and it happens automatically (pff MAGIC!).

Definition at line 156 of file common.hpp.

Member Function Documentation

◆ get_case_name()

const std::string get_case_name ( )
inlineprotected

Get name of the test case from JSON file.

Returns
Test'ss case name or a default name if name field is missing.

Definition at line 338 of file common.hpp.

◆ get_input_parameter()

T get_input_parameter ( const std::string &  parameter_name)
inlineprotected

Load selected data from a JSON object. get_input_parameter loads data from parameters section of the test case in JSON file and get_reference_parameter does the same thing for references section.

Get parameter function uses template type to figure out how to load parameters. If type is NOT a pointer it'll load value directly from the JSON. Otherwise path to the test vector is expected and function will allocate memory, load data from the binary file to this memory location and return pointer to it. For example in here we request to load pointer to float so llrs filed is expected to be a path to the binary file.

Definition at line 290 of file common.hpp.

Here is the call graph for this function:

◆ get_number_of_cases()

static unsigned get_number_of_cases ( const std::string &  type)
inlinestatic

Definition at line 190 of file common.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_reference_parameter()

T get_reference_parameter ( const std::string &  parameter_name)
inlineprotected

Definition at line 312 of file common.hpp.

Here is the call graph for this function:

◆ init_test()

void init_test ( const std::string &  type)
inlineprotected

Defines section in the conf.json that is used to load parameters from.

Parameters
[in]typeName of the section in the JSON file.

Definition at line 358 of file common.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ performance()

void performance ( const std::string &  isa,
const std::string &  module_name,
function,
Args ...  args 
)
inlineprotected

Run performance test case for a given function.

Parameters
[in]isaUsed Instruction Set.
[in]module_namename of the tested kernel.
[in]functionfunction to be tested.
[in]argsfunction's arguments.

Definition at line 253 of file common.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_test_description()

void print_test_description ( const std::string &  isa,
const std::string &  module_name 
)
inlineprotected

Print unique test description to the results xml file.

Parameters
[in]isaUsed Instruction Set.
[in]module_namename of the tested kernel.
[in]functionfunction to be tested.

Definition at line 271 of file common.hpp.

◆ set_division_factor()

void set_division_factor ( const double  factor)
inlineprotected

Set division factor.

Parameters
[in]factorDivision factor that divides mean and standard deviation.

Definition at line 222 of file common.hpp.

◆ set_parallelization_factor()

void set_parallelization_factor ( const int  factor)
inlineprotected

Set size of processed data.

Parameters
[in]sizeSize of processed data used to calculate module throughput.

Definition at line 240 of file common.hpp.

◆ set_results_units()

void set_results_units ( const std::string &  units)
inlineprotected

Set reults units.

Parameters
[in]unitsUnits that are displayed in the report.

Definition at line 231 of file common.hpp.

◆ SetUpTestCase()

static void SetUpTestCase ( )
inlinestatic

Definition at line 162 of file common.hpp.

Here is the call graph for this function:

◆ TearDownTestCase()

static void TearDownTestCase ( )
inlinestatic

Definition at line 185 of file common.hpp.

Field Documentation

◆ conf

json conf
static

Definition at line 159 of file common.hpp.

◆ division_factor

double division_factor = 1.0
protected

Definition at line 214 of file common.hpp.

◆ parallelization_factor

int parallelization_factor = 1
protected

Definition at line 216 of file common.hpp.

◆ result_units

std::string result_units = "None"
protected

Definition at line 215 of file common.hpp.

◆ test_type

std::string test_type
static

Definition at line 160 of file common.hpp.


The documentation for this class was generated from the following files: