Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
activate some more rma tests
[simgrid.git] / teshsuite / smpi / mpich3-test / rma / linked_list_bench_lock_excl.c
index c52208e..607ca12 100644 (file)
 #include <unistd.h>
 #endif
 
 #include <unistd.h>
 #endif
 
-#define NUM_ELEMS 1000
+#define NUM_ELEMS 100
 #define MAX_NPROBE nproc
 #define MIN_NPROBE 1
 #define ELEM_PER_ROW 16
 
 #define MAX_NPROBE nproc
 #define MIN_NPROBE 1
 #define ELEM_PER_ROW 16
 
-#define MIN(X,Y) ((X < Y) ? (X) : (Y))
-#define MAX(X,Y) ((X > Y) ? (X) : (Y))
+#define MYMIN(X,Y) ((X < Y) ? (X) : (Y))
+#define MYMAX(X,Y) ((X > Y) ? (X) : (Y))
 
 /* Linked list pointer */
 typedef struct {
 
 /* Linked list pointer */
 typedef struct {
@@ -48,13 +48,8 @@ static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
 static const int verbose = 0;
 static const int print_perf = 0;
 
 static const int verbose = 0;
 static const int print_perf = 0;
 
-/* List of locally allocated list elements. */
-static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
-static int my_elems_count = 0;
-
 /* Allocate a new shared linked list element */
 /* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win)
+static MPI_Aint alloc_elem(int value, MPI_Win win, llist_elem_t ***my_elems, int* my_elems_size, int* my_elems_count)
 {
     MPI_Aint disp;
     llist_elem_t *elem_ptr;
 {
     MPI_Aint disp;
     llist_elem_t *elem_ptr;
@@ -66,12 +61,12 @@ MPI_Aint alloc_elem(int value, MPI_Win win)
     MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
 
     /* Add the element to the list of local elements so we can free it later. */
     MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
 
     /* Add the element to the list of local elements so we can free it later. */
-    if (my_elems_size == my_elems_count) {
-        my_elems_size += 100;
-        my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
+    if (*my_elems_size == *my_elems_count) {
+        *my_elems_size += 100;
+        *my_elems = realloc(*my_elems, *my_elems_size * sizeof(void *));
     }
     }
-    my_elems[my_elems_count] = elem_ptr;
-    my_elems_count++;
+    (*my_elems)[*my_elems_count] = elem_ptr;
+    (*my_elems_count)++;
 
     MPI_Get_address(elem_ptr, &disp);
     return disp;
 
     MPI_Get_address(elem_ptr, &disp);
     return disp;
@@ -84,6 +79,10 @@ int main(int argc, char **argv)
     double time;
     MPI_Win llist_win;
     llist_ptr_t head_ptr, tail_ptr;
     double time;
     MPI_Win llist_win;
     llist_ptr_t head_ptr, tail_ptr;
+    /* List of locally allocated list elements. */
+    llist_elem_t **my_elems = NULL;
+    int my_elems_size = 0;
+    int my_elems_count = 0;
 
     MPI_Init(&argc, &argv);
 
 
     MPI_Init(&argc, &argv);
 
@@ -94,7 +93,7 @@ int main(int argc, char **argv)
 
     /* Process 0 creates the head node */
     if (procid == 0)
 
     /* Process 0 creates the head node */
     if (procid == 0)
-        head_ptr.disp = alloc_elem(procid, llist_win);
+        head_ptr.disp = alloc_elem(procid, llist_win, &my_elems, &my_elems_size, &my_elems_count);
 
     /* Broadcast the head pointer to everyone */
     head_ptr.rank = 0;
 
     /* Broadcast the head pointer to everyone */
     head_ptr.rank = 0;
@@ -122,7 +121,7 @@ int main(int argc, char **argv)
 
         /* Create a new list element and register it with the window */
         new_elem_ptr.rank = procid;
 
         /* Create a new list element and register it with the window */
         new_elem_ptr.rank = procid;
-        new_elem_ptr.disp = alloc_elem(procid, llist_win);
+        new_elem_ptr.disp = alloc_elem(procid, llist_win, &my_elems, &my_elems_size, &my_elems_count);
 
         /* Append the new node to the list.  This might take multiple attempts if
          * others have already appended and our tail pointer is stale. */
 
         /* Append the new node to the list.  This might take multiple attempts if
          * others have already appended and our tail pointer is stale. */
@@ -173,14 +172,14 @@ int main(int argc, char **argv)
                         printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank,
                                (void *) next_tail_ptr.disp);
                     tail_ptr = next_tail_ptr;
                         printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank,
                                (void *) next_tail_ptr.disp);
                     tail_ptr = next_tail_ptr;
-                    pollint = MAX(MIN_NPROBE, pollint / 2);
+                    pollint = MYMAX(MIN_NPROBE, pollint / 2);
                 }
                 else {
                     for (j = 0; j < pollint; j++)
                         MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
                                    MPI_STATUS_IGNORE);
 
                 }
                 else {
                     for (j = 0; j < pollint; j++)
                         MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
                                    MPI_STATUS_IGNORE);
 
-                    pollint = MIN(MAX_NPROBE, pollint * 2);
+                    pollint = MYMIN(MAX_NPROBE, pollint * 2);
                 }
             }
         } while (!success);
                 }
             }
         } while (!success);