This commit is contained in:
oscar 2023-05-01 15:28:51 -04:00
parent aba80e8869
commit fc687426ae
4 changed files with 21 additions and 8 deletions

View File

@ -314,6 +314,7 @@ class memload_generator {
void *to_buffer; void *to_buffer;
std::atomic<bool> reset_ts; std::atomic<bool> reset_ts;
int tid; int tid;
int pull;
int coreid; int coreid;
int target_dom; int target_dom;
struct memload_generator_options * opts; struct memload_generator_options * opts;
@ -336,7 +337,7 @@ class memload_generator {
struct memload_generator_options opts; struct memload_generator_options opts;
public: public:
memload_generator(cpuset_t * threads, cpuset_t * target_domain, struct memload_generator_options * opt, bool *success); memload_generator(cpuset_t * threads, cpuset_t * modes, cpuset_t * target_domain, struct memload_generator_options * opt, bool *success);
uint64_t get_transactions(); uint64_t get_transactions();
bool start(); bool start();
bool stop(); bool stop();

View File

@ -18,7 +18,7 @@ void *
memload_generator::worker_thrd(void *_tinfo) memload_generator::worker_thrd(void *_tinfo)
{ {
auto *tinfo = (struct thread_info *)_tinfo; auto *tinfo = (struct thread_info *)_tinfo;
void *from_buffer, *to_buffer; void *from_buffer, *to_buffer, *tmp;
if (tinfo->opts->shared_buffer) { if (tinfo->opts->shared_buffer) {
from_buffer = tinfo->from_buffer; from_buffer = tinfo->from_buffer;
@ -52,9 +52,15 @@ memload_generator::worker_thrd(void *_tinfo)
return nullptr; return nullptr;
} }
if (tinfo->pull) {
tmp = from_buffer;
from_buffer = to_buffer;
to_buffer = tmp;
}
// wait for other threads to init // wait for other threads to init
if (tinfo->opts->verbose) { if (tinfo->opts->verbose) {
fprintf(stdout, "memload_generator <thread %d>: running...\n", tinfo->tid); fprintf(stdout, "memload_generator <thread %d, pull %d>: running...\n", tinfo->tid, tinfo->pull);
} }
tinfo->init_status.store(1); tinfo->init_status.store(1);
@ -112,7 +118,7 @@ end:
return nullptr; return nullptr;
} }
memload_generator::memload_generator(cpuset_t *threads, cpuset_t *target_domain, memload_generator::memload_generator(cpuset_t *threads, cpuset_t * modes, cpuset_t *target_domain,
struct memload_generator_options *opt, bool *success) struct memload_generator_options *opt, bool *success)
{ {
*success = false; *success = false;
@ -162,6 +168,7 @@ memload_generator::memload_generator(cpuset_t *threads, cpuset_t *target_domain,
info->target_dom = target_domain_id; info->target_dom = target_domain_id;
info->from_buffer = local_buffer; info->from_buffer = local_buffer;
info->to_buffer = target_buffer; info->to_buffer = target_buffer;
info->pull = CPU_ISSET(nextcore, modes);
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
CPU_SET(nextcore, &cpuset); CPU_SET(nextcore, &cpuset);

View File

@ -79,7 +79,7 @@ nms_alloc_static(int node_id, size_t sz)
int sum; int sum;
for (size_t i = 0; i < sz; i++) { for (size_t i = 0; i < sz; i++) {
sum += *(uint8_t *)((char *)region + i); sum += *(uint8_t *)((char *)region + i);
*(uint8_t *)((char *)region + i) = 0; *(uint8_t *)((char *)region + i) = i;
} }
// restore existing thread's allocation strategy // restore existing thread's allocation strategy

View File

@ -26,6 +26,7 @@ usage()
" -q: bytes per second\n" " -q: bytes per second\n"
" -d: destination domain index\n" " -d: destination domain index\n"
" -s: worker threads cpu list\n" " -s: worker threads cpu list\n"
" -m: pull mode cpu list\n"
" -S: enable shared buffer\n" " -S: enable shared buffer\n"
" -t: time to run\n" " -t: time to run\n"
" -T: transaction size\n" " -T: transaction size\n"
@ -47,9 +48,10 @@ int main(int argc, char * argv[])
uint32_t time = -1; uint32_t time = -1;
uint64_t bps = 0; uint64_t bps = 0;
uint64_t transaction_size = arr_sz; uint64_t transaction_size = arr_sz;
cpuset_t threads; cpuset_t threads, modes;
char magic[256] = {0}; char magic[256] = {0};
CPU_ZERO(&threads); CPU_ZERO(&threads);
CPU_ZERO(&modes);
CPU_SET(0, &threads); CPU_SET(0, &threads);
char ia_dist[32] = "fixed"; char ia_dist[32] = "fixed";
int history_sz = 5; int history_sz = 5;
@ -63,7 +65,7 @@ int main(int argc, char * argv[])
{ {
int c; int c;
// parse arguments // parse arguments
while ((c = getopt(argc, argv, "vhb:d:s:So:T:t:q:i:H:M:")) != -1) { while ((c = getopt(argc, argv, "vhb:d:s:m:So:T:t:q:i:H:M:")) != -1) {
switch (c) { switch (c) {
case 'v': case 'v':
ntr_set_level(NTR_DEP_USER1, ntr_get_level(NTR_DEP_USER1) + 1); ntr_set_level(NTR_DEP_USER1, ntr_get_level(NTR_DEP_USER1) + 1);
@ -80,6 +82,9 @@ int main(int argc, char * argv[])
case 's': case 's':
cpulist_to_cpuset(optarg, &threads); cpulist_to_cpuset(optarg, &threads);
break; break;
case 'm':
cpulist_to_cpuset(optarg, &modes);
break;
case 'S': case 'S':
shared_buffer = 1; shared_buffer = 1;
break; break;
@ -150,7 +155,7 @@ int main(int argc, char * argv[])
std::ofstream ofile; std::ofstream ofile;
ofile.open(output_file, std::ios::out | std::ios::trunc); ofile.open(output_file, std::ios::out | std::ios::trunc);
auto mgen = new memload_generator(&threads, &domain_mask, &opts, &success); auto mgen = new memload_generator(&threads, &modes, &domain_mask, &opts, &success);
if (strlen(magic) > 0) { if (strlen(magic) > 0) {
fprintf(stdout, "%s\n", magic); fprintf(stdout, "%s\n", magic);
fflush(stdout); fflush(stdout);