memloadgen allocate memory in thread

This commit is contained in:
oscar 2023-03-15 19:10:52 -04:00
parent 7e4fd3d721
commit a385866002

View File

@ -19,8 +19,6 @@ memload_generator::worker_thrd(void *_tinfo)
{
auto *tinfo = (struct thread_info *)_tinfo;
void *from_buffer, *to_buffer;
long tid;
thr_self(&tid);
if (tinfo->opts->shared_buffer) {
from_buffer = tinfo->from_buffer;
@ -28,8 +26,8 @@ memload_generator::worker_thrd(void *_tinfo)
} else {
if (tinfo->opts->verbose) {
fprintf(stdout,
"memload_generator <thread %ld>: allocating %lu bytes on domain %d...\n",
tid, tinfo->opts->buffer_size,
"memload_generator <thread %d>: allocating fbuf %lu bytes on domain %d...\n",
tinfo->tid, tinfo->opts->buffer_size,
topo_core_to_numa(tinfo->coreid));
}
from_buffer = nms_alloc_static(topo_core_to_numa(
@ -37,8 +35,8 @@ memload_generator::worker_thrd(void *_tinfo)
tinfo->opts->buffer_size);
if (tinfo->opts->verbose) {
fprintf(stdout,
"memload_generator <thread %ld>: allocating %lu bytes on domain %d...\n",
tid, tinfo->opts->buffer_size, tinfo->target_dom);
"memload_generator <thread %d>: allocating tbuf %lu bytes on domain %d...\n",
tinfo->tid, tinfo->opts->buffer_size, tinfo->target_dom);
}
to_buffer = nms_alloc_static(tinfo->target_dom,
tinfo->opts->buffer_size);
@ -47,8 +45,8 @@ memload_generator::worker_thrd(void *_tinfo)
if (from_buffer == nullptr || to_buffer == nullptr) {
if (tinfo->opts->verbose) {
fprintf(stderr,
"memload_generator <thread %ld>: failed to allocate memory\n",
tid);
"memload_generator <thread %d>: failed to allocate memory\n",
tinfo->tid);
}
tinfo->init_status.store(-1);
return nullptr;
@ -56,7 +54,7 @@ memload_generator::worker_thrd(void *_tinfo)
// wait for other threads to init
if (tinfo->opts->verbose) {
fprintf(stdout, "memload_generator <thread %ld>: running...\n", tid);
fprintf(stdout, "memload_generator <thread %d>: running...\n", tinfo->tid);
}
tinfo->init_status.store(1);
@ -101,8 +99,8 @@ memload_generator::worker_thrd(void *_tinfo)
}
end:
if (tinfo->opts->verbose) {
fprintf(stdout, "memload_generator <thread %ld>: exiting...\n",
tid);
fprintf(stdout, "memload_generator <thread %d>: exiting...\n",
tinfo->tid);
}
if (!tinfo->opts->shared_buffer) {