Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add memset(0) for shared calloc.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 9 Jun 2021 15:21:48 +0000 (17:21 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 9 Jun 2021 15:21:48 +0000 (17:21 +0200)
Add missing barrier to auto-shared test.

src/smpi/internals/smpi_shared.cpp
teshsuite/smpi/auto-shared/auto-shared.c

index 9cd9c42..4af2c2f 100644 (file)
@@ -319,17 +319,18 @@ void* smpi_shared_malloc_intercept(size_t size, const char* file, int line)
 
 void* smpi_shared_calloc_intercept(size_t num_elm, size_t elem_size, const char* file, int line)
 {
-  if( smpi_cfg_auto_shared_malloc_thresh() == 0 || elem_size*num_elm < smpi_cfg_auto_shared_malloc_thresh()){
-    void* ptr = ::operator new(elem_size*num_elm);
+  size_t size = elem_size * num_elm;
+  if (smpi_cfg_auto_shared_malloc_thresh() == 0 || size < smpi_cfg_auto_shared_malloc_thresh()) {
+    void* ptr = ::operator new(size);
     if(not smpi_cfg_trace_call_use_absolute_path())
-      simgrid::smpi::utils::account_malloc_size(elem_size*num_elm, simgrid::xbt::Path(file).get_base_name(), line, ptr);
+      simgrid::smpi::utils::account_malloc_size(size, simgrid::xbt::Path(file).get_base_name(), line, ptr);
     else
-      simgrid::smpi::utils::account_malloc_size(elem_size*num_elm, file, line, ptr);
-    memset(ptr, 0, elem_size*num_elm);
+      simgrid::smpi::utils::account_malloc_size(size, file, line, ptr);
+    memset(ptr, 0, size);
     return ptr;
   } else {
-    simgrid::smpi::utils::account_shared_size(elem_size*num_elm);
-    return smpi_shared_malloc(elem_size*num_elm, file, line);
+    simgrid::smpi::utils::account_shared_size(size);
+    return memset(smpi_shared_malloc(size, file, line), 0, size);
   }
 }
 
index 9bc350f..b32153e 100644 (file)
@@ -34,6 +34,8 @@ int main(int argc, char *argv[])
   MPI_Comm_size(MPI_COMM_WORLD, &size);
   //Let's Allocate a memory buffer
   uint64_t* buf = calloc(1, sizeof(uint64_t));
+
+  MPI_Barrier(MPI_COMM_WORLD);
   //one writes data in it
   if(rank==0){
     *buf=size;