Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the communication optimization.
authorTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Fri, 7 Apr 2017 12:32:15 +0000 (14:32 +0200)
committerTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Fri, 7 Apr 2017 12:32:15 +0000 (14:32 +0200)
src/smpi/smpi_shared.cpp
teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c
teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.tesh

index 0aacb65..e629da9 100644 (file)
@@ -353,7 +353,8 @@ int smpi_is_shared(void* ptr, std::vector<std::pair<int, int>> &private_blocks,
       return 0;
     low --;
     if (ptr < (char*)low->first + low->second.size) {
-      *offset = ((uint8_t*) low->first) - ((uint8_t*)ptr);
+      xbt_assert(ptr > (char*)low->first, "Oops, there seems to be a bug in the shared memory metadata.");
+      *offset = ((uint8_t*)ptr) - ((uint8_t*) low->first);
       private_blocks = low->second.private_blocks;
       return 1;
     }
index f5461c4..2a93238 100644 (file)
@@ -91,7 +91,30 @@ int main(int argc, char *argv[])
       int start = shared_blocks[2*i+1];
       int stop = shared_blocks[2*i+2];
       int comm = check_all(buf, start, stop, rank-1);
-      printf("[%d] The result of the communication check for block (0x%x, 0x%x) is: %d\n", rank, start, stop, comm);
+      printf("[%d] The result of the (normal) communication check for block (0x%x, 0x%x) is: %d\n", rank, start, stop, comm);
+    }
+    memset(buf, rank, mem_size);
+  }
+
+  MPI_Barrier(MPI_COMM_WORLD);
+
+  // Then, even processes send a sub-part of their buffer their successor
+  // Note that the part (0, 0x10000) which is not sent is a shared part, so we do not care
+  if(rank%2 == 0) {
+    MPI_Send(buf+0x10000, mem_size-0x10000, MPI_UINT8_T, rank+1, 0, MPI_COMM_WORLD);
+  }
+  else {
+    MPI_Recv(buf+0x10000, mem_size-0x10000, MPI_UINT8_T, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+  }
+
+
+  // Odd processes verify that they successfully received the message
+  if(rank%2 == 1) {
+    for(int i = 0; i < nb_blocks-1; i++) {
+      int start = shared_blocks[2*i+1];
+      int stop = shared_blocks[2*i+2];
+      int comm = check_all(buf, start, stop, rank-1);
+      printf("[%d] The result of the (shifted) communication check for block (0x%x, 0x%x) is: %d\n", rank, start, stop, comm);
     }
   }
 
index c129aca..2cf32cf 100644 (file)
@@ -3,13 +3,23 @@ p Test compute
 ! output sort
 ! timeout 5
 $ ${bindir:=.}/../../../bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-partial-shared-communication --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
-> [3] The result of the communication check for block (0x1234567, 0x1300000) is: 1
-> [3] The result of the communication check for block (0x1300010, 0x3456789) is: 1
-> [3] The result of the communication check for block (0x3457890, 0x4444444) is: 1
-> [3] The result of the communication check for block (0x5555555, 0x5555565) is: 1
-> [3] The result of the communication check for block (0x5600000, 0x8000000) is: 1
-> [1] The result of the communication check for block (0x1234567, 0x1300000) is: 1
-> [1] The result of the communication check for block (0x1300010, 0x3456789) is: 1
-> [1] The result of the communication check for block (0x3457890, 0x4444444) is: 1
-> [1] The result of the communication check for block (0x5555555, 0x5555565) is: 1
-> [1] The result of the communication check for block (0x5600000, 0x8000000) is: 1
+> [3] The result of the (normal) communication check for block (0x1234567, 0x1300000) is: 1
+> [3] The result of the (normal) communication check for block (0x1300010, 0x3456789) is: 1
+> [3] The result of the (normal) communication check for block (0x3457890, 0x4444444) is: 1
+> [3] The result of the (normal) communication check for block (0x5555555, 0x5555565) is: 1
+> [3] The result of the (normal) communication check for block (0x5600000, 0x8000000) is: 1
+> [1] The result of the (normal) communication check for block (0x1234567, 0x1300000) is: 1
+> [1] The result of the (normal) communication check for block (0x1300010, 0x3456789) is: 1
+> [1] The result of the (normal) communication check for block (0x3457890, 0x4444444) is: 1
+> [1] The result of the (normal) communication check for block (0x5555555, 0x5555565) is: 1
+> [1] The result of the (normal) communication check for block (0x5600000, 0x8000000) is: 1
+> [3] The result of the (shifted) communication check for block (0x1234567, 0x1300000) is: 1
+> [3] The result of the (shifted) communication check for block (0x1300010, 0x3456789) is: 1
+> [3] The result of the (shifted) communication check for block (0x3457890, 0x4444444) is: 1
+> [3] The result of the (shifted) communication check for block (0x5555555, 0x5555565) is: 1
+> [3] The result of the (shifted) communication check for block (0x5600000, 0x8000000) is: 1
+> [1] The result of the (shifted) communication check for block (0x1234567, 0x1300000) is: 1
+> [1] The result of the (shifted) communication check for block (0x1300010, 0x3456789) is: 1
+> [1] The result of the (shifted) communication check for block (0x3457890, 0x4444444) is: 1
+> [1] The result of the (shifted) communication check for block (0x5555555, 0x5555565) is: 1
+> [1] The result of the (shifted) communication check for block (0x5600000, 0x8000000) is: 1