From 75130af867e23fcd50ab648615e73e7748351c1c Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Mon, 13 Nov 2017 11:01:51 +0000
Subject: [PATCH] Make mpi_message_limit an unsigned int, switch units to KB

---
 examples/parameter_example.yml | 2 +-
 src/engine.c                   | 5 ++---
 src/scheduler.h                | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml
index a7fa05a294..e997059f92 100644
--- a/examples/parameter_example.yml
+++ b/examples/parameter_example.yml
@@ -15,7 +15,7 @@ Scheduler:
   cell_split_size:        400       # (Optional) Maximal number of particles per cell (this is the default value).
   max_top_level_cells:    12        # (Optional) Maximal number of top-level cells in any dimension. The number of top-level cells will be the cube of this (this is the default value).
   tasks_per_cell:         0         # (Optional) The average number of tasks per cell. If not large enough the simulation will fail (means guess...).
-  mpi_message_limit:      4194304   # (Optional) Maximum MPI task message size to send non-buffered
+  mpi_message_limit:      4096      # (Optional) Maximum MPI task message size to send non-buffered, KB.
 
 # Parameters governing the time integration (Set dt_min and dt_max to the same value for a fixed time-step run.)
 TimeIntegration:
diff --git a/src/engine.c b/src/engine.c
index fdc534f9a6..25586b7d1e 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4636,12 +4636,11 @@ void engine_init(struct engine *e, struct space *s,
   scheduler_init(&e->sched, e->s, engine_estimate_nr_tasks(e), nr_queues,
                  (policy & scheduler_flag_steal), e->nodeID, &e->threadpool);
 
-  /* Maximum size of MPI task messages that should not be buffered,
+  /* Maximum size of MPI task messages, in KB, that should not be buffered,
    * that is sent using MPI_Issend, not MPI_Isend. 4Mb by default.
    */
   e->sched.mpi_message_limit =
-      parser_get_opt_param_int(params, "Scheduler:mpi_message_limit",
-                               4194304);
+      parser_get_opt_param_int(params, "Scheduler:mpi_message_limit", 4) * 1024;
 
   /* Allocate and init the threads. */
   if ((e->runners = (struct runner *)malloc(sizeof(struct runner) *
diff --git a/src/scheduler.h b/src/scheduler.h
index 86c6dd0c51..26ac9fab1d 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -105,7 +105,7 @@ struct scheduler {
     
   /* Maximum size of task messages, in bytes, to sent using non-buffered
    * MPI. */
-  int mpi_message_limit;
+  size_t mpi_message_limit;
 
   /* 'Pointer' to the seed for the random number generator */
   pthread_key_t local_seed_pointer;
-- 
GitLab