Changeset 1249 for mpich2/trunk/src/mpi/romio/adio/ad_bgl
- Timestamp:
- 08/02/08 21:32:54 (7 months ago)
- Files:
-
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.c (modified) (1 diff)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.h (modified) (1 diff)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c (modified) (27 diffs)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.h (modified) (2 diffs)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_close.c (modified) (1 diff)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_fcntl.c (modified) (1 diff)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_rdcoll.c (modified) (36 diffs)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_read.c (modified) (29 diffs)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_wrcoll.c (modified) (29 diffs)
- mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_write.c (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.c
r616 r1249 1 1 /* ---------------------------------------------------------------- */ 2 2 /* (C)Copyright IBM Corp. 2007, 2008 */ 3 /* ---------------------------------------------------------------- */ 3 4 /** 4 5 * \file ad_bgl.c mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl.h
r616 r1249 29 29 #endif 30 30 31 #if 0 31 32 int ADIOI_BGL_aio(ADIO_File fd, void *buf, int len, ADIO_Offset offset, 32 33 int wr, void *handle); 34 #endif 33 35 34 36 void ADIOI_BGL_Open(ADIO_File fd, int *error_code); mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.c
r616 r1249 1 1 /* ---------------------------------------------------------------- */ 2 2 /* (C)Copyright IBM Corp. 2007, 2008 */ 3 /* ---------------------------------------------------------------- */ 3 4 /** 4 5 * \file ad_bgl_aggrs.c … … 17 18 #include "ad_bgl_pset.h" 18 19 #include "ad_bgl_aggrs.h" 20 21 #ifdef USE_DBG_LOGGING 22 #define AGG_DEBUG 1 23 #endif 24 19 25 20 26 … … 220 226 int *aggrsInPset ) 221 227 { 222 # define DEBUG 0 223 # if DEBUG 228 # if AGG_DEBUG 224 229 int i; 225 230 # endif … … 230 235 tmp_ranklist = (int *) ADIOI_Malloc (confInfo->nProcs * sizeof(int)); 231 236 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 } 235 241 # endif 236 242 … … 240 246 # define VERIFY 0 241 247 # 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", 243 249 confInfo->PsetSize , 244 250 confInfo->numPsets , … … 251 257 # endif 252 258 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 } 256 263 # endif 257 264 … … 292 299 ADIO_Offset min_st_offset, max_end_offset, *fd_start, *fd_end, *fd_size; 293 300 int i, aggr; 301 # if AGG_DEBUG 294 302 static char myname[] = "ADIOI_BGL_GPFS_Calc_file_domains"; 303 # endif 295 304 __blksize_t blksize = 1048576; /* default to 1M */ 296 305 if(fs_ptr && ((ADIOI_BGL_fs*)fs_ptr)->blksize) /* ignore null ptr or 0 blksize */ 297 306 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 300 310 /* find the range of all the requests */ 301 311 min_st_offset = st_offsets [0]; … … 306 316 } 307 317 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 ); 309 319 310 320 /* determine the "file domain (FD)" of each process, i.e., the portion of … … 333 343 else fd_size[i] = (nb_cn_small+1) * blksize; 334 344 335 /* FPRINTF(stderr,"%s(%d): " 345 # if AGG_DEBUG 346 DBG_FPRINTF(stderr,"%s(%d): " 336 347 "gpfs_ub %llu, " 337 348 "gpfs_lb %llu, " … … 355 366 naggs_small 356 367 ); 357 */ 368 # endif 369 358 370 fd_size[0] -= gpfs_lb_rdoff; 359 371 fd_size[naggs-1] -= gpfs_ub_rdoff; … … 523 535 524 536 * 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", 526 538 naggs, 527 539 min_st_offset, … … 588 600 } 589 601 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 ); 591 603 592 604 /* … … 621 633 * (including this one) 622 634 */ 623 void ADIOI_BGL_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list, int *len_list,635 void ADIOI_BGL_Calc_my_req(ADIO_File fd, ADIO_Offset *offset_list, ADIO_Offset *len_list, 624 636 int contig_access_count, ADIO_Offset 625 637 min_st_offset, ADIO_Offset *fd_start, … … 630 642 ADIOI_Access **my_req_ptr, 631 643 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 */ 632 646 { 633 647 int *count_my_req_per_proc, count_my_req_procs, *buf_idx; … … 721 735 722 736 /* 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 } 724 742 725 743 l = my_req[proc].count; 726 curr_idx += (int) fd_len; /* NOTE: Why is curr_idx an int? Fix? */744 curr_idx += fd_len; 727 745 728 746 rem_len = len_list[i] - fd_len; … … 734 752 */ 735 753 my_req[proc].offsets[l] = off; 754 ADIOI_Assert(fd_len == (int) fd_len); 736 755 my_req[proc].lens[l] = (int) fd_len; 737 756 my_req[proc].count++; … … 743 762 fd_size, fd_start, fd_end); 744 763 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 } 746 769 747 770 l = my_req[proc].count; … … 750 773 751 774 my_req[proc].offsets[l] = off; 775 ADIOI_Assert(fd_len == (int) fd_len); 752 776 my_req[proc].lens[l] = (int) fd_len; 753 777 my_req[proc].count++; … … 758 782 for (i=0; i<nprocs; i++) { 759 783 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, 761 785 my_req[i].count); 762 786 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, 764 788 my_req[i].offsets[l], l, my_req[i].lens[l]); 765 789 } 766 790 } 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 } 773 793 #endif 774 794 … … 778 798 779 799 /* 780 * ADIOI_Calc_others_req 800 * ADIOI_Calc_others_req (copied to bgl and switched to all to all for performance) 781 801 * 782 802 * param[in] count_my_req_procs Number of processes whose file domain my … … 867 887 ADIOI_Malloc(count_others_req_per_proc[i]*sizeof(int)); 868 888 869 if ( ( unsigned)others_req[i].offsets < (unsigned)recvBufForOffsets )889 if ( (MPIR_Upint)others_req[i].offsets < (MPIR_Upint)recvBufForOffsets ) 870 890 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 ) 872 892 recvBufForLens = others_req[i].lens; 873 893 … … 884 904 } 885 905 } 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; 886 909 887 910 /* Now send the calculated offsets and lengths to respective processes */ … … 895 918 { 896 919 if ( (my_req[i].count) && 897 (( unsigned)my_req[i].offsets <= (unsigned)sendBufForOffsets) )898 920 ((MPIR_Upint)my_req[i].offsets <= (MPIR_Upint)sendBufForOffsets) ) 921 sendBufForOffsets = my_req[i].offsets; 899 922 900 923 if ( (my_req[i].count) && 901 (( unsigned)my_req[i].lens <= (unsigned)sendBufForLens) )924 ((MPIR_Upint)my_req[i].lens <= (MPIR_Upint)sendBufForLens) ) 902 925 sendBufForLens = my_req[i].lens; 903 926 } 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; 904 931 905 932 /* Calculate the displacements from the sendBufForOffsets/Lens */ … … 911 938 sdispls[i] = 0; 912 939 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) ); 915 944 916 945 // Receive these offsets from process i. … … 919 948 rdispls[i] = 0; 920 949 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) ); 923 954 } 924 955 … … 941 972 sdispls[i] = 0; 942 973 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) ); 945 978 946 979 // Receive these offsets from process i. … … 949 982 rdispls[i] = 0; 950 983 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) ); 953 988 } 954 989 mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_aggrs.h
r616 r1249 1 1 /* ---------------------------------------------------------------- */ 2 2 /* (C)Copyright IBM Corp. 2007, 2008 */ 3 /* ---------------------------------------------------------------- */ 3 4 /** 4 5 * \file ad_bgl_aggrs.h … … 61 62 /* overriding ADIOI_Calc_my_req for the default implementation is specific for 62 63 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, 64 65 int contig_access_count, ADIO_Offset 65 66 min_st_offset, ADIO_Offset *fd_start, mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_close.c
r734 r1249 1 1 /* ---------------------------------------------------------------- */ 2 2 /* (C)Copyright IBM Corp. 2007, 2008 */ 3 /* ---------------------------------------------------------------- */ 3 4 /** 4 * \file ad_bgl_ open.c5 * \file ad_bgl_close.c 5 6 * \brief ??? 6 7 */ mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_fcntl.c
r616 r1249 1 1 /* ---------------------------------------------------------------- */ 2 2 /* (C)Copyright IBM Corp. 2007, 2008 */ 3 /* ---------------------------------------------------------------- */ 3 4 /** 4 5 * \file ad_bgl_fcntl.c mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_rdcoll.c
r968 r1249 23 23 #endif 24 24 25 #ifdef USE_DBG_LOGGING 26 #define RDCOLL_DEBUG 1 27 #endif 28 29 25 30 /* prototypes of functions used for collective reads only. */ 26 31 static void ADIOI_Read_and_exch(ADIO_File fd, void *buf, MPI_Datatype … … 28 33 int myrank, ADIOI_Access 29 34 *others_req, ADIO_Offset *offset_list, 30 int *len_list, int contig_access_count,35 ADIO_Offset *len_list, int contig_access_count, 31 36 ADIO_Offset 32 37 min_st_offset, ADIO_Offset fd_size, … … 34 39 int *buf_idx, int *error_code); 35 40 static void ADIOI_R_Exchange_data(ADIO_File fd, void *buf, ADIOI_Flatlist_node 36 *flat_buf, ADIO_Offset *offset_list, int41 *flat_buf, ADIO_Offset *offset_list, ADIO_Offset 37 42 *len_list, int *send_size, int *recv_size, 38 43 int *count, int *start_pos, … … 48 53 MPI_Aint buftype_extent, int *buf_idx); 49 54 static void ADIOI_R_Exchange_data_alltoallv(ADIO_File fd, void *buf, ADIOI_Flatlist_node 50 *flat_buf, ADIO_Offset *offset_list, int55 *flat_buf, ADIO_Offset *offset_list, ADIO_Offset 51 56 *len_list, int *send_size, int *recv_size, 52 57 int *count, int *start_pos, … … 63 68 static void ADIOI_Fill_user_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 64 69 *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, 67 72 MPI_Request *requests, MPI_Status *statuses, 68 73 int *recd_from_proc, int nprocs, … … 75 80 extern void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype 76 81 datatype, int file_ptr_type, ADIO_Offset 77 offset, ADIO_Offset **offset_list_ptr, int82 offset, ADIO_Offset **offset_list_ptr, ADIO_Offset 78 83 **len_list_ptr, ADIO_Offset *start_offset_ptr, 79 84 ADIO_Offset *end_offset_ptr, int … … 107 112 ADIO_Offset *bgl_offsets0 = NULL, *bgl_offsets = NULL; 108 113 int ii; 109 int *len_list = NULL, *buf_idx = NULL; 110 114 ADIO_Offset *len_list = NULL; 115 int *buf_idx = NULL; 116 /* 111 117 double io_time = 0., all_time, max_all_time; 112 118 double tstep1, max_tstep1; … … 118 124 double tstep4, max_tstep4; 119 125 double sum_sz; 120 126 */ 121 127 #if BGL_PROFILE 122 128 BGLMPIO_T_CIO_RESET( 0, r ) … … 158 164 #endif 159 165 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], 162 169 len_list[i]); 163 }*/ 170 } 171 #endif 164 172 165 173 /* each process communicates its start and end offsets to other … … 224 232 if (buftype_is_contig && filetype_is_contig) { 225 233 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; 227 235 ADIO_ReadContig(fd, buf, count, datatype, ADIO_EXPLICIT_OFFSET, 228 236 off, status, error_code); … … 384 392 } 385 393 386 #if 0387 void ADIOI_Calc_my_off_len(ADIO_File fd, int bufcount, MPI_Datatype388 datatype, int file_ptr_type, ADIO_Offset389 offset, ADIO_Offset **offset_list_ptr, int390 **len_list_ptr, ADIO_Offset *start_offset_ptr,391 ADIO_Offset *end_offset_ptr, int392 *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 and405 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_extent473 + 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 again561 */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 #endif579 580 394 static void ADIOI_Read_and_exch(ADIO_File fd, void *buf, MPI_Datatype 581 395 datatype, int nprocs, 582 396 int myrank, ADIOI_Access 583 397 *others_req, ADIO_Offset *offset_list, 584 int *len_list, int contig_access_count, ADIO_Offset398 ADIO_Offset *len_list, int contig_access_count, ADIO_Offset 585 399 min_st_offset, ADIO_Offset fd_size, 586 400 ADIO_Offset *fd_start, ADIO_Offset *fd_end, … … 597 411 at least another 8Mbytes of temp space is unacceptable. */ 598 412 599 int i, j, m, size,ntimes, max_ntimes, buftype_is_contig;413 int i, j, m, ntimes, max_ntimes, buftype_is_contig; 600 414 ADIO_Offset st_loc=-1, end_loc=-1, off, done, real_off, req_off; 601 415 char *read_buf = NULL, *tmp_buf; 602 416 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; 605 421 MPI_Status status; 606 422 ADIOI_Flatlist_node *flat_buf=NULL; 607 423 MPI_Aint buftype_extent; 608 424 int coll_bufsize; 609 425 #ifdef RDCOLL_DEBUG 610 426 int iii; 611 427 #endif 612 428 *error_code = MPI_SUCCESS; /* changed below if error */ 613 429 /* only I/O errors are currently reported */ … … 741 557 MPE_Log_event(13, 0, "start computation"); 742 558 #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); 744 560 real_off = off - for_curr_iter; 745 561 real_size = size + for_curr_iter; … … 749 565 750 566 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 752 570 if (others_req[i].count) { 753 571 start_pos[i] = curr_offlen_ptr[i]; … … 772 590 if (req_off < real_off + real_size) { 773 591 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)); 774 593 MPI_Address(read_buf+req_off-real_off, 775 594 &(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 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); 782 601 if ((j+1 < others_req[i].count) && 783 602 (others_req[i].offsets[j+1] < … … 785 604 /* this is the case illustrated in the 786 605 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]); 790 608 /* max because it must cover requests 791 609 from different processes */ … … 808 626 #endif 809 627 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, 811 630 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 817 636 818 637 if (*error_code != MPI_SUCCESS) return; … … 852 671 if (for_next_iter) { 853 672 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)); 854 675 memcpy(tmp_buf, read_buf+real_size-for_next_iter, for_next_iter); 855 676 ADIOI_Free(read_buf); … … 905 726 906 727 static void ADIOI_R_Exchange_data(ADIO_File fd, void *buf, ADIOI_Flatlist_node 907 *flat_buf, ADIO_Offset *offset_list, int728 *flat_buf, ADIO_Offset *offset_list, ADIO_Offset 908 729 *len_list, int *send_size, int *recv_size, 909 730 int *count, int *start_pos, int *partial_send, … … 943 764 j = 0; 944 765 for (i=0; i < nprocs; i++) 945 if (recv_size[i]) { 766 if (recv_size[i]) { 946 767 MPI_Irecv(((char *) buf) + buf_idx[i], recv_size[i], 947 768 MPI_BYTE, i, myrank+i+100*iter, fd->comm, requests+j); … … 963 784 myrank+i+100*iter, fd->comm, requests+j); 964 785 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 967 790 } 968 791 } … … 1009 832 if (!buftype_is_contig) 1010 833 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, 1012 835 requests, statuses, recd_from_proc, 1013 836 nprocs, contig_access_count, … … 1029 852 } 1030 853 854 static 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 */ 1031 867 1032 868 #define ADIOI_BUF_INCR \ … … 1043 879 } \ 1044 880 user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 1045 n_buftypes*buftype_extent; \881 (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 1046 882 flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 1047 883 } \ … … 1055 891 while (size) { \ 1056 892 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); \ 1057 895 memcpy(((char *) buf) + user_buf_idx, \ 1058 896 &(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*/ \ 1060 898 user_buf_idx += size_in_buf; \ 1061 899 flat_buf_sz -= size_in_buf; \ … … 1067 905 } \ 1068 906 user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 1069 n_buftypes*buftype_extent; \907 (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 1070 908 flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 1071 909 } \ … … 1077 915 1078 916 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; 1095 921 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; 1098 924 1099 925 /* curr_from_proc[p] = amount of data recd from proc. p that has already … … 1103 929 user_buf_idx = current location in user buffer 1104 930 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)); 1108 934 1109 935 for (i=0; i < nprocs; i++) { … … 1123 949 for (i=0; i<contig_access_count; i++) { 1124 950 off = offset_list[i]; 1125 rem_len = (ADIO_Offset)len_list[i];951 rem_len = len_list[i]; 1126 952 1127 953 /* this request may span the file domains of more than one process */ … … 1143 969 if (curr_from_proc[p]+len > done_from_proc[p]) { 1144 970 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 - 1146 972 done_from_proc[p], recv_size[p]-recv_buf_idx[p]); 1147 973 buf_incr = done_from_proc[p] - curr_from_proc[p]; 1148 974 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)); 1150 977 curr_from_proc[p] = done_from_proc[p] + size; 1151 978 ADIOI_BUF_COPY 1152 979 } 1153 980 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; 1157 985 ADIOI_BUF_COPY 1158 986 } 1159 987 } 1160 988 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; 1163 992 ADIOI_BUF_INCR 1164 993 } 1165 994 } 1166 995 else { 1167 buf_incr = (int)len;996 buf_incr = len; 1168 997 ADIOI_BUF_INCR 1169 998 } … … 1182 1011 static void ADIOI_R_Exchange_data_alltoallv( 1183 1012 ADIO_File fd, void *buf, ADIOI_Flatlist_node 1184 *flat_buf, ADIO_Offset *offset_list, int1013 *flat_buf, ADIO_Offset *offset_list, ADIO_Offset 1185 1014 *len_list, int *send_size, int *recv_size, 1186 1015 int *count, int *start_pos, int *partial_send, … … 1195 1024 int i, j, k=0, tmp=0, nprocs_recv, nprocs_send; 1196 1025 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; 1200 1028 int rtail, stail; 1201 1029 char *sbuf_ptr, *from_ptr; … … 1241 1069 sbuf_ptr = all_send_buf + sdispls[i]; 1242 1070 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 ] ); 1244 1073 len = others_req[i].lens[ start_pos[i]+j ] ; 1245 1074 memcpy( sbuf_ptr, from_ptr, len ); … … 1250 1079 } 1251 1080 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 ); 1268 1095 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" ); 1272 1099 } 1273 1100 #endif … … 1280 1107 1281 1108 #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" ); 1285 1112 #endif 1286 1113 … … 1289 1116 if (!buftype_is_contig) 1290 1117 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, 1292 1119 requests, statuses, /* never used inside */ 1293 1120 recd_from_proc, mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_read.c
r616 r1249 22 22 ADIO_Offset offset, ADIO_Status *status, int *error_code) 23 23 { 24 int err=-1, datatype_size, len; 24 int err=-1, datatype_size; 25 ADIO_Offset len; 25 26 static char myname[] = "ADIOI_BGL_READCONTIG"; 26 27 … … 36 37 37 38 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 */ 39 41 40 42 #if BGL_PROFILE … … 49 51 else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 50 52 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); 52 54 if (bglmpio_timing2) bglmpio_prof_cr[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 53 55 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); … … 65 67 else ADIOI_READ_LOCK(fd, offset, SEEK_SET, len); 66 68 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); 68 70 if (bglmpio_timing2) bglmpio_prof_cr[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 69 71 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); … … 80 82 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 81 83 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); 83 85 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 84 86 fd->fp_sys_posn = offset + err; … … 92 94 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 93 95 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); 95 97 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 96 98 fd->fp_ind += err; … … 121 123 122 124 125 void 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. */ 123 131 124 132 #define ADIOI_BUFFERED_READ \ … … 126 134 if (req_off >= readbuf_off + readbuf_len) { \ 127 135 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));\ 129 137 lseek(fd->fd_sys, readbuf_off, SEEK_SET);\ 130 138 if (!(fd->atomicity)) ADIOI_READ_LOCK(fd, readbuf_off, SEEK_SET, readbuf_len);\ … … 134 142 } \ 135 143 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));\ 136 145 partial_read = (int) (readbuf_off + readbuf_len - req_off); \ 137 146 tmp_buf = (char *) ADIOI_Malloc(partial_read); \ … … 142 151 ADIOI_Free(tmp_buf); \ 143 152 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, \ 145 154 end_offset-readbuf_off+1)); \ 146 155 lseek(fd->fd_sys, readbuf_off+partial_read, SEEK_SET);\ … … 150 159 if (err == -1) err_flag = 1; \ 151 160 } \ 161 ADIOI_Assert(req_len == (size_t)req_len); \ 152 162 memcpy((char *)buf + userbuf_off, readbuf+req_off-readbuf_off, req_len); \ 153 163 } 154 164 155 165 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, int159 *error_code)160 {161 /* offset is in units of etype relative to the filetype. */162 166 163 167 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; 167 174 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; 169 176 MPI_Aint filetype_extent, buftype_extent; 170 177 int buf_count, buftype_is_contig, filetype_is_contig; 171 ADIO_Offset userbuf_off ;178 ADIO_Offset userbuf_off, req_len, sum; 172 179 ADIO_Offset off, req_off, disp, end_offset=0, readbuf_off, start_off; 173 180 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; 177 184 static char myname[] = "ADIOI_BGL_READSTRIDED"; 178 185 … … 208 215 etype_size = fd->etype_size; 209 216 217 ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count)); 210 218 bufsize = buftype_size * count; 211 219 … … 227 235 228 236 off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind : 229 fd->disp + etype_size * offset;237 fd->disp + (ADIO_Offset)etype_size * offset; 230 238 231 239 start_off = off; … … 233 241 readbuf_off = off; 234 242 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)); 236 244 237 245 /* if atomicity is true, lock (exclusive) the region to be accessed */ … … 246 254 247 255 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 } 255 266 256 267 if (fd->atomicity) … … 282 293 flag = 0; 283 294 while (!flag) { 295 int i; 284 296 n_filetypes++; 285 297 for (i=0; i<flat_file->count; i++) { 286 298 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] 288 300 >= offset) { 289 301 st_index = i; 290 frd_size = (int) (disp + flat_file->indices[i] +291 (ADIO_Offset) n_filetypes*filetype_extent292 + 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; 293 305 flag = 1; 294 306 break; … … 298 310 } 299 311 else { 312 int i; 300 313 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; 303 316 size_in_filetype = etype_in_filetype * etype_size; 304 317 … … 316 329 317 330 /* 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; 319 332 } 320 333 … … 326 339 st_frd_size = frd_size; 327 340 st_n_filetypes = n_filetypes; 328 i = 0;341 i_offset = 0; 329 342 j = st_index; 330 343 off = offset; 331 344 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; 334 347 end_offset = off + frd_size - 1; 335 348 … … 340 353 } 341 354 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); 344 357 } 345 358 … … 351 364 readbuf_off = offset; 352 365 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)); 354 367 355 368 lseek(fd->fd_sys, offset, SEEK_SET); … … 365 378 common case. */ 366 379 367 i = 0;380 i_offset = 0; 368 381 j = st_index; 369 382 off = offset; 370 383 n_filetypes = st_n_filetypes; 371 384 frd_size = ADIOI_MIN(st_frd_size, bufsize); 372 while (i < bufsize) {385 while (i_offset < bufsize) { 373 386 if (frd_size) { 374 387 /* TYPE_UB and TYPE_LB can result in … … 379 392 req_off = off; 380 393 req_len = frd_size; 381 userbuf_off = i ;394 userbuf_off = i_offset; 382 395 ADIOI_BUFFERED_READ 383 396 } 384 i += frd_size;397 i_offset += frd_size; 385 398 386 399 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) 388 401 off += frd_size; 389 402 /* did not reach end of contiguous block in filetype. … … 396 409 } 397 410 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); 400 413 } 401 414 } … … 409 422 410 423 k = num = buf_count = 0; 411 i = (int) (flat_buf->indices[0]);424 i_offset = flat_buf->indices[0]; 412 425 j = st_index; 413 426 off = offset; … … 424 437 req_off = off; 425 438 req_len = size; 426 userbuf_off = i ;439 userbuf_off = i_offset; 427 440 ADIOI_BUFFERED_READ 428 441 } … … 440 453 441 454 off = disp + flat_file->indices[j] + 442 (ADIO_Offset) n_filetypes*filetype_extent;455 n_filetypes*(ADIO_Offset)filetype_extent; 443 456 444 457 new_frd_size = flat_file->blocklens[j]; 445 458 if (size != brd_size) { 446 i += size;459 i_offset += size; 447 460 new_brd_size -= size; 448 461 } … … 454 467 k = (k + 1)%flat_buf->count; 455 468 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) + 457 470 flat_buf->indices[k]); 458 471 new_brd_size = flat_buf->blocklens[k]; … … 462 475 } 463 476 } 477 ADIOI_Assert(((ADIO_Offset)num + size) == (unsigned)(num + size)); 464 478 num += size; 465 479 frd_size = new_frd_size; mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_wrcoll.c
r968 r1249 27 27 datatype, int nprocs, int myrank, ADIOI_Access 28 28 *others_req, ADIO_Offset *offset_list, 29 int *len_list, int contig_access_count, ADIO_Offset29 ADIO_Offset *len_list, int contig_access_count, ADIO_Offset 30 30 min_st_offset, ADIO_Offset fd_size, 31 31 ADIO_Offset *fd_start, ADIO_Offset *fd_end, … … 33 33 static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf, 34 34 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, 36 36 int *recv_size, ADIO_Offset off, int size, 37 37 int *count, int *start_pos, int *partial_recv, … … 50 50 ADIOI_Flatlist_node *flat_buf, 51 51 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, 53 53 ADIO_Offset off, int size, /* 2 */ 54 54 int *count, int *start_pos, int *partial_recv, … … 66 66 static void ADIOI_Fill_send_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 67 67 *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, 69 69 MPI_Request *requests, int *sent_to_proc, 70 70 int nprocs, int myrank, … … 77 77 static void ADIOI_Fill_send_buffer_nosend(ADIO_File fd, void *buf, ADIOI_Flatlist_node 78 78 *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, 80 80 MPI_Request *requests, int *sent_to_proc, 81 81 int nprocs, int myrank, … … 119 119 int ii; 120 120 121 int *buf_idx = NULL, *len_list = NULL; 122 121 int *buf_idx = NULL; 122 ADIO_Offset *len_list = NULL; 123 /* 123 124 double io_time = 0, all_time, max_all_time; 124 125 double tstep1, max_tstep1; … … 130 131 double tstep4, max_tstep4; 131 132 double sum_sz; 132 133 */ 133 134 #if BGL_PROFILE 134 135 BGLMPIO_T_CIO_RESET( 0, w ) … … 377 378 ADIOI_Access 378 379 *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, 382 382 ADIO_Offset *fd_start, ADIO_Offset *fd_end, 383 383 int *buf_idx, int *error_code) … … 392 392 at least another 8Mbytes of temp space is unacceptable. */ 393 393 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; 395 397 ADIO_Offset st_loc=-1, end_loc=-1, off, done, req_off; 396 398 char *write_buf=NULL; … … 529 531 for (i=0; i < nprocs; i++) count[i] = recv_size[i] = 0; 530 532 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); 532 534 533 535 for (i=0; i < nprocs; i++) { … … 553 555 if (req_off < off + size) { 554 556 count[i]++; 557 ADIOI_Assert((((ADIO_Offset)(MPIR_Upint)write_buf)+req_off-off) == (ADIO_Offset)(MPIR_Upint)(write_buf+req_off-off)); 555 558 MPI_Address(write_buf+req_off-off, 556 559 &(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) 561 565 { 562 566 partial_recv[i] = (int) (off + size - req_off); … … 621 625 622 626 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, 624 629 off, &status, error_code); 625 630 if (*error_code != MPI_SUCCESS) return; … … 681 686 static void ADIOI_W_Exchange_data(ADIO_File fd, void *buf, char *write_buf, 682 687 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, 684 689 int *recv_size, ADIO_Offset off, int size, 685 690 int *count, int *start_pos, … … 921 926 } \ 922 927 user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 923 n_buftypes*buftype_extent; \928 (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 924 929 flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 925 930 } \ … … 933 938 while (size) { \ 934 939 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); \ 935 942 memcpy(&(send_buf[p][send_buf_idx[p]]), \ 936 943 ((char *) buf) + user_buf_idx, size_in_buf); \ … … 945 952 } \ 946 953 user_buf_idx = flat_buf->indices[flat_buf_idx] + \ 947 n_buftypes*buftype_extent; \954 (ADIO_Offset)n_buftypes*(ADIO_Offset)buftype_extent; \ 948 955 flat_buf_sz = flat_buf->blocklens[flat_buf_idx]; \ 949 956 } \ … … 954 961 } 955 962 956 957 958 963 static void ADIOI_Fill_send_buffer(ADIO_File fd, void *buf, ADIOI_Flatlist_node 959 964 *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, 961 966 MPI_Request *requests, int *sent_to_proc, 962 967 int nprocs, int myrank, … … 970 975 /* this function is only called if buftype is not contig */ 971 976 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; 974 980 ADIO_Offset off, len, rem_len, user_buf_idx; 975 981 … … 998 1004 for (i=0; i<contig_access_count; i++) { 999 1005 off = offset_list[i]; 1000 rem_len = (ADIO_Offset)len_list[i];1006 rem_len = len_list[i]; 1001 1007 1002 1008 /*this request may span the file domains of more than one process*/ … … 1018 1024 if (curr_to_proc[p]+len > done_to_proc[p]) { 1019 1025 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 - 1021 1027 done_to_proc[p], send_size[p]-send_buf_idx[p]); 1022 1028 buf_incr = done_to_proc[p] - curr_to_proc[p]; 1023 1029 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)); 1025 1033 curr_to_proc[p] = done_to_proc[p] + size; 1026 1034 ADIOI_BUF_COPY 1027 1035 } 1028 1036 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)); 1031 1040 curr_to_proc[p] += size; 1032 1041 ADIOI_BUF_COPY … … 1039 1048 } 1040 1049 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; 1043 1053 ADIOI_BUF_INCR 1044 1054 } 1045 1055 } 1046 1056 else { 1047 buf_incr = (int)len;1057 buf_incr = len; 1048 1058 ADIOI_BUF_INCR 1049 1059 } … … 1184 1194 ADIOI_Flatlist_node *flat_buf, 1185 1195 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, 1187 1197 ADIO_Offset off, int size, /* 2 */ 1188 1198 int *count, int *start_pos, int *partial_recv, … … 1199 1209 int *error_code) 1200 1210 { 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; 1202 1212 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; 1206 1215 int rtail, stail; 1207 1216 char *sbuf_ptr, *to_ptr; … … 1327 1336 sbuf_ptr = all_recv_buf + rdispls[i]; 1328 1337 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 ] ); 1330 1340 len = others_req[i].lens[ start_pos[i]+j ] ; 1331 1341 memcpy( to_ptr, sbuf_ptr, len ); … … 1352 1362 static void ADIOI_Fill_send_buffer_nosend(ADIO_File fd, void *buf, ADIOI_Flatlist_node 1353 1363 *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, 1355 1365 MPI_Request *requests, int *sent_to_proc, 1356 1366 int nprocs, int myrank, … … 1364 1374 /* this function is only called if buftype is not contig */ 1365 1375 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; 1368 1379 ADIO_Offset off, len, rem_len, user_buf_idx; 1369 1380 … … 1392 1403 for (i=0; i<contig_access_count; i++) { 1393 1404 off = offset_list[i]; 1394 rem_len = (ADIO_Offset)len_list[i];1405 rem_len = len_list[i]; 1395 1406 1396 1407 /*this request may span the file domains of more than one process*/ … … 1412 1423 if (curr_to_proc[p]+len > done_to_proc[p]) { 1413 1424 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 - 1415 1426 done_to_proc[p], send_size[p]-send_buf_idx[p]); 1416 1427 buf_incr = done_to_proc[p] - curr_to_proc[p]; 1417 1428 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)); 1419 1432 curr_to_proc[p] = done_to_proc[p] + size; 1420 1433 ADIOI_BUF_COPY 1421 1434 } 1422 1435 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)); 1425 1439 curr_to_proc[p] += size; 1426 1440 ADIOI_BUF_COPY … … 1436 1450 } 1437 1451 else { 1452 ADIOI_Assert((curr_to_proc[p] + len) == (unsigned)((ADIO_Offset)curr_to_proc[p] + len)); 1438 1453 curr_to_proc[p] += (int)len; 1439 buf_incr = (int)len;1454 buf_incr = len; 1440 1455 ADIOI_BUF_INCR 1441 1456 } 1442 1457 } 1443 1458 else { 1444 buf_incr = (int)len;1459 buf_incr = len; 1445 1460 ADIOI_BUF_INCR 1446 1461 } mpich2/trunk/src/mpi/romio/adio/ad_bgl/ad_bgl_write.c
r616 r1249 22 22 ADIO_Offset offset, ADIO_Status *status, int *error_code) 23 23 { 24 int err=-1, datatype_size, len; 24 int err=-1, datatype_size; 25 ADIO_Offset len; 25 26 static char myname[] = "ADIOI_BGL_WRITECONTIG"; 26 27 … … 36 37 37 38 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 */ 39 41 40 42 #if BGL_PROFILE … … 47 49 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 48 50 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); 50 52 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 51 53 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); … … 61 63 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len); 62 64 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); 64 66 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2); 65 67 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); … … 74 76 lseek(fd->fd_sys, offset, SEEK_SET); 75 77 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); 77 79 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 78 80 fd->fp_sys_posn = offset + err; … … 84 86 lseek(fd->fd_sys, fd->fp_ind, SEEK_SET); 85 87 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); 87 89 ADIOI_UNLOCK(fd, offset, SEEK_SET, len); 88 90 fd->fp_ind += err; … … 114 116 115 117 118 void 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. */ 116 124 117 125 … … 124 132 if (err == -1) err_flag = 1; \ 125 133 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));\ 127 135 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \ 128 136 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \ … … 136 144 } \ 137 145 } \ 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));\ 139 148 memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\ 140 149 while (write_sz != req_len) { \ … … 146 155 userbuf_off += write_sz; \ 147 156 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));\ 149 158 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \ 150 159 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \ … … 174 183 if (err == -1) err_flag = 1; \ 175 184 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));\ 177 186 } \ 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));\ 179 189 memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\ 180 190 while (write_sz != req_len) { \ … … 187 197 userbuf_off += write_sz; \ 188 198 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));\ 190 200 write_sz = ADIOI_MIN(req_len, writebuf_len); \ 191 201 memcpy(writebuf, (char *)buf + userbuf_off, write_sz);\ … … 195 205 196 206 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, int200 *error_code)201 {202 /* offset is in units of etype relative to the filetype. */203 207 204 208 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; 208 213 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; 210 215 MPI_Aint filetype_extent, buftype_extent; 211 216 int buf_count, buftype_is_contig, filetype_is_contig; … … 213 218 ADIO_Offset off, req_off, disp, end_offset=0, writebuf_off, start_off; 214 219 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; 217 224 static char myname[] = "ADIOI_BGL_WRITESTRIDED"; 218 225 … … 248 255 etype_size = fd->etype_size; 249 256 257 ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count)); 250 258 bufsize = buftype_size * count; 251 259 … … 273 281 writebuf_off = off; 274 282 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)); 276 284 277 285 /* if atomicity is true, lock the region to be accessed */ … … 280 288 281 289 for (j=0; j<count; j++) 290 { 291 int i; 282 292 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]; 284 294 req_off = off; 285 295 req_len = flat_buf->blocklens[i]; … … 287 297 off += flat_buf->blocklens[i]; 288 298 } 299 } 289 300 290 301 /* write the buffer out finally */ … … 322 333 flag = 0; 323 334 while (!flag) { 335 int i; 324 336 n_filetypes++; 325 337 for (i=0; i<flat_file->count; i++) { 326 338 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] 328 340 >= offset) { 329 341 st_index = i; 330 fwr_size = (int) (disp + flat_file->indices[i] +331 (ADIO_Offset) n_filetypes*filetype_extent332 + 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; 333 345 flag = 1; 334 346 break; … … 338 350 } 339 351 else { 352 int i; 340 353 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; 343 356 size_in_filetype = etype_in_filetype * etype_size; 344 357 … … 356 369 357 370 /* 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; 359 372 } 360 373 … … 366 379 st_fwr_size = fwr_size; 367 380 st_n_filetypes = n_filetypes; 368 i = 0;381 i_offset = 0; 369 382 j = st_index; 370 383 off = offset; 371 384 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; 374 387 end_offset = off + fwr_size - 1; 375 388 … … 380 393 } 381 394 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); 384 397 } 385 398 … … 391 404 writebuf_off = offset; 392 405 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)); 394 407 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); 395 408 lseek(fd->fd_sys, writebuf_off, SEEK_SET); … … 409 422 common case. */ 410 423 411 i = 0;424 i_offset = 0; 412 425 j = st_index; 413 426 off = offset; 414 427 n_filetypes = st_n_filetypes; 415 428 fwr_size = ADIOI_MIN(st_fwr_size, bufsize); 416 while (i < bufsize) {429 while (i_offset < bufsize) { 417 430 if (fwr_size) { 418 431 /* TYPE_UB and TYPE_LB can result in 419 432 fwr_size = 0. save system call in such cases */ 420 433 /* 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);*/ 422 435 423 436 req_off = off; 424 437 req_len = fwr_size; 425 userbuf_off = i ;438 userbuf_off = i_offset; 426 439 ADIOI_BUFFERED_WRITE 427 440 } 428 i += fwr_size;441 i_offset += fwr_size; 429 442 430 443 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) 432 445 off += fwr_size; 433 446 /* did not reach end of contiguous block in filetype. … … 440 453 } 441 454 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); 444 457 } 445 458 } … … 453 466 454 467 k = num = buf_count = 0; 455 i = (int) (flat_buf->indices[0]);468 i_offset = flat_buf->indices[0]; 456 469 j = st_index; 457 470 off = offset; … … 464 477 if (size) { 465 478 /* 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); */ 467 480 468 481 req_off = off; 469 482 req_len = size; 470 userbuf_off = i ;483 userbuf_off = i_offset; 471 484 ADIOI_BUFFERED_WRITE 472 485 } … … 484 497 485 498 off = disp + flat_file->indices[j] + 486 (ADIO_Offset) n_filetypes*filetype_extent;499 n_filetypes*(ADIO_Offset)filetype_extent; 487 500 488 501 new_fwr_size = flat_file->blocklens[j]; 489 502 if (size != bwr_size) { 490 i += size;503 i_offset += size; 491 504 new_bwr_size -= size; 492 505 } … … 498 511 k = (k + 1)%flat_buf->count; 499 512 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]; 502 515 new_bwr_size = flat_buf->blocklens[k]; 503 516 if (size != fwr_size) {