Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
provide support for SMP in MPI communicators.
[simgrid.git] / src / smpi / smpi_rma.c
index 7c7d867..72f4cc7 100644 (file)
@@ -23,6 +23,7 @@ typedef struct s_smpi_mpi_win{
   xbt_dynar_t requests;
   xbt_bar_t bar;
   MPI_Win* connected_wins;
+  char* name;
 } s_smpi_mpi_win_t;
 
 
@@ -41,6 +42,7 @@ MPI_Win smpi_mpi_win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info
   win->assert = 0;
   //win->info = info;
   win->comm = comm;
+  win->name = NULL;
   win->requests = xbt_dynar_new(sizeof(MPI_Request), NULL);
   win->connected_wins = xbt_malloc0(comm_size*sizeof(MPI_Win));
   win->connected_wins[rank] = win;
@@ -74,11 +76,28 @@ int smpi_mpi_win_free( MPI_Win* win){
   xbt_barrier_wait((*win)->bar);
   xbt_dynar_free(&(*win)->requests);
   xbt_free((*win)->connected_wins);
+  if ((*win)->name != NULL){
+    xbt_free((*win)->name);
+  }
   xbt_free(*win);
   win = MPI_WIN_NULL;
   return MPI_SUCCESS;
 }
 
+void smpi_mpi_win_get_name(MPI_Win win, char* name, int* length){
+  if(win->name==NULL){
+    *length=0;
+    name=NULL;
+    return;
+  }
+  *length = strlen(win->name);
+  strcpy(name, win->name);
+}
+
+void smpi_mpi_win_set_name(MPI_Win win, char* name){
+  win->name = strdup(name);;
+}
+
 
 int smpi_mpi_win_fence( int assert,  MPI_Win win){
 
@@ -165,7 +184,10 @@ int smpi_mpi_get( void *origin_addr, int origin_count, MPI_Datatype origin_datat
     //prepare receiver request
     MPI_Request rreq = smpi_rma_recv_init(origin_addr, origin_count, origin_datatype,
         smpi_group_index(smpi_comm_group(win->comm),target_rank), smpi_process_index(), RMA_TAG+2, win->comm, MPI_OP_NULL);
-
+        
+    //start the send, with another process than us as sender. 
+    smpi_mpi_start(sreq);
+    
     //push request to receiver's win
     xbt_dynar_push_as(send_win->requests, MPI_Request, sreq);