+
+
+
+ return MPI_SUCCESS;
+}
+
+int smpi_mpi_win_start(MPI_Group group, int assert, MPI_Win win){
+ /* From MPI forum advices
+ The call to MPI_WIN_COMPLETE does not return until the put call has completed at
+ the origin; and the target window will be accessed by the put operation only
+ after the call to MPI_WIN_START has matched a call to MPI_WIN_POST by the target
+ process. This still leaves much choice to implementors. The call to
+ MPI_WIN_START can block until the matching call to MPI_WIN_POST occurs at all
+ target processes. One can also have implementations where the call to
+ MPI_WIN_START is nonblocking, but the call to MPI_PUT blocks until the matching
+ call to MPI_WIN_POST occurred; or implementations where the first two calls are
+ nonblocking, but the call to MPI_WIN_COMPLETE blocks until the call to
+ MPI_WIN_POST occurred; or even implementations where all three calls can
+ complete before any target process called MPI_WIN_POST --- the data put must be
+ buffered, in this last case, so as to allow the put to complete at the origin
+ ahead of its completion at the target. However, once the call to MPI_WIN_POST is
+ issued, the sequence above must complete, without further dependencies.
+ */
+
+ //naive, blocking implementation.
+ int i=0,j=0;
+ int size = smpi_group_size(group);
+ MPI_Request* reqs = xbt_new0(MPI_Request, size);
+
+// for(i=0;i<size;i++){
+ while(j!=size){
+ int src=smpi_group_index(group,j);
+ if(src!=smpi_process_index()){
+ reqs[i]=smpi_irecv_init(NULL, 0, MPI_CHAR, src,RMA_TAG+4, MPI_COMM_WORLD);
+ i++;
+ }
+ j++;
+ }
+ size=i;
+ smpi_mpi_startall(size, reqs);
+ smpi_mpi_waitall(size, reqs, MPI_STATUSES_IGNORE);
+ for(i=0;i<size;i++){
+ smpi_mpi_request_free(&reqs[i]);
+ }
+ xbt_free(reqs);
+ win->opened++; //we're open for business !
+ win->group=group;
+ smpi_group_use(group);
+ return MPI_SUCCESS;
+}
+
+int smpi_mpi_win_post(MPI_Group group, int assert, MPI_Win win){
+ //let's make a synchronous send here
+ int i=0,j=0;
+ int size = smpi_group_size(group);
+ MPI_Request* reqs = xbt_new0(MPI_Request, size);
+
+ while(j!=size){
+ int dst=smpi_group_index(group,j);
+ if(dst!=smpi_process_index()){
+ reqs[i]=smpi_mpi_send_init(NULL, 0, MPI_CHAR, dst,
+ RMA_TAG+4, MPI_COMM_WORLD);
+ i++;
+ }
+ j++;
+ }
+ size=i;
+
+ smpi_mpi_startall(size, reqs);
+ smpi_mpi_waitall(size, reqs, MPI_STATUSES_IGNORE);
+ for(i=0;i<size;i++){
+ smpi_mpi_request_free(&reqs[i]);
+ }
+ xbt_free(reqs);
+ win->opened++; //we're open for business !
+ win->group=group;
+ smpi_group_use(group);
+ return MPI_SUCCESS;
+}