00001 
00002 
00003 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #include "ad_bgl.h"
00017 #include "ad_bgl_aggrs.h"
00018 
00019 void ADIOI_BGL_Flush(ADIO_File fd, int *error_code)
00020 {
00021   int err=0;
00022   static char myname[] = "ADIOI_BGL_FLUSH";
00023 
00024 
00025   if(((ADIOI_BGL_fs*)fd->fs_ptr)->fsync_aggr & ADIOI_BGL_FSYNC_AGGREGATION_ENABLED)
00026   {
00027     int rank;
00028  
00029     
00030     MPI_Barrier(fd->comm);
00031   
00032     MPI_Comm_rank(fd->comm, &rank);
00033   
00034     
00035 
00036 
00037 
00038     if(((ADIOI_BGL_fs*)fd->fs_ptr)->fsync_aggr & ADIOI_BGL_FSYNC_AGGREGATOR)
00039     {
00040       err = fsync(fd->fd_sys);
00041       DBG_FPRINTF(stderr,"aggregation:fsync %s, err=%#X, errno=%#X\n",fd->filename, err, errno);
00042       
00043       if (err == -1) err = errno;
00044       else err = 0;
00045     }
00046     
00047     MPI_Allreduce( MPI_IN_PLACE, (unsigned*)&err, 1, MPI_UNSIGNED, MPI_MAX, fd->comm);
00048     DBGV_FPRINTF(stderr,"aggregation result:fsync %s, errno %#X,\n",fd->filename, err);
00049 
00050     if (err) 
00051     {
00052       errno = err;
00053       err = -1;
00054     }
00055   }
00056   else 
00057   {
00058 #ifdef USE_DBG_LOGGING
00059     int rank;
00060 #endif
00061     err = fsync(fd->fd_sys);
00062 #ifdef USE_DBG_LOGGING
00063     MPI_Comm_rank(fd->comm, &rank);
00064 
00065     if(rank == 0)
00066     {
00067         DBG_FPRINTF(stderr,"no aggregation:fsync %s, err=%#X, errno=%#X\n",fd->filename, err, errno);
00068     }
00069     else
00070     {
00071         DBGV_FPRINTF(stderr,"no aggregation:fsync %s, err=%#X, errno=%#X\n",fd->filename, err, errno);
00072     }
00073 #endif
00074   }
00075 
00076   
00077   if (err == -1)
00078   {
00079     *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00080                                        myname, __LINE__, MPI_ERR_IO,
00081                                        "**io",
00082                                        "**io %s", strerror(errno));
00083     DBGT_FPRINTF(stderr,"fsync %s, err=%#X, errno=%#X\n",fd->filename, err, errno);
00084     return;
00085   }
00086   
00087 
00088   *error_code = MPI_SUCCESS;
00089 }
00090