-namespace simgrid{
-namespace smpi{
-
- File::File(MPI_Comm comm, char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
- file_= new simgrid::s4u::File(filename, nullptr);
- list_=nullptr;
- if (comm_->rank() == 0) {
- int size= comm_->size() + FP_SIZE;
- list_ = new char[size];
- memset(list_, 0, size);
- shared_file_pointer_ = new MPI_Offset();
- shared_mutex_ = s4u::Mutex::create();
- *shared_file_pointer_ = 0;
- win_=new Win(list_, size, 1, MPI_INFO_NULL, comm_);
- }else{
- win_=new Win(list_, 0, 1, MPI_INFO_NULL, comm_);
- }
- simgrid::smpi::Colls::bcast(&shared_file_pointer_, 1, MPI_AINT, 0, comm);
- simgrid::smpi::Colls::bcast(&shared_mutex_, 1, MPI_AINT, 0, comm);
- if(comm_->rank() != 0)
- intrusive_ptr_add_ref(&*shared_mutex_);
- }