[dcmf] [PATCH 7/9] data corruption with pwrite

Rob Latham robl at mcs.anl.gov
Fri Feb 15 13:50:31 CST 2008


witout _XOPEN_SOURCE defined to 500, unistd.h wouldn't prototype pwrite, and
the offset parameter would get truncated to zero.  yuk.

also, leave in the printf debugging while we try out a few more workloads.

Signed-off-by: Rob Latham <robl at mcs.anl.gov>
---
 .../src/mpi/romio/adio/common/ad_write_nolock.c    |   39 ++++++++++++++++++--
 1 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/lib/mpi/mpich2/src/mpi/romio/adio/common/ad_write_nolock.c b/lib/mpi/mpich2/src/mpi/romio/adio/common/ad_write_nolock.c
index 79b11a7..16293a2 100644
--- a/lib/mpi/mpich2/src/mpi/romio/adio/common/ad_write_nolock.c
+++ b/lib/mpi/mpich2/src/mpi/romio/adio/common/ad_write_nolock.c
@@ -5,13 +5,14 @@
  *   See COPYRIGHT notice in top-level directory.
  */
 
+#define _XOPEN_SOURCE 500 /* for pwrite (saves an lseek system call) */
+#include <unistd.h>
+
 #include "adio.h"
 #include "adio_extern.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
+/* #define IO_DEBUG 1 */
 void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 			     MPI_Datatype datatype, int file_ptr_type,
 			     ADIO_Offset offset, ADIO_Status *status, int
@@ -37,6 +38,9 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
     ADIO_Offset off, disp;
     int flag, new_bwr_size, new_fwr_size, err_flag=0;
     static char myname[] = "ADIOI_PVFS_WRITESTRIDED";
+#ifdef IO_DEBUG
+    int rank,nprocs;
+#endif
 
     /* --BEGIN ERROR HANDLING-- */
     if (fd->atomicity) {
@@ -57,6 +61,11 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 	return;
     }
 
+#ifdef IO_DEBUG
+    MPI_Comm_rank(fd->comm, &rank);
+    MPI_Comm_size(fd->comm, &nprocs);
+#endif
+
     MPI_Type_extent(fd->filetype, &filetype_extent);
     MPI_Type_size(datatype, &buftype_size);
     MPI_Type_extent(datatype, &buftype_extent);
@@ -95,6 +104,11 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 	    for (i=0; i<flat_buf->count; i++) {
 		if (flat_buf->blocklens[i] > combine_buf_remain && combine_buf != combine_buf_ptr) {
 		    /* there is data in the buffer; write out the buffer so far */
+#ifdef IO_DEBUG
+		    printf("[%d/%d] nc mem c file (0) writing loc = %Ld sz = %Ld\n", 
+				    rank, nprocs, off, 
+				    fd->hints->ind_wr_buffer_size-combine_buf_remain);
+#endif
 		    err = write(fd->fd_sys,
 				     combine_buf,
 				     fd->hints->ind_wr_buffer_size - combine_buf_remain);
@@ -110,6 +124,11 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 		    /* special case: blocklen is as big as or bigger than the combine buf;
 		     * write directly
 		     */
+#ifdef IO_DEBUG
+		    printf("[%d/%d] nc mem c file (1) writing loc = %Ld sz = %d\n", 
+				    rank, nprocs, off, 
+				    flat_buf->blocklens[i]);
+#endif
 		    err = write(fd->fd_sys,
 				     ((char *) buf) + j*buftype_extent + flat_buf->indices[i],
 				     flat_buf->blocklens[i]);
@@ -130,6 +149,11 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 
 	if (combine_buf_ptr != combine_buf) {
 	    /* data left in buffer to write */
+#ifdef IO_DEBUG
+	    printf("[%d/%d] nc mem c file (2) writing loc = %Ld sz = %Ld\n", 
+			    rank, nprocs, off, 
+			     fd->hints->ind_wr_buffer_size-combine_buf_remain);
+#endif
 	    err = write(fd->fd_sys,
 			     combine_buf,
 			     fd->hints->ind_wr_buffer_size - combine_buf_remain);
@@ -218,6 +242,11 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 #ifdef PROFILE
 		    MPE_Log_event(5, 0, "start write");
 #endif
+#ifdef IO_DEBUG
+	    printf("[%d/%d] c mem nc file writing loc = %Ld sz = %d\n", 
+			    rank, nprocs, off, 
+			     fwr_size);
+#endif
 		    err = pwrite(fd->fd_sys, ((char *) buf) + i, fwr_size, off);
 #ifdef PROFILE
 		    MPE_Log_event(6, 0, "end write");
@@ -262,6 +291,10 @@ void ADIOI_NOLOCK_WriteStrided(ADIO_File fd, void *buf, int count,
 #ifdef PROFILE
 		    MPE_Log_event(5, 0, "start write");
 #endif
+#ifdef IO_DEBUG
+	    printf("[%d/%d] nc mem nc file writing loc = %Ld sz = %d\n", 
+			    rank, nprocs, off, size);
+#endif
 		    err = pwrite(fd->fd_sys, ((char *) buf) + indx, size, off);
 #ifdef PROFILE
 		    MPE_Log_event(6, 0, "end write");
-- 
1.5.3.8




More information about the dcmf mailing list