From b198c6cbc53b4af4d9b946fda7094ab177b544fc Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Sat, 16 Jan 2021 12:36:43 +0000
Subject: [PATCH] added store memaddr per thread

---
 binarycpython/utils/grid.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index c6d8d3dc2..2a71994db 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -892,6 +892,9 @@ class Population:
                 self.process_ID: persistent_data_memaddr
             }
 
+        # lets try out making stores for all the grids:
+        self.grid_options["_store_memaddr"] = _binary_c_bindings.return_store_memaddr()
+
         # apparently we have to re-load this for every process, otherwise NameErrors arise (seems like a bug but I'm not sure)
         self._load_grid_function()
 
@@ -911,7 +914,7 @@ class Population:
         )
 
         verbose_print(
-            "Process {} started at {}".format(ID, datetime.datetime.now().isoformat()), self.grid_options["verbosity"], 0
+            "Process {} started at {}. Using store memaddr {}".format(ID, datetime.datetime.now().isoformat(), self.grid_options["_store_memaddr"]), self.grid_options["verbosity"], 0
         )
 
         round_number_mod = 0
@@ -1005,6 +1008,10 @@ class Population:
                 with open(output_file, "w") as f:
                     f.write(ensemble_raw_output)
 
+        # free store mem:
+        _binary_c_bindings.free_store_memaddr(self.grid_options["_store_memaddr"])
+
+
         # Return a set of results and errors
         output_dict = {
             "results": self.grid_options["results"],
-- 
GitLab