+ /*Ordered and Shared Versions, with RMA-based locks : Based on the model described in :*/\r
+ /* @InProceedings{10.1007/11557265_15,*/\r
+ /* author="Latham, Robert and Ross, Robert and Thakur, Rajeev and Toonen, Brian",*/ \r
+ /* title="Implementing MPI-IO Shared File Pointers Without File System Support",*/\r
+ /* booktitle="Recent Advances in Parallel Virtual Machine and Message Passing Interface",*/\r
+ /* year="2005",*/\r
+ /* publisher="Springer Berlin Heidelberg",*/\r
+ /* address="Berlin, Heidelberg",*/\r
+ /* pages="84--93"*/\r
+ /* }*/\r
+ int File::read_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){\r
+ fh->shared_mutex_->lock();\r
+ fh->seek(*(fh->shared_file_pointer_),MPI_SEEK_SET);\r
+ read(fh, buf, count, datatype, status);\r
+ *(fh->shared_file_pointer_)=fh->file_->tell();\r
+ fh->shared_mutex_->unlock();\r
+ return MPI_SUCCESS;\r
+ }\r
+\r
+ int File::read_ordered(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){\r
+ //0 needs to get the shared pointer value\r
+ MPI_Offset val;\r
+ if(fh->comm_->rank()==0){\r
+ val=*(fh->shared_file_pointer_);\r
+ }else{\r
+ val=count*datatype->size();\r
+ }\r
+\r
+ MPI_Offset result;\r
+ simgrid::smpi::Colls::scan(&val, &result, 1, MPI_OFFSET, MPI_SUM, fh->comm_);\r
+ fh->seek(result, MPI_SEEK_SET);\r
+ int ret = fh->op_all<simgrid::smpi::File::read>(buf, count, datatype, status);\r
+ if(fh->comm_->rank()==fh->comm_->size()-1){\r
+ fh->shared_mutex_->lock();\r
+ *(fh->shared_file_pointer_)=fh->file_->tell();\r
+ fh->shared_mutex_->unlock();\r
+ }\r
+ char c;\r
+ simgrid::smpi::Colls::bcast(&c, 1, MPI_BYTE, fh->comm_->size()-1, fh->comm_);\r
+ return ret;\r
+ }\r