-
Notifications
You must be signed in to change notification settings - Fork 2
4. How to add the driver to Runner
BlaCkinkGJ edited this page Aug 25, 2020
·
2 revisions
If you want to add the driver to runner
, then you must follow the below. In this example, we assume that we make a bench-driver
. (Please keep the naming rule to <BENCHMARK>-driver
)
This section describes making directories and files for driver.
- First of all, you make the
runner/driver
directory and theinclude/driver
directory which has thebench-driver
sub-directory - Add the
bench-driver.h
file toinclude/driver/bench-driver
directory. - Add the
bench-driver.c
file torunner/driver/bench-driver
directory. -
bench-driver.h
andbench-driver.c
must follow the below template source files.
#include <generic.h>
int bench_init(void *object);
int bench_runner(void);
int bench_get_interval(const char *key, char *buffer);
int bench_get_total(const char *key, char *buffer);
void bench_free(void);
#include <generic.h>
#include <runner.h>
#include <driver/bench-driver.h>
int bench_init(void *object)
{
struct runner_config *config = (struct runner_config *)object;
struct generic_driver_op *op = &config->op;
op->runner = bench_runner;
op->get_interval = bench_get_interval;
op->get_total = bench_get_total;
op->free = bench_free;
}
This section describes how to register the driver to the runner
.
- First of all, you have to add
BENCH_DRIVER=1
togeneric.h
's enumeration variable which containsTRACE_REPLAY_DRIVER=0
. you must not use the number which other drivers already have taken. - Next, you add the "key, value" to the
driver_name_tbl
variable ingeneric.c
. This value will be used in JSON's "driver" key. For example, you can add the value like[BENCH_DRIVER] = "bench"
todriver_name_tbl
- Finally, you add the
[BENCH_DRIVER] = bench_init
todriver_init_tbl
variable ingeneric.c
.
-
<BENCHMARK>_init
function only does the memory allocation and basic configuration. The real running sequence must be implemented in the<BENCHMAKR>_runner
. - Highly suggest to refer to the
tr-driver
anddocker-driver
to create a driver. - Basically, if you can run
scons
(NOTscons test
) then automatically generatecompile_commands.json
. If you use this with coc and ccls in neovim then you can more easily develop our program. - If you want to analyze our source code, then you check this link and run Sourcetrail with
compile_commands.json
.