Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups debug messages for read_all write_all
authorAugustin Degomme <adegomme@users.noreply.github.com>
Thu, 18 Apr 2019 11:39:20 +0000 (13:39 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Thu, 18 Apr 2019 11:39:20 +0000 (13:39 +0200)
src/smpi/include/smpi_file.hpp
src/smpi/mpi/smpi_file.cpp

index d00a97c..5a41b65 100644 (file)
@@ -63,7 +63,7 @@ class File{
     int size =  comm_->size();\r
     int rank = comm_-> rank();\r
     MPI_Offset min_offset = file_->tell();\r
     int size =  comm_->size();\r
     int rank = comm_-> rank();\r
     MPI_Offset min_offset = file_->tell();\r
-    MPI_Offset max_offset = min_offset + count * datatype->size();//cheating, as we don't care about exact data location, we can skip extent\r
+    MPI_Offset max_offset = (min_offset + count * datatype->size());//cheating, as we don't care about exact data location, we can skip extent\r
     MPI_Offset* min_offsets = xbt_new(MPI_Offset, size);\r
     MPI_Offset* max_offsets = xbt_new(MPI_Offset, size);\r
     simgrid::smpi::Colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_);\r
     MPI_Offset* min_offsets = xbt_new(MPI_Offset, size);\r
     MPI_Offset* max_offsets = xbt_new(MPI_Offset, size);\r
     simgrid::smpi::Colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_);\r
@@ -71,22 +71,33 @@ class File{
     MPI_Offset min=min_offset;\r
     MPI_Offset max=max_offset;\r
     MPI_Offset tot= 0;\r
     MPI_Offset min=min_offset;\r
     MPI_Offset max=max_offset;\r
     MPI_Offset tot= 0;\r
+    int empty=1;\r
     for(int i=0;i<size;i++){\r
     for(int i=0;i<size;i++){\r
+      if(min_offsets[i]!=max_offsets[i])\r
+        empty=0;\r
       tot+=(max_offsets[i]-min_offsets[i]);\r
       if(min_offsets[i]<min)\r
         min=min_offsets[i];\r
       if(max_offsets[i]>max)\r
         max=max_offsets[i];\r
     }\r
       tot+=(max_offsets[i]-min_offsets[i]);\r
       if(min_offsets[i]<min)\r
         min=min_offsets[i];\r
       if(max_offsets[i]>max)\r
         max=max_offsets[i];\r
     }\r
+    \r
+    XBT_DEBUG("my offsets to read : %lld:%lld, global min and max %lld:%lld", min_offset, max_offset, min, max);\r
+    if(empty==1){\r
+      status->count=0;\r
+      return MPI_SUCCESS;\r
+    }\r
     MPI_Offset total = max-min;\r
     if(total==tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)){\r
       //contiguous. Just have each proc perform its read\r
     MPI_Offset total = max-min;\r
     if(total==tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)){\r
       //contiguous. Just have each proc perform its read\r
+      status->count=count * datatype->size();\r
       return T(this,buf,count,datatype, status);\r
     }\r
 \r
     //Interleaved case : How much do I need to read, and whom to send it ?\r
       return T(this,buf,count,datatype, status);\r
     }\r
 \r
     //Interleaved case : How much do I need to read, and whom to send it ?\r
-    MPI_Offset my_chunk_start=(max-min)/size*rank;\r
-    MPI_Offset my_chunk_end=((max-min)/size*(rank+1))-1;\r
+    MPI_Offset my_chunk_start=(max-min+1)/size*rank;\r
+    MPI_Offset my_chunk_end=((max-min+1)/size*(rank+1));\r
+    XBT_DEBUG("my chunks to read : %lld:%lld", my_chunk_start, my_chunk_end);\r
     int* send_sizes = xbt_new0(int, size);\r
     int* recv_sizes = xbt_new(int, size);\r
     int* send_disps = xbt_new(int, size);\r
     int* send_sizes = xbt_new0(int, size);\r
     int* recv_sizes = xbt_new(int, size);\r
     int* send_disps = xbt_new(int, size);\r
@@ -95,14 +106,15 @@ class File{
     for(int i=0;i<size;i++){\r
       if((my_chunk_start>=min_offsets[i] && my_chunk_start < max_offsets[i])||\r
           ((my_chunk_end<=max_offsets[i]) && my_chunk_end> min_offsets[i])){\r
     for(int i=0;i<size;i++){\r
       if((my_chunk_start>=min_offsets[i] && my_chunk_start < max_offsets[i])||\r
           ((my_chunk_end<=max_offsets[i]) && my_chunk_end> min_offsets[i])){\r
-        send_sizes[i]=(std::min(max_offsets[i], my_chunk_end+1)-std::max(min_offsets[i], my_chunk_start));\r
+        send_sizes[i]=(std::min(max_offsets[i]-1, my_chunk_end-1)-std::max(min_offsets[i], my_chunk_start));\r
         //store min and max offest to actually read\r
         //store min and max offest to actually read\r
-        min_offset=std::max(min_offsets[i], my_chunk_start);\r
-        max_offset=std::min(max_offsets[i], my_chunk_end+1);\r
+        min_offset=std::min(min_offset, min_offsets[i]);\r
         send_disps[i]=0;//send_sizes[i]; cheat to avoid issues when send>recv as we use recv buffer\r
         total_sent+=send_sizes[i];\r
         send_disps[i]=0;//send_sizes[i]; cheat to avoid issues when send>recv as we use recv buffer\r
         total_sent+=send_sizes[i];\r
+        XBT_DEBUG("will have to send %d bytes to %d", send_sizes[i], i);\r
       }\r
     }\r
       }\r
     }\r
+    min_offset=std::max(min_offset, my_chunk_start);\r
 \r
     //merge the ranges of every process\r
     std::vector<std::pair<MPI_Offset, MPI_Offset>> ranges;\r
 \r
     //merge the ranges of every process\r
     std::vector<std::pair<MPI_Offset, MPI_Offset>> ranges;\r
@@ -136,8 +148,10 @@ class File{
       else if (chunks[i].first > my_chunk_end)\r
         continue;\r
       else\r
       else if (chunks[i].first > my_chunk_end)\r
         continue;\r
       else\r
-        totreads += (std::min(chunks[i].second, my_chunk_end+1)-std::max(chunks[i].first, my_chunk_start));\r
+        totreads += (std::min(chunks[i].second, my_chunk_end-1)-std::max(chunks[i].first, my_chunk_start));\r
     }\r
     }\r
+    XBT_DEBUG("will have to access %lld from my chunk", totreads);\r
+\r
     char* sendbuf= static_cast<char *>(smpi_get_tmp_sendbuffer(totreads));\r
 \r
     if(totreads>0){\r
     char* sendbuf= static_cast<char *>(smpi_get_tmp_sendbuffer(totreads));\r
 \r
     if(totreads>0){\r
@@ -153,6 +167,7 @@ class File{
     //Set buf value to avoid copying dumb data\r
     simgrid::smpi::Colls::alltoallv(sendbuf, send_sizes, send_disps, MPI_BYTE,\r
                               buf, recv_sizes, recv_disps, MPI_BYTE, comm_);\r
     //Set buf value to avoid copying dumb data\r
     simgrid::smpi::Colls::alltoallv(sendbuf, send_sizes, send_disps, MPI_BYTE,\r
                               buf, recv_sizes, recv_disps, MPI_BYTE, comm_);\r
+    status->count=count * datatype->size();\r
     smpi_free_tmp_buffer(sendbuf);\r
     xbt_free(send_sizes);\r
     xbt_free(recv_sizes);\r
     smpi_free_tmp_buffer(sendbuf);\r
     xbt_free(send_sizes);\r
     xbt_free(recv_sizes);\r
index dccfea5..d5717ee 100644 (file)
@@ -9,11 +9,13 @@
 #include "smpi_datatype.hpp"\r
 #include "smpi_info.hpp"\r
 #include "smpi_win.hpp"\r
 #include "smpi_datatype.hpp"\r
 #include "smpi_info.hpp"\r
 #include "smpi_win.hpp"\r
+//setup here, because we have templates in smpi_file we want to log\r
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)");\r
+\r
 #include "smpi_file.hpp"\r
 #include "smpi_status.hpp"\r
 #include "simgrid/plugins/file_system.h"\r
 \r
 #include "smpi_file.hpp"\r
 #include "smpi_status.hpp"\r
 #include "simgrid/plugins/file_system.h"\r
 \r
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)");\r
 #define FP_SIZE sizeof(MPI_Offset)\r
 \r
 \r
 #define FP_SIZE sizeof(MPI_Offset)\r
 \r
 \r
@@ -68,15 +70,15 @@ namespace smpi{
   int File::seek(MPI_Offset offset, int whence){\r
     switch(whence){\r
       case(MPI_SEEK_SET):\r
   int File::seek(MPI_Offset offset, int whence){\r
     switch(whence){\r
       case(MPI_SEEK_SET):\r
-        XBT_DEBUG("Seeking in MPI_File %s, setting offset %lld", file_->get_path(), offset);\r
+        XBT_VERB("Seeking in MPI_File %s, setting offset %lld", file_->get_path(), offset);\r
         file_->seek(offset,SEEK_SET);\r
         break;\r
       case(MPI_SEEK_CUR):\r
         file_->seek(offset,SEEK_SET);\r
         break;\r
       case(MPI_SEEK_CUR):\r
-        XBT_DEBUG("Seeking in MPI_File %s, current offset + %lld", file_->get_path(), offset);\r
+        XBT_VERB("Seeking in MPI_File %s, current offset + %lld", file_->get_path(), offset);\r
         file_->seek(offset,SEEK_CUR);\r
         break;\r
       case(MPI_SEEK_END):\r
         file_->seek(offset,SEEK_CUR);\r
         break;\r
       case(MPI_SEEK_END):\r
-        XBT_DEBUG("Seeking in MPI_File %s, end offset + %lld", file_->get_path(), offset);\r
+        XBT_VERB("Seeking in MPI_File %s, end offset + %lld", file_->get_path(), offset);\r
         file_->seek(offset,SEEK_END);\r
         break;\r
       default:\r
         file_->seek(offset,SEEK_END);\r
         break;\r
       default:\r
@@ -156,7 +158,7 @@ namespace smpi{
     MPI_Offset writesize = datatype->size()*count;\r
     XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());\r
     MPI_Offset write = fh->file_->write(writesize);\r
     MPI_Offset writesize = datatype->size()*count;\r
     XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());\r
     MPI_Offset write = fh->file_->write(writesize);\r
-    XBT_VERB("Write in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize);\r
+    XBT_VERB("Write in MPI_File %s, %lld bytes written, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize);\r
     if(writesize!=movesize){\r
       fh->file_->seek(position+movesize, SEEK_SET);\r
     }\r
     if(writesize!=movesize){\r
       fh->file_->seek(position+movesize, SEEK_SET);\r
     }\r