X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e5679b57719f0adbb09bb3a59f03d71bb5c227d9..98755faee042e94d1ff52f6e9508b18015bb1ae5:/src/smpi/include/smpi_file.hpp diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp index e90b48bc39..3feb57f696 100644 --- a/src/smpi/include/smpi_file.hpp +++ b/src/smpi/include/smpi_file.hpp @@ -10,6 +10,7 @@ #include "smpi_comm.hpp" #include "smpi_coll.hpp" #include "smpi_datatype.hpp" +#include "smpi_errhandler.hpp" #include "smpi_info.hpp" #include @@ -26,8 +27,10 @@ class File{ s4u::MutexPtr shared_mutex_; MPI_Win win_; char* list_; + MPI_Errhandler errhandler_; + public: - File(MPI_Comm comm, char *filename, int amode, MPI_Info info); + File(MPI_Comm comm, const char *filename, int amode, MPI_Info info); File(const File&) = delete; File& operator=(const File&) = delete; ~File(); @@ -35,6 +38,7 @@ class File{ int get_position(MPI_Offset* offset); int get_position_shared(MPI_Offset* offset); int flags(); + MPI_Comm comm(); int sync(); int seek(MPI_Offset offset, int whence); int seek_shared(MPI_Offset offset, int whence); @@ -44,11 +48,13 @@ class File{ static int read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); static int read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); static int write(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); - static int write_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); - static int write_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); + static int write_shared(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status); + static int write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status); template int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status); static int close(MPI_File *fh); - static int del(char *filename, MPI_Info info); + static int del(const char *filename, MPI_Info info); + MPI_Errhandler errhandler(); + void set_errhandler( MPI_Errhandler errhandler); }; /* Read_all, Write_all : loosely based on */ @@ -66,8 +72,8 @@ class File{ int rank = comm_-> rank(); MPI_Offset min_offset = file_->tell(); MPI_Offset max_offset = (min_offset + count * datatype->size());//cheating, as we don't care about exact data location, we can skip extent - MPI_Offset* min_offsets = xbt_new(MPI_Offset, size); - MPI_Offset* max_offsets = xbt_new(MPI_Offset, size); + MPI_Offset* min_offsets = new MPI_Offset[size]; + MPI_Offset* max_offsets = new MPI_Offset[size]; simgrid::smpi::Colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_); simgrid::smpi::Colls::allgather(&max_offset, 1, MPI_OFFSET, max_offsets, 1, MPI_OFFSET, comm_); MPI_Offset min=min_offset; @@ -86,11 +92,15 @@ class File{ XBT_CDEBUG(smpi_pmpi, "my offsets to read : %lld:%lld, global min and max %lld:%lld", min_offset, max_offset, min, max); if(empty==1){ + delete[] min_offsets; + delete[] max_offsets; status->count=0; return MPI_SUCCESS; } MPI_Offset total = max-min; if(total==tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)){ + delete[] min_offsets; + delete[] max_offsets; //contiguous. Just have each proc perform its read status->count=count * datatype->size(); return T(this,buf,count,datatype, status); @@ -100,18 +110,19 @@ class File{ MPI_Offset my_chunk_start=(max-min+1)/size*rank; MPI_Offset my_chunk_end=((max-min+1)/size*(rank+1)); XBT_CDEBUG(smpi_pmpi, "my chunks to read : %lld:%lld", my_chunk_start, my_chunk_end); - int* send_sizes = xbt_new0(int, size); - int* recv_sizes = xbt_new(int, size); - int* send_disps = xbt_new(int, size); - int* recv_disps = xbt_new(int, size); + int* send_sizes = new int[size]; + int* recv_sizes = new int[size]; + int* send_disps = new int[size]; + int* recv_disps = new int[size]; int total_sent=0; for(int i=0;irecv as we use recv buffer if((my_chunk_start>=min_offsets[i] && my_chunk_start < max_offsets[i])|| ((my_chunk_end<=max_offsets[i]) && my_chunk_end> min_offsets[i])){ send_sizes[i]=(std::min(max_offsets[i]-1, my_chunk_end-1)-std::max(min_offsets[i], my_chunk_start)); //store min and max offest to actually read min_offset=std::min(min_offset, min_offsets[i]); - send_disps[i]=0;//send_sizes[i]; cheat to avoid issues when send>recv as we use recv buffer total_sent+=send_sizes[i]; XBT_CDEBUG(smpi_pmpi, "will have to send %d bytes to %d", send_sizes[i], i); } @@ -154,7 +165,7 @@ class File{ } XBT_CDEBUG(smpi_pmpi, "will have to access %lld from my chunk", totreads); - char* sendbuf= static_cast(smpi_get_tmp_sendbuffer(total_sent)); + unsigned char* sendbuf = smpi_get_tmp_sendbuffer(total_sent); if(totreads>0){ seek(min_offset, MPI_SEEK_SET); @@ -171,12 +182,12 @@ class File{ buf, recv_sizes, recv_disps, MPI_BYTE, comm_); status->count=count * datatype->size(); smpi_free_tmp_buffer(sendbuf); - xbt_free(send_sizes); - xbt_free(recv_sizes); - xbt_free(send_disps); - xbt_free(recv_disps); - xbt_free(min_offsets); - xbt_free(max_offsets); + delete[] send_sizes; + delete[] recv_sizes; + delete[] send_disps; + delete[] recv_disps; + delete[] min_offsets; + delete[] max_offsets; return MPI_SUCCESS; } }