Show
Ignore:
Timestamp:
08/02/08 21:32:54 (7 months ago)
Author:
balaji
Message:

Merging the BG/P changes into trunk. Let's see how the nightly tests do.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.c

    r616 r1249  
    11/* ---------------------------------------------------------------- */ 
    22/* (C)Copyright IBM Corp.  2007, 2008                               */ 
     3/* ---------------------------------------------------------------- */ 
    34/** 
    45 * \file ad_bgl.c 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.h

    r616 r1249  
    2929#endif 
    3030 
     31#if 0  
    3132int ADIOI_BGL_aio(ADIO_File fd, void *buf, int len, ADIO_Offset offset, 
    3233                  int wr, void *handle); 
     34#endif 
    3335 
    3436void ADIOI_BGL_Open(ADIO_File fd, int *error_code); 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c

    r616 r1249  
    11/* ---------------------------------------------------------------- */ 
    22/* (C)Copyright IBM Corp.  2007, 2008                               */ 
     3/* ---------------------------------------------------------------- */ 
    34/** 
    45 * \file ad_bgl_aggrs.c 
     
    1718#include "ad_bgl_pset.h" 
    1819#include "ad_bgl_aggrs.h" 
     20 
     21#ifdef USE_DBG_LOGGING 
     22  #define AGG_DEBUG 1 
     23#endif 
     24 
    1925 
    2026 
     
    220226                                        int *aggrsInPset ) 
    221227{ 
    222 #   define DEBUG 0 
    223 #   if DEBUG 
     228#   if AGG_DEBUG 
    224229    int i;  
    225230#   endif 
     
    230235    tmp_ranklist = (int *) ADIOI_Malloc (confInfo->nProcs * sizeof(int)); 
    231236 
    232 #   if DEBUG 
    233     for (i=0; i<confInfo->nProcs; i++)  
    234     printf( "\tcpuid %1d, rank = %6d\n", all_procInfo[i].cpuid, all_procInfo[i].rank ); 
     237#   if AGG_DEBUG 
     238    for (i=0; i<confInfo->nProcs; i++) { 
     239      DBG_FPRINTF(stderr, "\tcpuid %1d, rank = %6d\n", all_procInfo[i].cpuid, all_procInfo[i].rank ); 
     240    } 
    235241#   endif 
    236242 
     
    240246#   define VERIFY 0 
    241247#   if VERIFY 
    242     printf( "\tconfInfo = %3d,%3d,%3d,%3d,%3d,%3d,%.4f; naggs = %d\n",  
     248    DBG_FPRINTF(stderr, "\tconfInfo = %3d,%3d,%3d,%3d,%3d,%3d,%.4f; naggs = %d\n",  
    243249            confInfo->PsetSize        , 
    244250            confInfo->numPsets        , 
     
    251257#   endif 
    252258 
    253 #   if DEBUG 
    254     for (i=0; i<naggs; i++)  
    255     printf( "\taggr %-4d = %6d\n", i, tmp_ranklist[i] ); 
     259#   if AGG_DEBUG 
     260    for (i=0; i<naggs; i++) { 
     261      DBG_FPRINTF(stderr, "\taggr %-4d = %6d\n", i, tmp_ranklist[i] ); 
     262    } 
    256263#   endif 
    257264 
     
    292299    ADIO_Offset min_st_offset, max_end_offset, *fd_start, *fd_end, *fd_size; 
    293300    int i, aggr; 
     301#   if AGG_DEBUG 
    294302    static char myname[] = "ADIOI_BGL_GPFS_Calc_file_domains"; 
     303#   endif 
    295304    __blksize_t blksize = 1048576; /* default to 1M */ 
    296305    if(fs_ptr && ((ADIOI_BGL_fs*)fs_ptr)->blksize) /* ignore null ptr or 0 blksize */ 
    297306      blksize = ((ADIOI_BGL_fs*)fs_ptr)->blksize; 
    298 /*    FPRINTF(stderr,"%s(%d): Blocksize=%ld\n",myname,__LINE__,blksize);*/ 
    299  
     307#   if AGG_DEBUG 
     308    DBG_FPRINTF(stderr,"%s(%d): Blocksize=%ld\n",myname,__LINE__,blksize); 
     309#   endif 
    300310    /* find the range of all the requests */ 
    301311    min_st_offset  = st_offsets [0]; 
     
    306316    } 
    307317 
    308     // printf( "_calc_file_domains, min_st_offset, max_ = %qd, %qd\n", min_st_offset, max_end_offset ); 
     318    // DBG_FPRINTF(stderr, "_calc_file_domains, min_st_offset, max_ = %qd, %qd\n", min_st_offset, max_end_offset ); 
    309319 
    310320    /* determine the "file domain (FD)" of each process, i.e., the portion of 
     
    333343                        else fd_size[i] = (nb_cn_small+1) * blksize; 
    334344 
    335 /*     FPRINTF(stderr,"%s(%d): " 
     345#   if AGG_DEBUG 
     346     DBG_FPRINTF(stderr,"%s(%d): " 
    336347                   "gpfs_ub       %llu, " 
    337348                   "gpfs_lb       %llu, " 
     
    355366                   naggs_small 
    356367                   ); 
    357 */ 
     368#   endif 
     369 
    358370    fd_size[0]       -= gpfs_lb_rdoff; 
    359371    fd_size[naggs-1] -= gpfs_ub_rdoff; 
     
    523535 
    524536     * 
    525     printf( "\t%6d : %12qd:%12qd, %12qd:%12qd:%12qd, %12qd:%12qd:%12qd\n",  
     537    DBG_FPRINTF(stderr, "\t%6d : %12qd:%12qd, %12qd:%12qd:%12qd, %12qd:%12qd:%12qd\n",  
    526538            naggs, 
    527539            min_st_offset, 
     
    588600    } 
    589601 
    590     // printf ("ADIOI_BGL_Calc_aggregator: rank_index = %d\n", rank_index ); 
     602    // DBG_FPRINTF ("ADIOI_BGL_Calc_aggregator: rank_index = %d\n", rank_index ); 
    591603 
    592604    /*  
     
    621633 * (including this one) 
    622634 */ 
    623 void ADIOI_BGL_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list, int *len_list,  
     635void ADIOI_BGL_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list, ADIO_Offset *len_list,  
    624636                           int contig_access_count, ADIO_Offset  
    625637                           min_st_offset, ADIO_Offset *fd_start, 
     
    630642                           ADIOI_Access **my_req_ptr, 
    631643                           int **buf_idx_ptr) 
     644/* Possibly reconsider if buf_idx's are ok as int's, or should they be aints/offsets?  
     645   They are used as memory buffer indices so it seems like the 2G limit is in effect */ 
    632646{ 
    633647    int *count_my_req_per_proc, count_my_req_procs, *buf_idx; 
     
    721735 
    722736        /* for each separate contiguous access from this process */ 
    723         if (buf_idx[proc] == -1) buf_idx[proc] = (int) curr_idx; 
     737        if (buf_idx[proc] == -1) 
     738  { 
     739    ADIOI_Assert(curr_idx == (int) curr_idx); 
     740    buf_idx[proc] = (int) curr_idx; 
     741  } 
    724742 
    725743        l = my_req[proc].count; 
    726         curr_idx += (int) fd_len; /* NOTE: Why is curr_idx an int?  Fix? */ 
     744        curr_idx += fd_len; 
    727745 
    728746        rem_len = len_list[i] - fd_len; 
     
    734752         */ 
    735753        my_req[proc].offsets[l] = off; 
     754  ADIOI_Assert(fd_len == (int) fd_len); 
    736755        my_req[proc].lens[l] = (int) fd_len; 
    737756        my_req[proc].count++; 
     
    743762                                         fd_size, fd_start, fd_end); 
    744763 
    745             if (buf_idx[proc] == -1) buf_idx[proc] = (int) curr_idx; 
     764            if (buf_idx[proc] == -1)  
     765      { 
     766        ADIOI_Assert(curr_idx == (int) curr_idx); 
     767        buf_idx[proc] = (int) curr_idx; 
     768      } 
    746769 
    747770            l = my_req[proc].count; 
     
    750773 
    751774            my_req[proc].offsets[l] = off; 
     775      ADIOI_Assert(fd_len == (int) fd_len); 
    752776            my_req[proc].lens[l] = (int) fd_len; 
    753777            my_req[proc].count++; 
     
    758782    for (i=0; i<nprocs; i++) { 
    759783        if (count_my_req_per_proc[i] > 0) { 
    760             FPRINTF(stdout, "data needed from %d (count = %d):\n", i,  
     784            DBG_FPRINTF(stderr, "data needed from %d (count = %d):\n", i,  
    761785                    my_req[i].count); 
    762786            for (l=0; l < my_req[i].count; l++) { 
    763                 FPRINTF(stdout, "   off[%d] = %Ld, len[%d] = %d\n", l, 
     787                DBG_FPRINTF(stderr, "   off[%d] = %lld, len[%d] = %d\n", l, 
    764788                        my_req[i].offsets[l], l, my_req[i].lens[l]); 
    765789            } 
    766790        } 
    767     } 
    768 #if 0 
    769     for (i=0; i<nprocs; i++) { 
    770         FPRINTF(stdout, "buf_idx[%d] = 0x%x\n", i, buf_idx[i]); 
    771     } 
    772 #endif 
     791        DBG_FPRINTF(stderr, "buf_idx[%d] = 0x%x\n", i, buf_idx[i]); 
     792    } 
    773793#endif 
    774794 
     
    778798 
    779799/* 
    780  * ADIOI_Calc_others_req 
     800 * ADIOI_Calc_others_req (copied to bgl and switched to all to all for performance) 
    781801 * 
    782802 * param[in]  count_my_req_procs        Number of processes whose file domain my 
     
    867887                ADIOI_Malloc(count_others_req_per_proc[i]*sizeof(int));  
    868888 
    869             if ( (unsigned)others_req[i].offsets < (unsigned)recvBufForOffsets ) 
     889            if ( (MPIR_Upint)others_req[i].offsets < (MPIR_Upint)recvBufForOffsets ) 
    870890                recvBufForOffsets = others_req[i].offsets; 
    871             if ( (unsigned)others_req[i].lens < (unsigned)recvBufForLens ) 
     891            if ( (MPIR_Upint)others_req[i].lens < (MPIR_Upint)recvBufForLens ) 
    872892                recvBufForLens = others_req[i].lens; 
    873893 
     
    884904        } 
    885905    } 
     906    /* If no recv buffer was allocated in the loop above, make it NULL */ 
     907    if ( recvBufForOffsets == (void*)0xFFFFFFFF) recvBufForOffsets = NULL; 
     908    if ( recvBufForLens    == (void*)0xFFFFFFFF) recvBufForLens    = NULL; 
    886909     
    887910    /* Now send the calculated offsets and lengths to respective processes */ 
     
    895918    { 
    896919        if ( (my_req[i].count) && 
    897              ((unsigned)my_req[i].offsets <= (unsigned)sendBufForOffsets) ) 
    898             sendBufForOffsets = my_req[i].offsets; 
     920             ((MPIR_Upint)my_req[i].offsets <= (MPIR_Upint)sendBufForOffsets) ) 
     921          sendBufForOffsets = my_req[i].offsets; 
    899922            
    900923        if ( (my_req[i].count) && 
    901              ((unsigned)my_req[i].lens <= (unsigned)sendBufForLens) ) 
     924             ((MPIR_Upint)my_req[i].lens <= (MPIR_Upint)sendBufForLens) ) 
    902925            sendBufForLens = my_req[i].lens; 
    903926    } 
     927 
     928    /* If no send buffer was found in the loop above, make it NULL */ 
     929    if ( sendBufForOffsets == (void*)0xFFFFFFFF) sendBufForOffsets = NULL; 
     930    if ( sendBufForLens    == (void*)0xFFFFFFFF) sendBufForLens    = NULL; 
    904931 
    905932    /* Calculate the displacements from the sendBufForOffsets/Lens */ 
     
    911938            sdispls[i] = 0; 
    912939        else 
    913             sdispls[i] = ( (unsigned)my_req[i].offsets -  
    914                            (unsigned)sendBufForOffsets ) / sizeof(ADIO_Offset); 
     940          sdispls[i] =  (int) 
     941                        ( ( (MPIR_Upint)my_req[i].offsets -  
     942                           (MPIR_Upint)sendBufForOffsets ) /  
     943                          (MPIR_Upint)sizeof(ADIO_Offset) ); 
    915944 
    916945        // Receive these offsets from process i. 
     
    919948            rdispls[i] = 0; 
    920949        else 
    921             rdispls[i] = ( (unsigned)others_req[i].offsets -  
    922                            (unsigned)recvBufForOffsets ) / sizeof(ADIO_Offset); 
     950            rdispls[i] = (int) 
     951                         ( ( (MPIR_Upint)others_req[i].offsets -  
     952                             (MPIR_Upint)recvBufForOffsets ) /  
     953                           (MPIR_Upint)sizeof(ADIO_Offset) ); 
    923954    } 
    924955 
     
    941972            sdispls[i] = 0; 
    942973        else 
    943             sdispls[i] = ( (unsigned)my_req[i].lens -  
    944                            (unsigned)sendBufForLens ) / sizeof(int); 
     974          sdispls[i] = (int) 
     975                       ( ( (MPIR_Upint)my_req[i].lens -  
     976                           (MPIR_Upint)sendBufForLens ) /  
     977                         (MPIR_Upint) sizeof(int) ); 
    945978         
    946979        // Receive these offsets from process i. 
     
    949982            rdispls[i] = 0; 
    950983        else 
    951             rdispls[i] = ( (unsigned)others_req[i].lens -  
    952                            (unsigned)recvBufForLens ) / sizeof(int); 
     984            rdispls[i] = (int) 
     985                         ( ( (MPIR_Upint)others_req[i].lens -  
     986                             (MPIR_Upint)recvBufForLens ) /  
     987                           (MPIR_Upint) sizeof(int) ); 
    953988    } 
    954989 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.h

    r616 r1249  
    11/* ---------------------------------------------------------------- */ 
    22/* (C)Copyright IBM Corp.  2007, 2008                               */ 
     3/* ---------------------------------------------------------------- */ 
    34/** 
    45 * \file ad_bgl_aggrs.h 
     
    6162    /* overriding ADIOI_Calc_my_req for the default implementation is specific for  
    6263       static file domain partitioning */ 
    63     void ADIOI_BGL_Calc_my_req ( ADIO_File fd, ADIO_Offset *offset_list, int *len_list, 
     64    void ADIOI_BGL_Calc_my_req ( ADIO_File fd, ADIO_Offset *offset_list, ADIO_Offset *len_list, 
    6465                                 int contig_access_count, ADIO_Offset 
    6566                                 min_st_offset, ADIO_Offset *fd_start, 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_close.c

    r734 r1249  
    11/* ---------------------------------------------------------------- */ 
    22/* (C)Copyright IBM Corp.  2007, 2008                               */ 
     3/* ---------------------------------------------------------------- */ 
    34/** 
    4  * \file ad_bgl_open.c 
     5 * \file ad_bgl_close.c 
    56 * \brief ??? 
    67 */ 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_fcntl.c

    r616 r1249  
    11/* ---------------------------------------------------------------- */ 
    22/* (C)Copyright IBM Corp.  2007, 2008                               */ 
     3/* ---------------------------------------------------------------- */ 
    34/** 
    45 * \file ad_bgl_fcntl.c 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_rdcoll.c

    r968 r1249  
    2323#endif 
    2424 
     25#ifdef USE_DBG_LOGGING 
     26  #define RDCOLL_DEBUG 1 
     27#endif 
     28 
     29 
    2530/* prototypes of functions used for collective reads only. */ 
    2631static void ADIOI_Read_and_exch(ADIO_File fd, void *buf, MPI_Datatype 
     
    2833                                int myrank, ADIOI_Access 
    2934                                *others_req, ADIO_Offset *offset_list, 
    30                                 int *len_list, int contig_access_count,  
     35                                ADIO_Offset *len_list, int contig_access_count,  
    3136                                ADIO_Offset 
    3237                                min_st_offset, ADIO_Offset fd_size, 
     
    3439                                int *buf_idx, int *error_code); 
    3540static void ADIOI_R_Exchange_data(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    36                                   *flat_buf, ADIO_Offset *offset_list, in
     41                                  *flat_buf, ADIO_Offset *offset_list, ADIO_Offse
    3742                                  *len_list, int *send_size, int *recv_size, 
    3843                                  int *count, int *start_pos,  
     
    4853                                  MPI_Aint buftype_extent, int *buf_idx); 
    4954static void ADIOI_R_Exchange_data_alltoallv(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    50                                   *flat_buf, ADIO_Offset *offset_list, in
     55                                  *flat_buf, ADIO_Offset *offset_list, ADIO_Offse
    5156                                  *len_list, int *send_size, int *recv_size, 
    5257                                  int *count, int *start_pos, 
     
    6368static void ADIOI_Fill_user_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    6469                                   *flat_buf, char **recv_buf, ADIO_Offset  
    65                                    *offset_list, int *len_list,  
    66                                    int *recv_size,  
     70                                   *offset_list, ADIO_Offset *len_list,  
     71                                   unsigned *recv_size,  
    6772                                   MPI_Request *requests, MPI_Status *statuses, 
    6873                                   int *recd_from_proc, int nprocs, 
     
    7580extern void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype 
    7681                            datatype, int file_ptr_type, ADIO_Offset 
    77                             offset, ADIO_Offset **offset_list_ptr, in
     82                            offset, ADIO_Offset **offset_list_ptr, ADIO_Offse
    7883                            **len_list_ptr, ADIO_Offset *start_offset_ptr, 
    7984                            ADIO_Offset *end_offset_ptr, int 
     
    107112    ADIO_Offset *bgl_offsets0 = NULL, *bgl_offsets = NULL; 
    108113    int  ii; 
    109     int *len_list = NULL, *buf_idx = NULL; 
    110  
     114    ADIO_Offset *len_list = NULL; 
     115    int *buf_idx = NULL; 
     116/* 
    111117    double io_time = 0., all_time, max_all_time;  
    112118    double tstep1, max_tstep1; 
     
    118124    double tstep4, max_tstep4; 
    119125    double sum_sz; 
    120  
     126*/ 
    121127#if BGL_PROFILE  
    122128    BGLMPIO_T_CIO_RESET( 0, r ) 
     
    158164#endif 
    159165 
    160         /*    for (i=0; i<contig_access_count; i++) { 
    161               FPRINTF(stderr, "rank %d  off %ld  len %d\n", myrank, offset_list[i],  
     166#ifdef RDCOLL_DEBUG 
     167    for (i=0; i<contig_access_count; i++) { 
     168              DBG_FPRINTF(stderr, "rank %d  off %lld  len %lld\n", myrank, offset_list[i],  
    162169              len_list[i]); 
    163               }*/ 
     170    } 
     171#endif 
    164172 
    165173        /* each process communicates its start and end offsets to other  
     
    224232        if (buftype_is_contig && filetype_is_contig) { 
    225233            if (file_ptr_type == ADIO_EXPLICIT_OFFSET) { 
    226                 off = fd->disp + (fd->etype_size) * offset; 
     234                off = fd->disp + (ADIO_Offset)(fd->etype_size) * offset; 
    227235                ADIO_ReadContig(fd, buf, count, datatype, ADIO_EXPLICIT_OFFSET, 
    228236                       off, status, error_code); 
     
    384392} 
    385393 
    386 #if 0 
    387 void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype 
    388                             datatype, int file_ptr_type, ADIO_Offset 
    389                             offset, ADIO_Offset **offset_list_ptr, int 
    390                             **len_list_ptr, ADIO_Offset *start_offset_ptr, 
    391                             ADIO_Offset *end_offset_ptr, int 
    392                            *contig_access_count_ptr) 
    393 { 
    394     int filetype_size, buftype_size, etype_size; 
    395     int i, j, k, frd_size=0, old_frd_size=0, st_index=0; 
    396     int n_filetypes, etype_in_filetype; 
    397     ADIO_Offset abs_off_in_filetype=0; 
    398     int bufsize, sum, n_etypes_in_filetype, size_in_filetype; 
    399     int contig_access_count, *len_list, flag, filetype_is_contig; 
    400     MPI_Aint filetype_extent, filetype_lb; 
    401     ADIOI_Flatlist_node *flat_file; 
    402     ADIO_Offset *offset_list, off, end_offset=0, disp; 
    403      
    404 /* For this process's request, calculate the list of offsets and 
    405    lengths in the file and determine the start and end offsets. */ 
    406  
    407     ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig); 
    408  
    409     MPI_Type_size(fd->filetype, &filetype_size); 
    410     MPI_Type_extent(fd->filetype, &filetype_extent); 
    411     MPI_Type_lb(fd->filetype, &filetype_lb); 
    412     MPI_Type_size(datatype, &buftype_size); 
    413     etype_size = fd->etype_size; 
    414  
    415     if ( ! filetype_size ) { 
    416         *contig_access_count_ptr = 0; 
    417         *offset_list_ptr = (ADIO_Offset *) ADIOI_Malloc(2*sizeof(ADIO_Offset)); 
    418         *len_list_ptr = (int *) ADIOI_Malloc(2*sizeof(int)); 
    419         /* 2 is for consistency. everywhere I malloc one more than needed */ 
    420  
    421         offset_list = *offset_list_ptr; 
    422         len_list = *len_list_ptr; 
    423         offset_list[0] = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :  
    424                  fd->disp + etype_size * offset; 
    425         len_list[0] = 0; 
    426         *start_offset_ptr = offset_list[0]; 
    427         *end_offset_ptr = offset_list[0] + len_list[0] - 1; 
    428          
    429         return; 
    430     } 
    431  
    432     if (filetype_is_contig) { 
    433         *contig_access_count_ptr = 1;         
    434         *offset_list_ptr = (ADIO_Offset *) ADIOI_Malloc(2*sizeof(ADIO_Offset)); 
    435         *len_list_ptr = (int *) ADIOI_Malloc(2*sizeof(int)); 
    436         /* 2 is for consistency. everywhere I malloc one more than needed */ 
    437  
    438         offset_list = *offset_list_ptr; 
    439         len_list = *len_list_ptr; 
    440         offset_list[0] = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :  
    441                  fd->disp + etype_size * offset; 
    442         len_list[0] = bufcount * buftype_size; 
    443         *start_offset_ptr = offset_list[0]; 
    444         *end_offset_ptr = offset_list[0] + len_list[0] - 1; 
    445  
    446         /* update file pointer */ 
    447         if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = *end_offset_ptr + 1; 
    448     } 
    449  
    450     else { 
    451  
    452        /* First calculate what size of offset_list and len_list to allocate */ 
    453     
    454        /* filetype already flattened in ADIO_Open or ADIO_Fcntl */ 
    455         flat_file = ADIOI_Flatlist; 
    456         while (flat_file->type != fd->filetype) flat_file = flat_file->next; 
    457         disp = fd->disp; 
    458  
    459         if (file_ptr_type == ADIO_INDIVIDUAL) { 
    460             offset = fd->fp_ind; /* in bytes */ 
    461             n_filetypes = -1; 
    462             flag = 0; 
    463             while (!flag) { 
    464                 n_filetypes++; 
    465                 for (i=0; i<flat_file->count; i++) { 
    466                     if (disp + flat_file->indices[i] +  
    467                         (ADIO_Offset) n_filetypes*filetype_extent +  
    468                         flat_file->blocklens[i] >= offset)  
    469                     { 
    470                         st_index = i; 
    471                         frd_size = (int) (disp + flat_file->indices[i] +  
    472                             (ADIO_Offset) n_filetypes*filetype_extent 
    473                                 + flat_file->blocklens[i] - offset); 
    474                         flag = 1; 
    475                         break; 
    476                     } 
    477                 } 
    478             } 
    479         } 
    480         else { 
    481             n_etypes_in_filetype = filetype_size/etype_size; 
    482             n_filetypes = (int) (offset / n_etypes_in_filetype); 
    483             etype_in_filetype = (int) (offset % n_etypes_in_filetype); 
    484             size_in_filetype = etype_in_filetype * etype_size; 
    485   
    486             sum = 0; 
    487             for (i=0; i<flat_file->count; i++) { 
    488                 sum += flat_file->blocklens[i]; 
    489                 if (sum > size_in_filetype) { 
    490                     st_index = i; 
    491                     frd_size = sum - size_in_filetype; 
    492                     abs_off_in_filetype = flat_file->indices[i] + 
    493                         size_in_filetype - (sum - flat_file->blocklens[i]); 
    494                     break; 
    495                 } 
    496             } 
    497  
    498             /* abs. offset in bytes in the file */ 
    499             offset = disp + (ADIO_Offset) n_filetypes*filetype_extent +  
    500                 abs_off_in_filetype; 
    501         } 
    502  
    503          /* calculate how much space to allocate for offset_list, len_list */ 
    504  
    505         old_frd_size = frd_size; 
    506         contig_access_count = i = 0; 
    507         j = st_index; 
    508         bufsize = buftype_size * bufcount; 
    509         frd_size = ADIOI_MIN(frd_size, bufsize); 
    510         while (i < bufsize) { 
    511             if (frd_size) contig_access_count++; 
    512             i += frd_size; 
    513             j = (j + 1) % flat_file->count; 
    514             frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
    515         } 
    516  
    517         /* allocate space for offset_list and len_list */ 
    518  
    519         *offset_list_ptr = (ADIO_Offset *) 
    520                  ADIOI_Malloc((contig_access_count+1)*sizeof(ADIO_Offset));   
    521         *len_list_ptr = (int *) ADIOI_Malloc((contig_access_count+1)*sizeof(int)); 
    522         /* +1 to avoid a 0-size malloc */ 
    523  
    524         offset_list = *offset_list_ptr; 
    525         len_list = *len_list_ptr; 
    526  
    527       /* find start offset, end offset, and fill in offset_list and len_list */ 
    528  
    529         *start_offset_ptr = offset; /* calculated above */ 
    530  
    531         i = k = 0; 
    532         j = st_index; 
    533         off = offset; 
    534         frd_size = ADIOI_MIN(old_frd_size, bufsize); 
    535         while (i < bufsize) { 
    536             if (frd_size) { 
    537                 offset_list[k] = off; 
    538                 len_list[k] = frd_size; 
    539                 k++; 
    540             } 
    541             i += frd_size; 
    542             end_offset = off + frd_size - 1; 
    543  
    544      /* Note: end_offset points to the last byte-offset that will be accessed. 
    545          e.g., if start_offset=0 and 100 bytes to be read, end_offset=99*/ 
    546  
    547             if (off + frd_size < disp + flat_file->indices[j] + 
    548                 flat_file->blocklens[j] +  
    549                 (ADIO_Offset) n_filetypes*filetype_extent) 
    550             { 
    551                 off += frd_size; 
    552                 /* did not reach end of contiguous block in filetype. 
    553                  * no more I/O needed. off is incremented by frd_size.  
    554                  */ 
    555             } 
    556             else { 
    557                 if (j < (flat_file->count - 1)) j++; 
    558                 else { 
    559                     /* hit end of flattened filetype;  
    560                      * start at beginning again  
    561                      */ 
    562                     j = 0; 
    563                     n_filetypes++; 
    564                 } 
    565                 off = disp + flat_file->indices[j] +  
    566                     (ADIO_Offset) n_filetypes*filetype_extent; 
    567                 frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
    568             } 
    569         } 
    570  
    571         /* update file pointer */ 
    572         if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off; 
    573  
    574         *contig_access_count_ptr = contig_access_count; 
    575         *end_offset_ptr = end_offset; 
    576     } 
    577 } 
    578 #endif 
    579  
    580394static void ADIOI_Read_and_exch(ADIO_File fd, void *buf, MPI_Datatype 
    581395                         datatype, int nprocs, 
    582396                         int myrank, ADIOI_Access 
    583397                         *others_req, ADIO_Offset *offset_list, 
    584                          int *len_list, int contig_access_count, ADIO_Offset 
     398                         ADIO_Offset *len_list, int contig_access_count, ADIO_Offset 
    585399                         min_st_offset, ADIO_Offset fd_size, 
    586400                         ADIO_Offset *fd_start, ADIO_Offset *fd_end, 
     
    597411   at least another 8Mbytes of temp space is unacceptable. */ 
    598412 
    599     int i, j, m, size, ntimes, max_ntimes, buftype_is_contig; 
     413    int i, j, m, ntimes, max_ntimes, buftype_is_contig; 
    600414    ADIO_Offset st_loc=-1, end_loc=-1, off, done, real_off, req_off; 
    601415    char *read_buf = NULL, *tmp_buf; 
    602416    int *curr_offlen_ptr, *count, *send_size, *recv_size; 
    603     int *partial_send, *recd_from_proc, *start_pos, for_next_iter; 
    604     int real_size, req_len, flag, for_curr_iter, rank; 
     417    int *partial_send, *recd_from_proc, *start_pos; 
     418    /* Not convinced end_loc-st_loc couldn't be > int, so make these offsets*/ 
     419    ADIO_Offset real_size, size, for_curr_iter, for_next_iter; 
     420    int req_len, flag, rank; 
    605421    MPI_Status status; 
    606422    ADIOI_Flatlist_node *flat_buf=NULL; 
    607423    MPI_Aint buftype_extent; 
    608424    int coll_bufsize; 
    609  
     425#ifdef RDCOLL_DEBUG 
    610426    int iii; 
    611  
     427#endif 
    612428    *error_code = MPI_SUCCESS;  /* changed below if error */ 
    613429    /* only I/O errors are currently reported */ 
     
    741557        MPE_Log_event(13, 0, "start computation"); 
    742558#endif 
    743         size = (int) (ADIOI_MIN(coll_bufsize, end_loc-st_loc+1-done));  
     559        size = ADIOI_MIN((unsigned)coll_bufsize, end_loc-st_loc+1-done);  
    744560        real_off = off - for_curr_iter; 
    745561        real_size = size + for_curr_iter; 
     
    749565 
    750566        for (i=0; i<nprocs; i++) { 
    751             /* FPRINTF(stderr, "rank %d, i %d, others_count %d\n", rank, i, others_req[i].count); */ 
     567#ifdef RDCOLL_DEBUG 
     568            DBG_FPRINTF(stderr, "rank %d, i %d, others_count %d\n", rank, i, others_req[i].count);  
     569#endif 
    752570            if (others_req[i].count) { 
    753571                start_pos[i] = curr_offlen_ptr[i]; 
     
    772590                    if (req_off < real_off + real_size) { 
    773591                        count[i]++; 
     592      ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)read_buf)+req_off-real_off) == (ADIO_Offset)(MPIR_Upint)(read_buf+req_off-real_off)); 
    774593                        MPI_Address(read_buf+req_off-real_off,  
    775594                               &(others_req[i].mem_ptrs[j])); 
    776                         send_size[i] += (int)(ADIOI_MIN(real_off + (ADIO_Offset)real_size -  
    777                                                  req_off, req_len)); 
    778  
    779                         if (real_off+real_size-req_off < req_len) { 
    780                             partial_send[i] = (int) (real_off+real_size- 
    781                                                     req_off); 
     595      ADIOI_Assert((real_off + real_size - req_off) == (int)(real_off + real_size - req_off)); 
     596                        send_size[i] += (int)(ADIOI_MIN(real_off + real_size - req_off,  
     597                                      (ADIO_Offset)(unsigned)req_len));  
     598 
     599                        if (real_off+real_size-req_off < (ADIO_Offset)(unsigned)req_len) { 
     600                            partial_send[i] = (int) (real_off + real_size - req_off); 
    782601                            if ((j+1 < others_req[i].count) &&  
    783602                                 (others_req[i].offsets[j+1] <  
     
    785604                                /* this is the case illustrated in the 
    786605                                   figure above. */ 
    787                                 for_next_iter = (int) (ADIOI_MAX(for_next_iter, 
    788                                           real_off + real_size -  
    789                                              others_req[i].offsets[j+1]));  
     606                                for_next_iter = ADIOI_MAX(for_next_iter, 
     607                                          real_off + real_size - others_req[i].offsets[j+1]);  
    790608                                /* max because it must cover requests  
    791609                                   from different processes */ 
     
    808626#endif 
    809627        if (flag) { 
    810             ADIO_ReadContig(fd, read_buf+for_curr_iter, size, MPI_BYTE, 
     628      ADIOI_Assert(size == (int)size); 
     629            ADIO_ReadContig(fd, read_buf+for_curr_iter, (int)size, MPI_BYTE, 
    811630                            ADIO_EXPLICIT_OFFSET, off, &status, error_code); 
    812 /* 
    813             printf( "\tread_coll: 700, data read [%3d] = ", size ); 
    814             for (iii=0; iii<size; iii++) { printf( "%3d,", *((unsigned char *)read_buf + for_curr_iter + iii) ); } 
    815             printf( "\n" ); 
    816  */ 
     631#ifdef RDCOLL_DEBUG 
     632            DBG_FPRINTF(stderr, "\tread_coll: 700, data read [%lld] = ", size ); 
     633            for (iii=0; iii<size && iii<80; iii++) { DBGV_FPRINTF(stderr, "%3d,", *((unsigned char *)read_buf + for_curr_iter + iii) ); } 
     634            DBG_FPRINTF(stderr, "\n" ); 
     635#endif 
    817636 
    818637            if (*error_code != MPI_SUCCESS) return; 
     
    852671        if (for_next_iter) { 
    853672            tmp_buf = (char *) ADIOI_Malloc(for_next_iter); 
     673      ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)read_buf)+real_size-for_next_iter) == (ADIO_Offset)(MPIR_Upint)(read_buf+real_size-for_next_iter)); 
     674      ADIOI_Assert((for_next_iter+coll_bufsize) == (size_t)(for_next_iter+coll_bufsize)); 
    854675            memcpy(tmp_buf, read_buf+real_size-for_next_iter, for_next_iter); 
    855676            ADIOI_Free(read_buf); 
     
    905726 
    906727static void ADIOI_R_Exchange_data(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    907                          *flat_buf, ADIO_Offset *offset_list, in
     728                         *flat_buf, ADIO_Offset *offset_list, ADIO_Offse
    908729                         *len_list, int *send_size, int *recv_size, 
    909730                         int *count, int *start_pos, int *partial_send,  
     
    943764        j = 0; 
    944765        for (i=0; i < nprocs; i++)  
    945             if (recv_size[i]) { 
     766            if (recv_size[i]) {  
    946767                MPI_Irecv(((char *) buf) + buf_idx[i], recv_size[i],  
    947768                  MPI_BYTE, i, myrank+i+100*iter, fd->comm, requests+j); 
     
    963784                              myrank+i+100*iter, fd->comm, requests+j); 
    964785                    j++; 
    965                     /* FPRINTF(stderr, "node %d, recv_size %d, tag %d \n",  
    966                        myrank, recv_size[i], myrank+i+100*iter); */ 
     786#ifdef RDCOLL_DEBUG 
     787                    DBG_FPRINTF(stderr, "node %d, recv_size %d, tag %d \n",  
     788                       myrank, recv_size[i], myrank+i+100*iter);  
     789#endif 
    967790                } 
    968791    } 
     
    1009832        if (!buftype_is_contig)  
    1010833            ADIOI_Fill_user_buffer(fd, buf, flat_buf, recv_buf, 
    1011                                    offset_list, len_list, recv_size,  
     834                                   offset_list, len_list, (unsigned*)recv_size,  
    1012835                                   requests, statuses, recd_from_proc,  
    1013836                                   nprocs, contig_access_count, 
     
    1029852} 
    1030853 
     854static void ADIOI_Fill_user_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
     855                                   *flat_buf, char **recv_buf, ADIO_Offset  
     856                                   *offset_list, ADIO_Offset *len_list,  
     857                                   unsigned *recv_size,  
     858                                   MPI_Request *requests, MPI_Status *statuses, 
     859                                   int *recd_from_proc, int nprocs, 
     860                                   int contig_access_count,  
     861                                   ADIO_Offset min_st_offset,  
     862                                   ADIO_Offset fd_size, ADIO_Offset *fd_start,  
     863                                   ADIO_Offset *fd_end, 
     864                                   MPI_Aint buftype_extent) 
     865{ 
     866/* this function is only called if buftype is not contig */ 
    1031867 
    1032868#define ADIOI_BUF_INCR \ 
     
    1043879            } \ 
    1044880            user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 
    1045                               n_buftypes*buftype_extent; \ 
     881                              (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 
    1046882            flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 
    1047883        } \ 
     
    1055891    while (size) { \ 
    1056892        size_in_buf = ADIOI_MIN(size, flat_buf_sz); \ 
     893  ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)buf) + user_buf_idx) == (ADIO_Offset)(MPIR_Upint)(buf + user_buf_idx)); \ 
     894  ADIOI_Assert(size_in_buf == (size_t)size_in_buf); \ 
    1057895        memcpy(((char *) buf) + user_buf_idx, \ 
    1058896               &(recv_buf[p][recv_buf_idx[p]]), size_in_buf); \ 
    1059         recv_buf_idx[p] += size_in_buf;
     897        recv_buf_idx[p] += size_in_buf; /* already tested (size_t)size_in_buf*/
    1060898        user_buf_idx += size_in_buf; \ 
    1061899        flat_buf_sz -= size_in_buf; \ 
     
    1067905            } \ 
    1068906            user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 
    1069                               n_buftypes*buftype_extent; \ 
     907                              (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 
    1070908            flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 
    1071909        } \ 
     
    1077915 
    1078916 
    1079 static void ADIOI_Fill_user_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    1080                                    *flat_buf, char **recv_buf, ADIO_Offset  
    1081                                    *offset_list, int *len_list,  
    1082                                    int *recv_size,  
    1083                                    MPI_Request *requests, MPI_Status *statuses, 
    1084                                    int *recd_from_proc, int nprocs, 
    1085                                    int contig_access_count,  
    1086                                    ADIO_Offset min_st_offset,  
    1087                                    ADIO_Offset fd_size, ADIO_Offset *fd_start,  
    1088                                    ADIO_Offset *fd_end, 
    1089                                    MPI_Aint buftype_extent) 
    1090 
    1091 /* this function is only called if buftype is not contig */ 
    1092  
    1093     int i, p, flat_buf_idx, size, buf_incr; 
    1094     int flat_buf_sz, size_in_buf, n_buftypes; 
     917 
     918    int i, p, flat_buf_idx; 
     919    ADIO_Offset flat_buf_sz, size_in_buf, buf_incr, size; 
     920    int n_buftypes; 
    1095921    ADIO_Offset off, len, rem_len, user_buf_idx; 
    1096  
    1097     int *curr_from_proc, *done_from_proc, *recv_buf_idx; 
     922    /* Not sure unsigned is necessary, but it makes the math safer */ 
     923    unsigned *curr_from_proc, *done_from_proc, *recv_buf_idx; 
    1098924 
    1099925/*  curr_from_proc[p] = amount of data recd from proc. p that has already 
     
    1103929    user_buf_idx = current location in user buffer  
    1104930    recv_buf_idx[p] = current location in recv_buf of proc. p  */ 
    1105     curr_from_proc = (int *) ADIOI_Malloc(nprocs * sizeof(int)); 
    1106     done_from_proc = (int *) ADIOI_Malloc(nprocs * sizeof(int)); 
    1107     recv_buf_idx   = (int *) ADIOI_Malloc(nprocs * sizeof(int)); 
     931    curr_from_proc = (unsigned *) ADIOI_Malloc(nprocs * sizeof(unsigned)); 
     932    done_from_proc = (unsigned *) ADIOI_Malloc(nprocs * sizeof(unsigned)); 
     933    recv_buf_idx   = (unsigned *) ADIOI_Malloc(nprocs * sizeof(unsigned)); 
    1108934 
    1109935    for (i=0; i < nprocs; i++) { 
     
    1123949    for (i=0; i<contig_access_count; i++) {  
    1124950        off     = offset_list[i]; 
    1125         rem_len = (ADIO_Offset) len_list[i]; 
     951        rem_len = len_list[i]; 
    1126952 
    1127953        /* this request may span the file domains of more than one process */ 
     
    1143969                if (curr_from_proc[p]+len > done_from_proc[p]) { 
    1144970                    if (done_from_proc[p] > curr_from_proc[p]) { 
    1145                         size = (int)ADIOI_MIN(curr_from_proc[p] + len -  
     971                        size = ADIOI_MIN(curr_from_proc[p] + len -  
    1146972                              done_from_proc[p], recv_size[p]-recv_buf_idx[p]); 
    1147973                        buf_incr = done_from_proc[p] - curr_from_proc[p]; 
    1148974                        ADIOI_BUF_INCR 
    1149                         buf_incr = (int)(curr_from_proc[p]+len-done_from_proc[p]); 
     975                        buf_incr = curr_from_proc[p]+len-done_from_proc[p]; 
     976      ADIOI_Assert((done_from_proc[p] + size) == (unsigned)((ADIO_Offset)done_from_proc[p] + size)); 
    1150977                        curr_from_proc[p] = done_from_proc[p] + size; 
    1151978                        ADIOI_BUF_COPY 
    1152979                    } 
    1153980                    else { 
    1154                         size = (int)ADIOI_MIN(len,recv_size[p]-recv_buf_idx[p]); 
    1155                         buf_incr = (int)len; 
    1156                         curr_from_proc[p] += size; 
     981                        size = ADIOI_MIN(len,recv_size[p]-recv_buf_idx[p]); 
     982                        buf_incr = len; 
     983      ADIOI_Assert((curr_from_proc[p] + size) == (unsigned)((ADIO_Offset)curr_from_proc[p] + size)); 
     984                        curr_from_proc[p] += (unsigned) size; 
    1157985                        ADIOI_BUF_COPY 
    1158986                    } 
    1159987                } 
    1160988                else { 
    1161                     curr_from_proc[p] += (int)len; 
    1162                     buf_incr = (int)len; 
     989        ADIOI_Assert((curr_from_proc[p] + len) == (unsigned)((ADIO_Offset)curr_from_proc[p] + len)); 
     990                    curr_from_proc[p] += (unsigned) len; 
     991                    buf_incr = len; 
    1163992                    ADIOI_BUF_INCR 
    1164993                } 
    1165994            } 
    1166995            else { 
    1167                 buf_incr = (int)len; 
     996                buf_incr = len; 
    1168997                ADIOI_BUF_INCR 
    1169998            } 
     
    11821011static void ADIOI_R_Exchange_data_alltoallv( 
    11831012                ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    1184                 *flat_buf, ADIO_Offset *offset_list, in
     1013                *flat_buf, ADIO_Offset *offset_list, ADIO_Offse
    11851014                *len_list, int *send_size, int *recv_size,  
    11861015                int *count, int *start_pos, int *partial_send, 
     
    11951024    int i, j, k=0, tmp=0, nprocs_recv, nprocs_send; 
    11961025    char **recv_buf = NULL; 
    1197     MPI_Request *requests; 
    1198     MPI_Datatype send_type; 
    1199     MPI_Status *statuses; 
     1026    MPI_Request *requests=NULL; 
     1027    MPI_Status *statuses=NULL; 
    12001028    int rtail, stail; 
    12011029    char *sbuf_ptr, *from_ptr; 
     
    12411069            sbuf_ptr = all_send_buf + sdispls[i]; 
    12421070            for (j=0; j<count[i]; j++) { 
    1243                 from_ptr = (char *)( others_req[i].mem_ptrs[ start_pos[i]+j ] ); 
     1071                ADIOI_ENSURE_AINT_FITS_IN_PTR( others_req[i].mem_ptrs[ start_pos[i]+j ]); 
     1072                from_ptr = (char *) ADIOI_AINT_CAST_TO_VOID_PTR ( others_req[i].mem_ptrs[ start_pos[i]+j ] ); 
    12441073                len      =           others_req[i].lens[     start_pos[i]+j ]  ; 
    12451074                memcpy( sbuf_ptr, from_ptr, len ); 
     
    12501079    } 
    12511080 
    1252 #if 0 
    1253     printf( "\tsend_size = " ); 
    1254     for (i=0; i<nprocs; i++) { printf( "%2d,", send_size[i] ); } 
    1255     printf( "\n" ); 
    1256     printf( "\trecv_size = " ); 
    1257     for (i=0; i<nprocs; i++) { printf( "%2d,", recv_size[i] ); } 
    1258     printf( "\n" ); 
    1259     printf( "\tsdispls   = " ); 
    1260     for (i=0; i<nprocs; i++) { printf( "%2d,", sdispls  [i] ); } 
    1261     printf( "\n" ); 
    1262     printf( "\trdispls   = " ); 
    1263     for (i=0; i<nprocs; i++) { printf( "%2d,", rdispls  [i] ); } 
    1264     printf( "\n" ); 
    1265     printf( "\ttails = %4d, %4d\n", stail, rtail ); 
    1266 #endif 
    1267 #if 0 
     1081#if RDCOLL_DEBUG 
     1082    DBG_FPRINTF(stderr, "\tsend_size = " ); 
     1083    for (i=0; i<nprocs; i++) { DBG_FPRINTF(stderr, "%2d,", send_size[i] ); } 
     1084    DBG_FPRINTF(stderr, "\n" ); 
     1085    DBG_FPRINTF(stderr, "\trecv_size = " ); 
     1086    for (i=0; i<nprocs; i++) { DBG_FPRINTF(stderr, "%2d,", recv_size[i] ); } 
     1087    DBG_FPRINTF(stderr, "\n" ); 
     1088    DBG_FPRINTF(stderr, "\tsdispls   = " ); 
     1089    for (i=0; i<nprocs; i++) { DBG_FPRINTF(stderr, "%2d,", sdispls  [i] ); } 
     1090    DBG_FPRINTF(stderr, "\n" ); 
     1091    DBG_FPRINTF(stderr, "\trdispls   = " ); 
     1092    for (i=0; i<nprocs; i++) { DBG_FPRINTF(stderr, "%2d,", rdispls  [i] ); } 
     1093    DBG_FPRINTF(stderr, "\n" ); 
     1094    DBG_FPRINTF(stderr, "\ttails = %4d, %4d\n", stail, rtail ); 
    12681095    if (nprocs_send) { 
    1269     printf( "\tall_send_buf = " ); 
    1270     for (i=0; i<nprocs; i++) { printf( "%2d,", all_send_buf  [i*131072] ); } 
    1271     printf( "\n" ); 
     1096    DBG_FPRINTF(stderr, "\tall_send_buf = " ); 
     1097    for (i=0; i<nprocs; i++) { DBG_FPRINTF(stderr, "%2d,", all_send_buf  [i*131072] ); } 
     1098    DBG_FPRINTF(stderr, "\n" ); 
    12721099    } 
    12731100#endif 
     
    12801107 
    12811108#if 0 
    1282     printf( "\tall_recv_buf = " ); 
    1283     for (i=131072; i<131073; i++) { printf( "%2d,", all_recv_buf  [i] ); } 
    1284     printf( "\n" ); 
     1109    DBG_FPRINTF(stderr, "\tall_recv_buf = " ); 
     1110    for (i=131072; i<131073; i++) { DBG_FPRINTF(stderr, "%2d,", all_recv_buf  [i] ); } 
     1111    DBG_FPRINTF(stderr, "\n" ); 
    12851112#endif 
    12861113     
     
    12891116        if (!buftype_is_contig) 
    12901117            ADIOI_Fill_user_buffer(fd, buf, flat_buf, recv_buf, 
    1291                                    offset_list, len_list, recv_size, 
     1118                                   offset_list, len_list, (unsigned*)recv_size, 
    12921119                                   requests, statuses,          /* never used inside */ 
    12931120                                   recd_from_proc, 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_read.c

    r616 r1249  
    2222                     ADIO_Offset offset, ADIO_Status *status, int *error_code) 
    2323{ 
    24     int err=-1, datatype_size, len; 
     24    int err=-1, datatype_size; 
     25    ADIO_Offset len; 
    2526    static char myname[] = "ADIOI_BGL_READCONTIG"; 
    2627 
     
    3637 
    3738    MPI_Type_size(datatype, &datatype_size); 
    38     len = datatype_size * count; 
     39    len = (ADIO_Offset)datatype_size * (ADIO_Offset)count; 
     40    ADIOI_Assert(len == (unsigned int) len); /* read takes an unsigned int parm */ 
    3941 
    4042#if BGL_PROFILE 
     
    4951        else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 
    5052                if (bglmpio_timing2) io_time2 = MPI_Wtime(); 
    51         err = read(fd->fd_sys, buf, len); 
     53        err = read(fd->fd_sys, buf, (unsigned int)len); 
    5254                if (bglmpio_timing2) bglmpio_prof_cr[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 
    5355        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
     
    6567        else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 
    6668                if (bglmpio_timing2) io_time2 = MPI_Wtime(); 
    67         err = read(fd->fd_sys, buf, len); 
     69        err = read(fd->fd_sys, buf, (unsigned int)len); 
    6870                if (bglmpio_timing2) bglmpio_prof_cr[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 
    6971        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
     
    8082            ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    8183        else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 
    82         err = read(fd->fd_sys, buf, len); 
     84        err = read(fd->fd_sys, buf, (unsigned int)len); 
    8385        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
    8486        fd->fp_sys_posn = offset + err; 
     
    9294            ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    9395        else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 
    94         err = read(fd->fd_sys, buf, len); 
     96        err = read(fd->fd_sys, buf, (unsigned int)len); 
    9597        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
    9698        fd->fp_ind += err; 
     
    121123 
    122124 
     125void ADIOI_BGL_ReadStrided(ADIO_File fd, void *buf, int count, 
     126                       MPI_Datatype datatype, int file_ptr_type, 
     127                       ADIO_Offset offset, ADIO_Status *status, int 
     128                       *error_code) 
     129{ 
     130/* offset is in units of etype relative to the filetype. */ 
    123131 
    124132#define ADIOI_BUFFERED_READ \ 
     
    126134    if (req_off >= readbuf_off + readbuf_len) { \ 
    127135        readbuf_off = req_off; \ 
    128         readbuf_len = (int) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1));\ 
     136        readbuf_len = (unsigned) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1));\ 
    129137        lseek(fd->fd_sys, readbuf_off, SEEK_SET);\ 
    130138        if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);\ 
     
    134142    } \ 
    135143    while (req_len > readbuf_off + readbuf_len - req_off) { \ 
     144  ADIOI_Assert((readbuf_off + readbuf_len - req_off) == (int) (readbuf_off + readbuf_len - req_off));\ 
    136145        partial_read = (int) (readbuf_off + readbuf_len - req_off); \ 
    137146        tmp_buf = (char *) ADIOI_Malloc(partial_read); \ 
     
    142151        ADIOI_Free(tmp_buf); \ 
    143152        readbuf_off += readbuf_len-partial_read; \ 
    144         readbuf_len = (int) (partial_read + ADIOI_MIN(max_bufsize, \ 
     153        readbuf_len = (unsigned) (partial_read + ADIOI_MIN(max_bufsize, \ 
    145154                                       end_offset-readbuf_off+1)); \ 
    146155        lseek(fd->fd_sys, readbuf_off+partial_read, SEEK_SET);\ 
     
    150159        if (err == -1) err_flag = 1; \ 
    151160    } \ 
     161    ADIOI_Assert(req_len == (size_t)req_len); \ 
    152162    memcpy((char *)buf + userbuf_off, readbuf+req_off-readbuf_off, req_len); \ 
    153163} 
    154164 
    155165 
    156 void ADIOI_BGL_ReadStrided(ADIO_File fd, void *buf, int count, 
    157                        MPI_Datatype datatype, int file_ptr_type, 
    158                        ADIO_Offset offset, ADIO_Status *status, int 
    159                        *error_code) 
    160 { 
    161 /* offset is in units of etype relative to the filetype. */ 
    162166 
    163167    ADIOI_Flatlist_node *flat_buf, *flat_file; 
    164     int i, j, k, err=-1, brd_size, frd_size=0, st_index=0; 
    165     int bufsize, num, size, sum, n_etypes_in_filetype, size_in_filetype; 
    166     int n_filetypes, etype_in_filetype; 
     168    ADIO_Offset i_offset, new_brd_size, brd_size, size; 
     169    int j, k, err=-1, st_index=0; 
     170    ADIO_Offset frd_size=0, new_frd_size, st_frd_size; 
     171    unsigned bufsize, num;  
     172    int n_etypes_in_filetype; 
     173    ADIO_Offset n_filetypes, etype_in_filetype, size_in_filetype; 
    167174    ADIO_Offset abs_off_in_filetype=0; 
    168     int filetype_size, etype_size, buftype_size, req_len, partial_read; 
     175    int filetype_size, etype_size, buftype_size, partial_read; 
    169176    MPI_Aint filetype_extent, buftype_extent;  
    170177    int buf_count, buftype_is_contig, filetype_is_contig; 
    171     ADIO_Offset userbuf_off
     178    ADIO_Offset userbuf_off, req_len, sum
    172179    ADIO_Offset off, req_off, disp, end_offset=0, readbuf_off, start_off; 
    173180    char *readbuf, *tmp_buf, *value; 
    174     int flag, st_frd_size, st_n_filetypes, readbuf_len
    175     int new_brd_size, new_frd_size, err_flag=0, info_flag, max_bufsize
    176  
     181    int flag, st_n_filetypes
     182    int err_flag=0, info_flag
     183    unsigned max_bufsize, readbuf_len; 
    177184    static char myname[] = "ADIOI_BGL_READSTRIDED"; 
    178185 
     
    208215    etype_size = fd->etype_size; 
    209216 
     217    ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count)); 
    210218    bufsize = buftype_size * count; 
    211219 
     
    227235 
    228236        off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :  
    229                  fd->disp + etype_size * offset; 
     237                 fd->disp + (ADIO_Offset)etype_size * offset; 
    230238 
    231239        start_off = off; 
     
    233241        readbuf_off = off; 
    234242        readbuf = (char *) ADIOI_Malloc(max_bufsize); 
    235         readbuf_len = (int) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1)); 
     243        readbuf_len = (unsigned) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1)); 
    236244 
    237245/* if atomicity is true, lock (exclusive) the region to be accessed */ 
     
    246254 
    247255        for (j=0; j<count; j++)  
    248             for (i=0; i<flat_buf->count; i++) { 
    249                 userbuf_off = j*buftype_extent + flat_buf->indices[i]; 
    250                 req_off = off; 
    251                 req_len = flat_buf->blocklens[i]; 
    252                 ADIOI_BUFFERED_READ 
    253                 off += flat_buf->blocklens[i]; 
    254             } 
     256        { 
     257          int i; 
     258              for (i=0; i<flat_buf->count; i++) { 
     259                  userbuf_off = (ADIO_Offset)j*(ADIO_Offset)buftype_extent + flat_buf->indices[i]; 
     260      req_off = off; 
     261      req_len = flat_buf->blocklens[i]; 
     262      ADIOI_BUFFERED_READ 
     263                  off += flat_buf->blocklens[i]; 
     264              } 
     265        } 
    255266 
    256267        if (fd->atomicity) 
     
    282293            flag = 0; 
    283294            while (!flag) { 
     295        int i; 
    284296                n_filetypes++; 
    285297                for (i=0; i<flat_file->count; i++) { 
    286298                    if (disp + flat_file->indices[i] +  
    287                         (ADIO_Offset) n_filetypes*filetype_extent + flat_file->blocklens[i]  
     299                        n_filetypes*(ADIO_Offset)filetype_extent + flat_file->blocklens[i]  
    288300                            >= offset) { 
    289301                        st_index = i; 
    290                         frd_size = (int) (disp + flat_file->indices[i] +  
    291                                 (ADIO_Offset) n_filetypes*filetype_extent 
    292                                  + flat_file->blocklens[i] - offset)
     302                        frd_size = disp + flat_file->indices[i] +  
     303                                n_filetypes*(ADIO_Offset)filetype_extent 
     304                                 + flat_file->blocklens[i] - offset
    293305                        flag = 1; 
    294306                        break; 
     
    298310        } 
    299311        else { 
     312    int i; 
    300313            n_etypes_in_filetype = filetype_size/etype_size; 
    301             n_filetypes = (int) (offset / n_etypes_in_filetype)
    302             etype_in_filetype = (int) (offset % n_etypes_in_filetype)
     314            n_filetypes = offset / n_etypes_in_filetype
     315            etype_in_filetype = offset % n_etypes_in_filetype
    303316            size_in_filetype = etype_in_filetype * etype_size; 
    304317  
     
    316329 
    317330            /* abs. offset in bytes in the file */ 
    318             offset = disp + (ADIO_Offset) n_filetypes*filetype_extent + abs_off_in_filetype; 
     331            offset = disp + n_filetypes*(ADIO_Offset)filetype_extent + abs_off_in_filetype; 
    319332        } 
    320333 
     
    326339        st_frd_size = frd_size; 
    327340        st_n_filetypes = n_filetypes; 
    328         i = 0; 
     341        i_offset = 0; 
    329342        j = st_index; 
    330343        off = offset; 
    331344        frd_size = ADIOI_MIN(st_frd_size, bufsize); 
    332         while (i < bufsize) { 
    333             i += frd_size; 
     345        while (i_offset < bufsize) { 
     346            i_offset += frd_size; 
    334347            end_offset = off + frd_size - 1; 
    335348 
     
    340353            } 
    341354 
    342             off = disp + flat_file->indices[j] + (ADIO_Offset) n_filetypes*filetype_extent; 
    343             frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
     355            off = disp + flat_file->indices[j] + n_filetypes*(ADIO_Offset)filetype_extent; 
     356            frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i_offset); 
    344357        } 
    345358 
     
    351364        readbuf_off = offset; 
    352365        readbuf = (char *) ADIOI_Malloc(max_bufsize); 
    353         readbuf_len = (int) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1)); 
     366        readbuf_len = (unsigned) (ADIOI_MIN(max_bufsize, end_offset-readbuf_off+1)); 
    354367 
    355368        lseek(fd->fd_sys, offset, SEEK_SET); 
     
    365378   common case. */ 
    366379 
    367             i = 0; 
     380            i_offset = 0; 
    368381            j = st_index; 
    369382            off = offset; 
    370383            n_filetypes = st_n_filetypes; 
    371384            frd_size = ADIOI_MIN(st_frd_size, bufsize); 
    372             while (i < bufsize) { 
     385            while (i_offset < bufsize) { 
    373386                if (frd_size) {  
    374387                    /* TYPE_UB and TYPE_LB can result in  
     
    379392                    req_off = off; 
    380393                    req_len = frd_size; 
    381                     userbuf_off = i
     394                    userbuf_off = i_offset
    382395                    ADIOI_BUFFERED_READ 
    383396                } 
    384                 i += frd_size; 
     397                i_offset += frd_size; 
    385398 
    386399                if (off + frd_size < disp + flat_file->indices[j] + 
    387                    flat_file->blocklens[j] + (ADIO_Offset) n_filetypes*filetype_extent) 
     400                   flat_file->blocklens[j] + n_filetypes*(ADIO_Offset)filetype_extent) 
    388401                       off += frd_size; 
    389402                /* did not reach end of contiguous block in filetype. 
     
    396409                    } 
    397410                    off = disp + flat_file->indices[j] +  
    398                                         (ADIO_Offset) n_filetypes*filetype_extent; 
    399                     frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
     411                                        n_filetypes*(ADIO_Offset)filetype_extent; 
     412                    frd_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i_offset); 
    400413                } 
    401414            } 
     
    409422 
    410423            k = num = buf_count = 0; 
    411             i = (int) (flat_buf->indices[0])
     424            i_offset = flat_buf->indices[0]
    412425            j = st_index; 
    413426            off = offset; 
     
    424437                    req_off = off; 
    425438                    req_len = size; 
    426                     userbuf_off = i
     439                    userbuf_off = i_offset
    427440                    ADIOI_BUFFERED_READ 
    428441                } 
     
    440453 
    441454                    off = disp + flat_file->indices[j] +  
    442                                               (ADIO_Offset) n_filetypes*filetype_extent; 
     455                                              n_filetypes*(ADIO_Offset)filetype_extent; 
    443456 
    444457                    new_frd_size = flat_file->blocklens[j]; 
    445458                    if (size != brd_size) { 
    446                         i += size; 
     459                        i_offset += size; 
    447460                        new_brd_size -= size; 
    448461                    } 
     
    454467                    k = (k + 1)%flat_buf->count; 
    455468                    buf_count++; 
    456                     i = (int) (buftype_extent*(buf_count/flat_buf->count) + 
     469                    i_offset = ((ADIO_Offset)buftype_extent*(ADIO_Offset)(buf_count/flat_buf->count) + 
    457470                        flat_buf->indices[k]);  
    458471                    new_brd_size = flat_buf->blocklens[k]; 
     
    462475                    } 
    463476                } 
     477    ADIOI_Assert(((ADIO_Offset)num + size) == (unsigned)(num + size)); 
    464478                num += size; 
    465479                frd_size = new_frd_size; 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_wrcoll.c

    r968 r1249  
    2727                         datatype, int nprocs, int myrank, ADIOI_Access 
    2828                         *others_req, ADIO_Offset *offset_list, 
    29                          int *len_list, int contig_access_count, ADIO_Offset 
     29                         ADIO_Offset *len_list, int contig_access_count, ADIO_Offset 
    3030                         min_st_offset, ADIO_Offset fd_size, 
    3131                         ADIO_Offset *fd_start, ADIO_Offset *fd_end, 
     
    3333static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf, 
    3434                         ADIOI_Flatlist_node *flat_buf, ADIO_Offset  
    35                          *offset_list, int *len_list, int *send_size,  
     35                         *offset_list, ADIO_Offset *len_list, int *send_size,  
    3636                         int *recv_size, ADIO_Offset off, int size, 
    3737                         int *count, int *start_pos, int *partial_recv,  
     
    5050                ADIOI_Flatlist_node *flat_buf,  
    5151                ADIO_Offset *offset_list,  
    52                 int *len_list, int *send_size, int *recv_size,  
     52                ADIO_Offset *len_list, int *send_size, int *recv_size,  
    5353                ADIO_Offset off, int size,                              /* 2 */ 
    5454                int *count, int *start_pos, int *partial_recv, 
     
    6666static void ADIOI_Fill_send_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    6767                           *flat_buf, char **send_buf, ADIO_Offset  
    68                            *offset_list, int *len_list, int *send_size,  
     68                           *offset_list, ADIO_Offset *len_list, int *send_size,  
    6969                           MPI_Request *requests, int *sent_to_proc,  
    7070                           int nprocs, int myrank,  
     
    7777static void ADIOI_Fill_send_buffer_nosend(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    7878                           *flat_buf, char **send_buf, ADIO_Offset  
    79                            *offset_list, int *len_list, int *send_size,  
     79                           *offset_list, ADIO_Offset *len_list, int *send_size,  
    8080                           MPI_Request *requests, int *sent_to_proc,  
    8181                           int nprocs, int myrank,  
     
    119119    int  ii; 
    120120 
    121     int *buf_idx = NULL, *len_list = NULL; 
    122  
     121    int *buf_idx = NULL; 
     122    ADIO_Offset *len_list = NULL; 
     123/* 
    123124    double io_time = 0, all_time, max_all_time; 
    124125    double tstep1, max_tstep1; 
     
    130131    double tstep4, max_tstep4; 
    131132    double sum_sz; 
    132  
     133*/ 
    133134#if BGL_PROFILE  
    134135    BGLMPIO_T_CIO_RESET( 0, w ) 
     
    377378                                 ADIOI_Access 
    378379                                 *others_req, ADIO_Offset *offset_list, 
    379                                  int *len_list, int contig_access_count, 
    380                                  ADIO_Offset 
    381                                  min_st_offset, ADIO_Offset fd_size, 
     380                                 ADIO_Offset *len_list, int contig_access_count, 
     381                                 ADIO_Offset min_st_offset, ADIO_Offset fd_size, 
    382382                                 ADIO_Offset *fd_start, ADIO_Offset *fd_end, 
    383383                                 int *buf_idx, int *error_code) 
     
    392392   at least another 8Mbytes of temp space is unacceptable. */ 
    393393 
    394     int hole, i, j, m, size=0, ntimes, max_ntimes, buftype_is_contig; 
     394    /* Not convinced end_loc-st_loc couldn't be > int, so make these offsets*/ 
     395    ADIO_Offset size=0; 
     396    int hole, i, j, m, ntimes, max_ntimes, buftype_is_contig; 
    395397    ADIO_Offset st_loc=-1, end_loc=-1, off, done, req_off; 
    396398    char *write_buf=NULL; 
     
    529531        for (i=0; i < nprocs; i++) count[i] = recv_size[i] = 0; 
    530532 
    531         size = (int) (ADIOI_MIN(coll_bufsize, end_loc-st_loc+1-done));  
     533        size = ADIOI_MIN((unsigned)coll_bufsize, end_loc-st_loc+1-done);  
    532534 
    533535        for (i=0; i < nprocs; i++) { 
     
    553555                    if (req_off < off + size) { 
    554556                        count[i]++; 
     557      ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)write_buf)+req_off-off) == (ADIO_Offset)(MPIR_Upint)(write_buf+req_off-off)); 
    555558                        MPI_Address(write_buf+req_off-off,  
    556559                               &(others_req[i].mem_ptrs[j])); 
    557                         recv_size[i] += (int)(ADIOI_MIN(off + (ADIO_Offset)size -  
    558                                                   req_off, req_len)); 
    559  
    560                         if (off+size-req_off < req_len) 
     560      ADIOI_Assert((off + size - req_off) == (int)(off + size - req_off)); 
     561                        recv_size[i] += (int)(ADIOI_MIN(off + size - req_off,  
     562                                      (unsigned)req_len)); 
     563 
     564                        if (off+size-req_off < (unsigned)req_len) 
    561565                        { 
    562566                            partial_recv[i] = (int) (off + size - req_off); 
     
    621625 
    622626        if (flag) { 
    623             ADIO_WriteContig(fd, write_buf, size, MPI_BYTE, ADIO_EXPLICIT_OFFSET,  
     627      ADIOI_Assert(size == (int)size); 
     628            ADIO_WriteContig(fd, write_buf, (int)size, MPI_BYTE, ADIO_EXPLICIT_OFFSET,  
    624629                        off, &status, error_code); 
    625630            if (*error_code != MPI_SUCCESS) return; 
     
    681686static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf, 
    682687                                  ADIOI_Flatlist_node *flat_buf, ADIO_Offset  
    683                                   *offset_list, int *len_list, int *send_size,  
     688                                  *offset_list, ADIO_Offset *len_list, int *send_size,  
    684689                                  int *recv_size, ADIO_Offset off, int size, 
    685690                                  int *count, int *start_pos, 
     
    921926            } \ 
    922927            user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 
    923                               n_buftypes*buftype_extent; \ 
     928                              (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 
    924929            flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 
    925930        } \ 
     
    933938    while (size) { \ 
    934939        size_in_buf = ADIOI_MIN(size, flat_buf_sz); \ 
     940  ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)buf) + user_buf_idx) == (ADIO_Offset)(MPIR_Upint)(buf + user_buf_idx)); \ 
     941  ADIOI_Assert(size_in_buf == (size_t)size_in_buf); \ 
    935942        memcpy(&(send_buf[p][send_buf_idx[p]]), \ 
    936943               ((char *) buf) + user_buf_idx, size_in_buf); \ 
     
    945952            } \ 
    946953            user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 
    947                               n_buftypes*buftype_extent; \ 
     954                              (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 
    948955            flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 
    949956        } \ 
     
    954961} 
    955962 
    956  
    957  
    958963static void ADIOI_Fill_send_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    959964                           *flat_buf, char **send_buf, ADIO_Offset  
    960                            *offset_list, int *len_list, int *send_size,  
     965                           *offset_list, ADIO_Offset *len_list, int *send_size,  
    961966                           MPI_Request *requests, int *sent_to_proc,  
    962967                           int nprocs, int myrank,  
     
    970975/* this function is only called if buftype is not contig */ 
    971976 
    972     int i, p, flat_buf_idx, size; 
    973     int flat_buf_sz, buf_incr, size_in_buf, jj, n_buftypes; 
     977    int i, p, flat_buf_idx; 
     978    ADIO_Offset flat_buf_sz, size_in_buf, buf_incr, size; 
     979    int jj, n_buftypes; 
    974980    ADIO_Offset off, len, rem_len, user_buf_idx; 
    975981 
     
    9981004    for (i=0; i<contig_access_count; i++) {  
    9991005        off     = offset_list[i]; 
    1000         rem_len = (ADIO_Offset) len_list[i]; 
     1006        rem_len = len_list[i]; 
    10011007 
    10021008        /*this request may span the file domains of more than one process*/ 
     
    10181024                if (curr_to_proc[p]+len > done_to_proc[p]) { 
    10191025                    if (done_to_proc[p] > curr_to_proc[p]) { 
    1020                         size = (int)ADIOI_MIN(curr_to_proc[p] + len -  
     1026                        size = ADIOI_MIN(curr_to_proc[p] + len -  
    10211027                                done_to_proc[p], send_size[p]-send_buf_idx[p]); 
    10221028                        buf_incr = done_to_proc[p] - curr_to_proc[p]; 
    10231029                        ADIOI_BUF_INCR 
    1024                         buf_incr = (int)(curr_to_proc[p] + len - done_to_proc[p]); 
     1030      ADIOI_Assert((curr_to_proc[p] + len - done_to_proc[p]) == (unsigned)(curr_to_proc[p] + len - done_to_proc[p])); 
     1031                        buf_incr = curr_to_proc[p] + len - done_to_proc[p]; 
     1032      ADIOI_Assert((done_to_proc[p] + size) == (unsigned)(done_to_proc[p] + size)); 
    10251033                        curr_to_proc[p] = done_to_proc[p] + size; 
    10261034                        ADIOI_BUF_COPY 
    10271035                    } 
    10281036                    else { 
    1029                         size = (int)ADIOI_MIN(len,send_size[p]-send_buf_idx[p]); 
    1030                         buf_incr = (int)len; 
     1037                        size = ADIOI_MIN(len,send_size[p]-send_buf_idx[p]); 
     1038                        buf_incr = len; 
     1039      ADIOI_Assert((curr_to_proc[p] + size) == (unsigned)((ADIO_Offset)curr_to_proc[p] + size)); 
    10311040                        curr_to_proc[p] += size; 
    10321041                        ADIOI_BUF_COPY 
     
    10391048                } 
    10401049                else { 
    1041                     curr_to_proc[p] += (int)len; 
    1042                     buf_incr = (int)len; 
     1050        ADIOI_Assert((curr_to_proc[p] + len) == (unsigned)((ADIO_Offset)curr_to_proc[p] + len)); 
     1051                    curr_to_proc[p] += len; 
     1052                    buf_incr = len; 
    10431053                    ADIOI_BUF_INCR 
    10441054                } 
    10451055            } 
    10461056            else { 
    1047                 buf_incr = (int)len; 
     1057                buf_incr = len; 
    10481058                ADIOI_BUF_INCR 
    10491059            } 
     
    11841194                ADIOI_Flatlist_node *flat_buf,  
    11851195                ADIO_Offset *offset_list,  
    1186                 int *len_list, int *send_size, int *recv_size,  
     1196                ADIO_Offset *len_list, int *send_size, int *recv_size,  
    11871197                ADIO_Offset off, int size,                              /* 2 */ 
    11881198                int *count, int *start_pos, int *partial_recv, 
     
    11991209                int *error_code) 
    12001210{    
    1201     int i, j, k=0, tmp=0, nprocs_recv, nprocs_send, erri, *tmp_len, err; 
     1211    int i, j, k=0, nprocs_recv, nprocs_send, *tmp_len, err; 
    12021212    char **send_buf = NULL; 
    1203     MPI_Request *requests, *send_req; 
    1204     MPI_Datatype recv_type; 
    1205     MPI_Status *statuses, status; 
     1213    MPI_Request *send_req=NULL; 
     1214    MPI_Status status; 
    12061215    int rtail, stail; 
    12071216    char *sbuf_ptr, *to_ptr; 
     
    13271336            sbuf_ptr = all_recv_buf + rdispls[i]; 
    13281337            for (j=0; j<count[i]; j++) { 
    1329                 to_ptr = (char *)( others_req[i].mem_ptrs[ start_pos[i]+j ] ); 
     1338                ADIOI_ENSURE_AINT_FITS_IN_PTR(others_req[i].mem_ptrs[ start_pos[i]+j ]); 
     1339                to_ptr = (char *) ADIOI_AINT_CAST_TO_VOID_PTR ( others_req[i].mem_ptrs[ start_pos[i]+j ] ); 
    13301340                len    =           others_req[i].lens[     start_pos[i]+j ]  ; 
    13311341                memcpy( to_ptr, sbuf_ptr, len ); 
     
    13521362static void ADIOI_Fill_send_buffer_nosend(ADIO_File fd, void *buf, ADIOI_Flatlist_node 
    13531363                           *flat_buf, char **send_buf, ADIO_Offset  
    1354                            *offset_list, int *len_list, int *send_size,  
     1364                           *offset_list, ADIO_Offset *len_list, int *send_size,  
    13551365                           MPI_Request *requests, int *sent_to_proc,  
    13561366                           int nprocs, int myrank,  
     
    13641374/* this function is only called if buftype is not contig */ 
    13651375 
    1366     int i, p, flat_buf_idx, size; 
    1367     int flat_buf_sz, buf_incr, size_in_buf, jj, n_buftypes; 
     1376    int i, p, flat_buf_idx; 
     1377    ADIO_Offset flat_buf_sz, size_in_buf, buf_incr, size; 
     1378    int jj, n_buftypes; 
    13681379    ADIO_Offset off, len, rem_len, user_buf_idx; 
    13691380 
     
    13921403    for (i=0; i<contig_access_count; i++) {  
    13931404        off     = offset_list[i]; 
    1394         rem_len = (ADIO_Offset) len_list[i]; 
     1405        rem_len = len_list[i]; 
    13951406 
    13961407        /*this request may span the file domains of more than one process*/ 
     
    14121423                if (curr_to_proc[p]+len > done_to_proc[p]) { 
    14131424                    if (done_to_proc[p] > curr_to_proc[p]) { 
    1414                         size = (int)ADIOI_MIN(curr_to_proc[p] + len -  
     1425                        size = ADIOI_MIN(curr_to_proc[p] + len -  
    14151426                                done_to_proc[p], send_size[p]-send_buf_idx[p]); 
    14161427                        buf_incr = done_to_proc[p] - curr_to_proc[p]; 
    14171428                        ADIOI_BUF_INCR 
    1418                         buf_incr = (int)(curr_to_proc[p] + len - done_to_proc[p]); 
     1429      ADIOI_Assert((curr_to_proc[p] + len - done_to_proc[p]) == (unsigned)(curr_to_proc[p] + len - done_to_proc[p])); 
     1430                        buf_incr = curr_to_proc[p] + len - done_to_proc[p]; 
     1431      ADIOI_Assert((done_to_proc[p] + size) == (unsigned)(done_to_proc[p] + size)); 
    14191432                        curr_to_proc[p] = done_to_proc[p] + size; 
    14201433                        ADIOI_BUF_COPY 
    14211434                    } 
    14221435                    else { 
    1423                         size = (int)ADIOI_MIN(len,send_size[p]-send_buf_idx[p]); 
    1424                         buf_incr = (int)len; 
     1436                        size = ADIOI_MIN(len,send_size[p]-send_buf_idx[p]); 
     1437                        buf_incr = len; 
     1438      ADIOI_Assert((curr_to_proc[p] + size) == (unsigned)((ADIO_Offset)curr_to_proc[p] + size)); 
    14251439                        curr_to_proc[p] += size; 
    14261440                        ADIOI_BUF_COPY 
     
    14361450                } 
    14371451                else { 
     1452        ADIOI_Assert((curr_to_proc[p] + len) == (unsigned)((ADIO_Offset)curr_to_proc[p] + len)); 
    14381453                    curr_to_proc[p] += (int)len; 
    1439                     buf_incr = (int)len; 
     1454                    buf_incr = len; 
    14401455                    ADIOI_BUF_INCR 
    14411456                } 
    14421457            } 
    14431458            else { 
    1444                 buf_incr = (int)len; 
     1459                buf_incr = len; 
    14451460                ADIOI_BUF_INCR 
    14461461            } 
  • mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_write.c

    r616 r1249  
    2222                     ADIO_Offset offset, ADIO_Status *status, int *error_code) 
    2323{ 
    24     int err=-1, datatype_size, len; 
     24    int err=-1, datatype_size; 
     25    ADIO_Offset len; 
    2526    static char myname[] = "ADIOI_BGL_WRITECONTIG"; 
    2627 
     
    3637                           
    3738    MPI_Type_size(datatype, &datatype_size); 
    38     len = datatype_size * count; 
     39    len = (ADIO_Offset)datatype_size * (ADIO_Offset)count; 
     40    ADIOI_Assert(len == (unsigned int) len); /* write takes an unsigned int parm */ 
    3941 
    4042#if BGL_PROFILE 
     
    4749        ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    4850                if (bglmpio_timing2) io_time2 = MPI_Wtime(); 
    49         err = write(fd->fd_sys, buf, len); 
     51        err = write(fd->fd_sys, buf, (unsigned int)len); 
    5052                if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 
    5153        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
     
    6163        ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    6264                if (bglmpio_timing2) io_time2 = MPI_Wtime(); 
    63         err = write(fd->fd_sys, buf, len); 
     65        err = write(fd->fd_sys, buf, (unsigned int)len); 
    6466                if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 
    6567        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
     
    7476            lseek(fd->fd_sys, offset, SEEK_SET); 
    7577        ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    76         err = write(fd->fd_sys, buf, len); 
     78        err = write(fd->fd_sys, buf, (unsigned int)len); 
    7779        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
    7880        fd->fp_sys_posn = offset + err; 
     
    8486            lseek(fd->fd_sys, fd->fp_ind, SEEK_SET); 
    8587        ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 
    86         err = write(fd->fd_sys, buf, len); 
     88        err = write(fd->fd_sys, buf, (unsigned int)len); 
    8789        ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 
    8890        fd->fp_ind += err; 
     
    114116 
    115117 
     118void ADIOI_BGL_WriteStrided(ADIO_File fd, void *buf, int count, 
     119                       MPI_Datatype datatype, int file_ptr_type, 
     120                       ADIO_Offset offset, ADIO_Status *status, int 
     121                       *error_code) 
     122{ 
     123/* offset is in units of etype relative to the filetype. */ 
    116124 
    117125 
     
    124132        if (err == -1) err_flag = 1; \ 
    125133        writebuf_off = req_off; \ 
    126         writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
     134        writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
    127135        if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \ 
    128136        lseek(fd->fd_sys, writebuf_off, SEEK_SET); \ 
     
    136144        } \ 
    137145    } \ 
    138     write_sz = (int) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \ 
     146    write_sz = (unsigned) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \ 
     147    ADIOI_Assert((ADIO_Offset)write_sz == ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off));\ 
    139148    memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\ 
    140149    while (write_sz != req_len) { \ 
     
    146155        userbuf_off += write_sz; \ 
    147156        writebuf_off += writebuf_len; \ 
    148         writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
     157        writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
    149158        if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \ 
    150159        lseek(fd->fd_sys, writebuf_off, SEEK_SET); \ 
     
    174183        if (err == -1) err_flag = 1; \ 
    175184        writebuf_off = req_off; \ 
    176         writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
     185        writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
    177186    } \ 
    178     write_sz = (int) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \ 
     187    write_sz = (unsigned) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \ 
     188    ADIOI_Assert((ADIO_Offset)write_sz == ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off));\ 
    179189    memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\ 
    180190    while (write_sz != req_len) { \ 
     
    187197        userbuf_off += write_sz; \ 
    188198        writebuf_off += writebuf_len; \ 
    189         writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
     199        writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\ 
    190200        write_sz = ADIOI_MIN(req_len, writebuf_len); \ 
    191201        memcpy(writebuf, (char *)buf + userbuf_off, write_sz);\ 
     
    195205 
    196206 
    197 void ADIOI_BGL_WriteStrided(ADIO_File fd, void *buf, int count, 
    198                        MPI_Datatype datatype, int file_ptr_type, 
    199                        ADIO_Offset offset, ADIO_Status *status, int 
    200                        *error_code) 
    201 { 
    202 /* offset is in units of etype relative to the filetype. */ 
    203207 
    204208    ADIOI_Flatlist_node *flat_buf, *flat_file; 
    205     int i, j, k, err=-1, bwr_size, fwr_size=0, st_index=0; 
    206     int bufsize, num, size, sum, n_etypes_in_filetype, size_in_filetype; 
    207     int n_filetypes, etype_in_filetype; 
     209    ADIO_Offset i_offset, sum, size_in_filetype; 
     210    int j, k, err=-1, st_index=0; 
     211    int n_etypes_in_filetype; 
     212    ADIO_Offset num, size, n_filetypes, etype_in_filetype, st_n_filetypes; 
    208213    ADIO_Offset abs_off_in_filetype=0; 
    209     int filetype_size, etype_size, buftype_size, req_len
     214    int filetype_size, etype_size, buftype_size
    210215    MPI_Aint filetype_extent, buftype_extent;  
    211216    int buf_count, buftype_is_contig, filetype_is_contig; 
     
    213218    ADIO_Offset off, req_off, disp, end_offset=0, writebuf_off, start_off; 
    214219    char *writebuf, *value; 
    215     int flag, st_fwr_size, st_n_filetypes, writebuf_len, write_sz; 
    216     int new_bwr_size, new_fwr_size, err_flag=0, info_flag, max_bufsize; 
     220    int flag; 
     221    unsigned bufsize, writebuf_len, max_bufsize, write_sz; 
     222    int err_flag=0, info_flag; 
     223    ADIO_Offset new_bwr_size, new_fwr_size, st_fwr_size, fwr_size=0, bwr_size, req_len; 
    217224    static char myname[] = "ADIOI_BGL_WRITESTRIDED"; 
    218225 
     
    248255    etype_size = fd->etype_size; 
    249256 
     257    ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count)); 
    250258    bufsize = buftype_size * count; 
    251259 
     
    273281        writebuf_off = off; 
    274282        writebuf = (char *) ADIOI_Malloc(max_bufsize); 
    275         writebuf_len = (int) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1)); 
     283        writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1)); 
    276284 
    277285/* if atomicity is true, lock the region to be accessed */ 
     
    280288 
    281289        for (j=0; j<count; j++)  
     290        { 
     291          int i; 
    282292            for (i=0; i<flat_buf->count; i++) { 
    283                 userbuf_off = j*buftype_extent + flat_buf->indices[i]; 
     293                userbuf_off = (ADIO_Offset)j*(ADIO_Offset)buftype_extent + flat_buf->indices[i]; 
    284294                req_off = off; 
    285295                req_len = flat_buf->blocklens[i]; 
     
    287297                off += flat_buf->blocklens[i]; 
    288298            } 
     299        } 
    289300 
    290301        /* write the buffer out finally */ 
     
    322333            flag = 0; 
    323334            while (!flag) { 
     335        int i; 
    324336                n_filetypes++; 
    325337                for (i=0; i<flat_file->count; i++) { 
    326338                    if (disp + flat_file->indices[i] +  
    327                         (ADIO_Offset) n_filetypes*filetype_extent + flat_file->blocklens[i]  
     339                        n_filetypes*(ADIO_Offset)filetype_extent + flat_file->blocklens[i]  
    328340                            >= offset) { 
    329341                        st_index = i; 
    330                         fwr_size = (int) (disp + flat_file->indices[i] +  
    331                                 (ADIO_Offset) n_filetypes*filetype_extent 
    332                                  + flat_file->blocklens[i] - offset)
     342                        fwr_size = disp + flat_file->indices[i] +  
     343                                n_filetypes*(ADIO_Offset)filetype_extent 
     344                                 + flat_file->blocklens[i] - offset
    333345                        flag = 1; 
    334346                        break; 
     
    338350        } 
    339351        else { 
     352    int i; 
    340353            n_etypes_in_filetype = filetype_size/etype_size; 
    341             n_filetypes = (int) (offset / n_etypes_in_filetype)
    342             etype_in_filetype = (int) (offset % n_etypes_in_filetype)
     354            n_filetypes = offset / n_etypes_in_filetype
     355            etype_in_filetype = offset % n_etypes_in_filetype
    343356            size_in_filetype = etype_in_filetype * etype_size; 
    344357  
     
    356369 
    357370            /* abs. offset in bytes in the file */ 
    358             offset = disp + (ADIO_Offset) n_filetypes*filetype_extent + abs_off_in_filetype; 
     371            offset = disp + n_filetypes*(ADIO_Offset)filetype_extent + abs_off_in_filetype; 
    359372        } 
    360373 
     
    366379        st_fwr_size = fwr_size; 
    367380        st_n_filetypes = n_filetypes; 
    368         i = 0; 
     381        i_offset = 0; 
    369382        j = st_index; 
    370383        off = offset; 
    371384        fwr_size = ADIOI_MIN(st_fwr_size, bufsize); 
    372         while (i < bufsize) { 
    373             i += fwr_size; 
     385        while (i_offset < bufsize) { 
     386            i_offset += fwr_size; 
    374387            end_offset = off + fwr_size - 1; 
    375388 
     
    380393            } 
    381394 
    382             off = disp + flat_file->indices[j] + (ADIO_Offset) n_filetypes*filetype_extent; 
    383             fwr_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
     395            off = disp + flat_file->indices[j] + n_filetypes*(ADIO_Offset)filetype_extent; 
     396            fwr_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i_offset); 
    384397        } 
    385398 
     
    391404        writebuf_off = offset; 
    392405        writebuf = (char *) ADIOI_Malloc(max_bufsize); 
    393         writebuf_len = (int)(ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1)); 
     406        writebuf_len = (unsigned)(ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1)); 
    394407        if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); 
    395408        lseek(fd->fd_sys, writebuf_off, SEEK_SET);  
     
    409422   common case. */ 
    410423 
    411             i = 0; 
     424            i_offset = 0; 
    412425            j = st_index; 
    413426            off = offset; 
    414427            n_filetypes = st_n_filetypes; 
    415428            fwr_size = ADIOI_MIN(st_fwr_size, bufsize); 
    416             while (i < bufsize) { 
     429            while (i_offset < bufsize) { 
    417430                if (fwr_size) {  
    418431                    /* TYPE_UB and TYPE_LB can result in  
    419432                       fwr_size = 0. save system call in such cases */  
    420433                    /* lseek(fd->fd_sys, off, SEEK_SET); 
    421                     err = write(fd->fd_sys, ((char *) buf) + i, fwr_size);*/ 
     434                    err = write(fd->fd_sys, ((char *) buf) + i_offset, fwr_size);*/ 
    422435 
    423436                    req_off = off; 
    424437                    req_len = fwr_size; 
    425                     userbuf_off = i
     438                    userbuf_off = i_offset
    426439                    ADIOI_BUFFERED_WRITE 
    427440                } 
    428                 i += fwr_size; 
     441                i_offset += fwr_size; 
    429442 
    430443                if (off + fwr_size < disp + flat_file->indices[j] + 
    431                    flat_file->blocklens[j] + (ADIO_Offset) n_filetypes*filetype_extent) 
     444                   flat_file->blocklens[j] + n_filetypes*(ADIO_Offset)filetype_extent) 
    432445                       off += fwr_size; 
    433446                /* did not reach end of contiguous block in filetype. 
     
    440453                    } 
    441454                    off = disp + flat_file->indices[j] +  
    442                                         (ADIO_Offset) n_filetypes*filetype_extent; 
    443                     fwr_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i); 
     455                                        n_filetypes*(ADIO_Offset)filetype_extent; 
     456                    fwr_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i_offset); 
    444457                } 
    445458            } 
     
    453466 
    454467            k = num = buf_count = 0; 
    455             i = (int) (flat_buf->indices[0])
     468            i_offset = flat_buf->indices[0]
    456469            j = st_index; 
    457470            off = offset; 
     
    464477                if (size) { 
    465478                    /* lseek(fd->fd_sys, off, SEEK_SET); 
    466                     err = write(fd->fd_sys, ((char *) buf) + i, size); */ 
     479                    err = write(fd->fd_sys, ((char *) buf) + i_offset, size); */ 
    467480 
    468481                    req_off = off; 
    469482                    req_len = size; 
    470                     userbuf_off = i
     483                    userbuf_off = i_offset
    471484                    ADIOI_BUFFERED_WRITE 
    472485                } 
     
    484497 
    485498                    off = disp + flat_file->indices[j] +  
    486                                   (ADIO_Offset) n_filetypes*filetype_extent; 
     499                                  n_filetypes*(ADIO_Offset)filetype_extent; 
    487500 
    488501                    new_fwr_size = flat_file->blocklens[j]; 
    489502                    if (size != bwr_size) { 
    490                         i += size; 
     503                        i_offset += size; 
    491504                        new_bwr_size -= size; 
    492505                    } 
     
    498511                    k = (k + 1)%flat_buf->count; 
    499512                    buf_count++; 
    500                     i = (int) (buftype_extent*(buf_count/flat_buf->count) + 
    501                         flat_buf->indices[k]);  
     513                    i_offset = (ADIO_Offset)buftype_extent*(ADIO_Offset)(buf_count/flat_buf->count) + 
     514                        flat_buf->indices[k];  
    502515                    new_bwr_size = flat_buf->blocklens[k]; 
    503516                    if (size != fwr_size) {