memload generator
This commit is contained in:
parent
997587c519
commit
0dc463ba35
@ -32,6 +32,7 @@ set(LIBGEN_CC_FLAGS -O2 -g -Wall -Wextra -Werror -std=c++11)
|
||||
set(KHAT_LINKLIBS pthread nm ntr ${dpdk_LIBRARIES})
|
||||
set(CAT_LINKLIBS pthread nm ntr gen ${dpdk_LIBRARIES})
|
||||
set(RAT_LINKLIBS pthread nm ntr gen ${dpdk_LIBRARIES})
|
||||
set(MEMLOAD_LINKLIBS pthread nm ntr)
|
||||
|
||||
add_library(ntr libntr/ntr.c)
|
||||
target_compile_options(ntr PRIVATE ${LIBNTR_C_FLAGS})
|
||||
@ -56,4 +57,9 @@ target_link_options(cat PRIVATE -L /usr/local/lib)
|
||||
add_executable(rat net/rat.cc)
|
||||
target_link_libraries(rat ${RAT_LINKLIBS})
|
||||
target_compile_options(rat PRIVATE ${CC_FLAGS})
|
||||
target_link_options(rat PRIVATE -L /usr/local/lib)
|
||||
target_link_options(rat PRIVATE -L /usr/local/lib)
|
||||
|
||||
add_executable(memloadgen util/memloadgen.cc)
|
||||
target_link_libraries(memloadgen ${MEMLOAD_LINKLIBS})
|
||||
target_compile_options(memloadgen PRIVATE ${CC_FLAGS})
|
||||
target_link_options(memloadgen PRIVATE -L /usr/local/lib)
|
79
util/memloadgen.cc
Normal file
79
util/memloadgen.cc
Normal file
@ -0,0 +1,79 @@
|
||||
#include "nm.h"
|
||||
#include "ntr.h"
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stdout,
|
||||
"Usage:\n"
|
||||
" -v: verbose mode\n"
|
||||
" -b: MLG bytes per second\n"
|
||||
" -x: MLG thread affinity mask\n"
|
||||
" -X: MLG target domain affinity mask\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
ntr_init();
|
||||
ntr_set_level(NTR_DEP_USER1, NTR_LEVEL_WARNING);
|
||||
|
||||
unsigned long long mlg_bps = 0;
|
||||
unsigned long long mlg_dmask = 0;
|
||||
unsigned long long mlg_cmask = 0;
|
||||
{
|
||||
int c;
|
||||
// parse arguments
|
||||
while ((c = getopt(argc, argv, "hb:X:x:v")) != -1) {
|
||||
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':
|
||||
mlg_bps = strtoull(optarg, nullptr, 10);
|
||||
break;
|
||||
case 'X':
|
||||
mlg_dmask = strtoull(
|
||||
optarg, nullptr, 16);
|
||||
break;
|
||||
case 'x':
|
||||
mlg_cmask = strtoull(
|
||||
optarg, nullptr, 16);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ntr(NTR_DEP_USER1, NTR_LEVEL_INFO, "MLG: [bps: %lld, threads: 0x%llx, domain: 0x%llx]\n", mlg_bps, mlg_cmask, mlg_dmask);
|
||||
|
||||
// init nm
|
||||
if (nm_init(ntr_get_level(NTR_DEP_USER1) - NTR_LEVEL_WARNING) != 0) {
|
||||
fprintf(stderr, "nm init failed!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
memload_generator * mgen = new memload_generator(mlg_cmask, mlg_dmask, mlg_bps, &success);
|
||||
|
||||
mgen->start();
|
||||
|
||||
while(true)
|
||||
{
|
||||
unsigned long bps = mgen->get_bps();
|
||||
ntr(NTR_DEP_USER1, NTR_LEVEL_INFO,
|
||||
"main: MLG bps = %ld ~= %ldM\n", bps, bps / 1024 / 1024);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user