- int File::read(MPI_File fh, void* /*buf*/, int count, MPI_Datatype datatype, MPI_Status* status)
- {
- //get position first as we may be doing non contiguous reads and it will probably be updated badly
- MPI_Offset position = fh->file_->tell();
- MPI_Offset movesize = datatype->get_extent()*count;
- MPI_Offset readsize = datatype->size()*count;
- XBT_DEBUG("Position before read in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());
- MPI_Offset read = fh->file_->read(readsize);
- XBT_VERB("Read in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", fh->file_->get_path(), read, readsize, movesize);
- if(readsize!=movesize){
- fh->file_->seek(position+movesize, SEEK_SET);
- }
- XBT_VERB("Position after read in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell());
- if(status != MPI_STATUS_IGNORE)
- status->count=count*datatype->size();
- return MPI_SUCCESS;
+/*Ordered and Shared Versions, with RMA-based locks : Based on the model described in :*/
+/* @InProceedings{10.1007/11557265_15,*/
+/* author="Latham, Robert and Ross, Robert and Thakur, Rajeev and Toonen, Brian",*/
+/* title="Implementing MPI-IO Shared File Pointers Without File System Support",*/
+/* booktitle="Recent Advances in Parallel Virtual Machine and Message Passing Interface",*/
+/* year="2005",*/
+/* publisher="Springer Berlin Heidelberg",*/
+/* address="Berlin, Heidelberg",*/
+/* pages="84--93"*/
+/* }*/
+int File::read_shared(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status)
+{
+ fh->shared_mutex_->lock();
+ fh->seek(*(fh->shared_file_pointer_), MPI_SEEK_SET);
+ read(fh, buf, count, datatype, status);
+ *(fh->shared_file_pointer_) = fh->file_->tell();
+ fh->shared_mutex_->unlock();
+ return MPI_SUCCESS;
+}
+
+int File::read_ordered(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status)
+{
+ // 0 needs to get the shared pointer value
+ MPI_Offset val;
+ if (fh->comm_->rank() == 0) {
+ val = *(fh->shared_file_pointer_);
+ } else {
+ val = count * datatype->size();