2022-06-22 15:40:48 +00:00
|
|
|
#include "gen.hh"
|
2022-05-25 10:55:01 +00:00
|
|
|
#include <cstdlib>
|
2022-02-21 13:41:40 +00:00
|
|
|
#include "ntr.h"
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <unistd.h>
|
2022-06-22 15:40:48 +00:00
|
|
|
#include <topo.h>
|
2022-02-21 13:41:40 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
fprintf(stdout,
|
|
|
|
"Usage:\n"
|
|
|
|
" -v: verbose mode\n"
|
|
|
|
" -b: MLG bytes per second\n"
|
|
|
|
" -x: MLG thread affinity mask\n"
|
2022-06-22 15:40:48 +00:00
|
|
|
" -X: MLG target domain affinity mask\n"
|
|
|
|
" -S: shared buffer\n"
|
|
|
|
" -i: iterations\n");
|
2022-02-21 13:41:40 +00:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char * argv[])
|
|
|
|
{
|
|
|
|
ntr_init();
|
|
|
|
ntr_set_level(NTR_DEP_USER1, NTR_LEVEL_WARNING);
|
|
|
|
|
2022-06-22 15:40:48 +00:00
|
|
|
size_t arr_sz = 0;
|
|
|
|
uint32_t iter = -1;
|
|
|
|
cpuset_t threads;
|
|
|
|
int shared_buffer = 0;
|
|
|
|
cpuset_t domain_mask;
|
2022-02-21 13:41:40 +00:00
|
|
|
{
|
|
|
|
int c;
|
|
|
|
// parse arguments
|
2022-06-22 15:40:48 +00:00
|
|
|
while ((c = getopt(argc, argv, "hb:X:x:vi:S")) != -1) {
|
2022-02-21 13:41:40 +00:00
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
ntr_set_level(NTR_DEP_USER1,
|
|
|
|
ntr_get_level(NTR_DEP_USER1) + 1);
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
case 'b':
|
2022-06-22 15:40:48 +00:00
|
|
|
arr_sz = strtoull(optarg, nullptr, 10);
|
2022-05-25 10:55:01 +00:00
|
|
|
break;
|
|
|
|
case 'i':
|
2022-06-22 15:40:48 +00:00
|
|
|
iter = strtoul(optarg, nullptr, 10);
|
2022-02-21 13:41:40 +00:00
|
|
|
break;
|
|
|
|
case 'X':
|
2022-06-22 15:40:48 +00:00
|
|
|
cpulist_to_cpuset(optarg, &domain_mask);
|
2022-02-21 13:41:40 +00:00
|
|
|
break;
|
|
|
|
case 'x':
|
2022-06-22 15:40:48 +00:00
|
|
|
cpulist_to_cpuset(optarg, &threads);
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
shared_buffer = 1;
|
2022-02-21 13:41:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-22 15:40:48 +00:00
|
|
|
ntr(NTR_DEP_USER1, NTR_LEVEL_INFO, "MLG: [size: %ld iter: %u, # threads: 0x%d, domain: 0x%ld]\n", arr_sz, iter, CPU_COUNT(&threads), CPU_FFS(&domain_mask) - 1);
|
2022-02-21 13:41:40 +00:00
|
|
|
|
2022-06-22 15:40:48 +00:00
|
|
|
// init topo
|
|
|
|
if (topo_init(ntr_get_level(NTR_DEP_USER1) - NTR_LEVEL_WARNING) != 0) {
|
|
|
|
fprintf(stderr, "libtopo init failed!\n");
|
2022-02-21 13:41:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool success = false;
|
2022-06-22 15:40:48 +00:00
|
|
|
memload_generator::memload_generator_options opts;
|
|
|
|
opts.chunk_size = arr_sz;
|
|
|
|
opts.iteration = iter;
|
|
|
|
opts.shared_buffer = shared_buffer;
|
|
|
|
opts.verbose = 1;
|
2022-02-21 13:41:40 +00:00
|
|
|
|
2022-06-22 15:40:48 +00:00
|
|
|
auto mgen = new memload_generator(&threads, &domain_mask, &opts, &success);
|
2022-05-25 10:55:01 +00:00
|
|
|
while(!mgen->check_done()) {
|
|
|
|
usleep(10000);
|
2022-02-21 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
2022-05-25 10:55:01 +00:00
|
|
|
unsigned long bps = mgen->get_bps();
|
|
|
|
ntr(NTR_DEP_USER1, NTR_LEVEL_INFO,
|
|
|
|
"main: MLG bps = %ld ~= %ldM\n", bps, bps / 1024 / 1024);
|
|
|
|
|
2022-06-22 15:40:48 +00:00
|
|
|
delete mgen;
|
|
|
|
|
2022-02-21 13:41:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|