+int PMPI_Win_allocate_shared( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
+ int retval = 0;
+ smpi_bench_end();
+ if (comm == MPI_COMM_NULL) {
+ retval= MPI_ERR_COMM;
+ }else if (disp_unit <= 0 || size < 0 ){
+ retval= MPI_ERR_OTHER;
+ }else{
+ void* ptr = nullptr;
+ int rank = comm->rank();
+ if(rank==0){
+ ptr = xbt_malloc(size*comm->size());
+ if(ptr==nullptr)
+ return MPI_ERR_NO_MEM;
+ }
+
+ simgrid::smpi::colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
+ simgrid::smpi::colls::barrier(comm);
+
+ *static_cast<void**>(base) = (char*)ptr+rank*size;
+ *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin();
+ return retval;
+}
+