Skip to content
Snippets Groups Projects
Commit 46a6caa0 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Fix a memory allocation bug (*nlogs) and stop allocating all the buffer memory upfront

Not allocating upfront will reduce the overall memory footprint, but may slow down the send and recv loops
parent 28a00cc2
Branches
No related tags found
1 merge request!5Add an option to fix the message size
......@@ -131,6 +131,7 @@ static void *inject_thread(void *arg) {
/* Differences to SWIFT: MPI_BYTE not the MPI_Type. */
int err = 0;
if (log->type == task_type_send) {
log->data = calloc(log->size, 1);
err = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
......@@ -140,6 +141,7 @@ static void *inject_thread(void *arg) {
atomic_inc(&todo_send);
} else {
log->data = calloc(log->size, 1);
err = MPI_Irecv(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
......@@ -329,7 +331,7 @@ static void pick_logs(void) {
nlogs, sizeof(struct mpiuse_log_entry *));
nr_reqs = 0;
sends_queue = (struct mpiuse_log_entry **)calloc(
nlogs, sizeof(struct mpiuse_log_entry *) * nlogs);
nlogs, sizeof(struct mpiuse_log_entry *));
nr_sends = 0;
recvs_queue = (struct mpiuse_log_entry **)calloc(
nlogs, sizeof(struct mpiuse_log_entry *));
......@@ -343,10 +345,8 @@ static void pick_logs(void) {
/* Override size if needed. */
if (messagesize > 0) log->size = messagesize;
/* Allocate space for data. */
log->data = calloc(log->size, 1);
/* And keep this log. */
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment