00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009 #include "adio_extern.h"
00010 #include "ad_zoidfs.h"
00011
00012 #include "ad_zoidfs_common.h"
00013
00014
00015
00016 void ADIOI_ZOIDFS_ReadStrided(ADIO_File fd, void *buf, int count,
00017 MPI_Datatype datatype, int file_ptr_type,
00018 ADIO_Offset offset, ADIO_Status *status, int
00019 *error_code)
00020 {
00021
00022 ADIOI_Flatlist_node *flat_buf, *flat_file;
00023 int i, j, k, brd_size, frd_size=0, st_index=0;
00024 int bufsize, sum, n_etypes_in_filetype, size_in_filetype;
00025 int n_filetypes, etype_in_filetype;
00026 ADIO_Offset abs_off_in_filetype=0;
00027 int filetype_size, etype_size, buftype_size;
00028 MPI_Aint filetype_extent, buftype_extent;
00029 int buf_count, buftype_is_contig, filetype_is_contig;
00030 ADIO_Offset off, disp, start_off, initial_off;
00031 int flag, st_frd_size, st_n_filetypes;
00032
00033 size_t mem_list_count, file_list_count;
00034 void ** mem_offsets;
00035 uint64_t *file_offsets;
00036 size_t *mem_lengths;
00037 uint64_t *file_lengths;
00038 int total_blks_to_read;
00039
00040 int max_mem_list, max_file_list;
00041
00042 int b_blks_read;
00043 int f_data_read;
00044 int size_read=0, n_read_lists, extra_blks;
00045
00046 int end_brd_size, end_frd_size;
00047 int start_k, start_j, new_file_read, new_buffer_read;
00048 int start_mem_offset;
00049 ADIOI_ZOIDFS_object * zoidfs_obj_ptr;
00050 int err_flag=0;
00051 MPI_Offset total_bytes_read = 0;
00052 static char myname[] = "ADIOI_ZOIDFS_ReadStrided";
00053
00054
00055
00056 #define MAX_ARRAY_SIZE 64
00057
00058 *error_code = MPI_SUCCESS;
00059
00060 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00061 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00062
00063
00064
00065
00066 if (!filetype_is_contig) {
00067 flat_file = ADIOI_Flatlist;
00068 while (flat_file->type != fd->filetype) flat_file = flat_file->next;
00069 if (flat_file->count == 1 && !buftype_is_contig)
00070 filetype_is_contig = 1;
00071 }
00072
00073 MPI_Type_size(fd->filetype, &filetype_size);
00074 if ( ! filetype_size ) {
00075 *error_code = MPI_SUCCESS;
00076 return;
00077 }
00078
00079 MPI_Type_extent(fd->filetype, &filetype_extent);
00080 MPI_Type_size(datatype, &buftype_size);
00081 MPI_Type_extent(datatype, &buftype_extent);
00082 etype_size = fd->etype_size;
00083
00084 bufsize = buftype_size * count;
00085
00086 zoidfs_obj_ptr = (ADIOI_ZOIDFS_object *)fd->fs_ptr;
00087
00088 if (!buftype_is_contig && filetype_is_contig) {
00089
00090
00091 uint64_t file_offsets;
00092 uint64_t file_lengths;
00093
00094 ADIOI_Flatten_datatype(datatype);
00095 flat_buf = ADIOI_Flatlist;
00096 while (flat_buf->type != datatype) flat_buf = flat_buf->next;
00097
00098 off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :
00099 fd->disp + etype_size * offset;
00100
00101 file_list_count = 1;
00102 file_offsets = off;
00103 file_lengths = 0;
00104 total_blks_to_read = count*flat_buf->count;
00105 b_blks_read = 0;
00106
00107
00108 if (total_blks_to_read > MAX_ARRAY_SIZE)
00109 mem_list_count = MAX_ARRAY_SIZE;
00110 else mem_list_count = total_blks_to_read;
00111 mem_offsets = (void*)ADIOI_Malloc(mem_list_count*sizeof(void*));
00112 mem_lengths = (size_t*)ADIOI_Malloc(mem_list_count*sizeof(size_t));
00113
00114
00115
00116 j = 0;
00117
00118 while (b_blks_read < total_blks_to_read) {
00119 for (i=0; i<flat_buf->count; i++) {
00120 mem_offsets[b_blks_read % MAX_ARRAY_SIZE] =
00121 buf + j*buftype_extent + flat_buf->indices[i];
00122 mem_lengths[b_blks_read % MAX_ARRAY_SIZE] =
00123 flat_buf->blocklens[i];
00124 file_lengths += flat_buf->blocklens[i];
00125 b_blks_read++;
00126 if (!(b_blks_read % MAX_ARRAY_SIZE) ||
00127 (b_blks_read == total_blks_to_read)) {
00128
00129
00130
00131 if (b_blks_read == total_blks_to_read) {
00132 mem_list_count = total_blks_to_read % MAX_ARRAY_SIZE;
00133
00134 if (!mem_list_count) mem_list_count = MAX_ARRAY_SIZE;
00135 }
00136 #ifdef ADIOI_MPE_LOGGING
00137 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
00138 #endif
00139 NO_STALE(err_flag, fd, zoidfs_obj_ptr,
00140 zoidfs_read(zoidfs_obj_ptr,
00141 mem_list_count,
00142 mem_offsets, mem_lengths,
00143 1, &file_offsets, &file_lengths, ZOIDFS_NO_OP_HINT));
00144 #ifdef ADIOI_MPE_LOGGING
00145 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
00146 #endif
00147
00148 if (err_flag != ZFS_OK) {
00149 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00150 MPIR_ERR_RECOVERABLE,
00151 myname, __LINE__,
00152 ADIOI_ZOIDFS_error_convert(err_flag),
00153 "Error in zoidfs_read", 0);
00154 goto error_state;
00155 }
00156 total_bytes_read += file_lengths;
00157
00158
00159
00160
00161 if (err_flag || b_blks_read == total_blks_to_read) break;
00162
00163 file_offsets += file_lengths;
00164 file_lengths = 0;
00165 }
00166 }
00167 j++;
00168 }
00169 ADIOI_Free(mem_offsets);
00170 ADIOI_Free(mem_lengths);
00171
00172 if (file_ptr_type == ADIO_INDIVIDUAL)
00173 fd->fp_ind += total_bytes_read;
00174
00175 fd->fp_sys_posn = -1;
00176
00177 #ifdef HAVE_STATUS_SET_BYTES
00178 MPIR_Status_set_bytes(status, datatype, bufsize);
00179
00180
00181
00182 #endif
00183 ADIOI_Delete_flattened(datatype);
00184
00185 return;
00186 }
00187
00188
00189
00190
00191
00192 flat_file = ADIOI_Flatlist;
00193 while (flat_file->type != fd->filetype) flat_file = flat_file->next;
00194
00195 disp = fd->disp;
00196 initial_off = offset;
00197
00198
00199
00200
00201
00202
00203
00204 if (file_ptr_type == ADIO_INDIVIDUAL) {
00205 offset = fd->fp_ind;
00206 n_filetypes = -1;
00207 flag = 0;
00208 while (!flag) {
00209 n_filetypes++;
00210 for (i=0; i<flat_file->count; i++) {
00211 if (disp + flat_file->indices[i] +
00212 ((ADIO_Offset) n_filetypes)*filetype_extent +
00213 flat_file->blocklens[i] >= offset) {
00214 st_index = i;
00215 frd_size = disp + flat_file->indices[i] +
00216 ((ADIO_Offset) n_filetypes)*filetype_extent
00217 + flat_file->blocklens[i] - offset;
00218 flag = 1;
00219 break;
00220 }
00221 }
00222 }
00223 }
00224 else {
00225 n_etypes_in_filetype = filetype_size/etype_size;
00226 n_filetypes = (int) (offset / n_etypes_in_filetype);
00227 etype_in_filetype = (int) (offset % n_etypes_in_filetype);
00228 size_in_filetype = etype_in_filetype * etype_size;
00229
00230 sum = 0;
00231 for (i=0; i<flat_file->count; i++) {
00232 sum += flat_file->blocklens[i];
00233 if (sum > size_in_filetype) {
00234 st_index = i;
00235 frd_size = sum - size_in_filetype;
00236 abs_off_in_filetype = flat_file->indices[i] +
00237 size_in_filetype - (sum - flat_file->blocklens[i]);
00238 break;
00239 }
00240 }
00241
00242
00243 offset = disp + ((ADIO_Offset) n_filetypes)*filetype_extent +
00244 abs_off_in_filetype;
00245 }
00246
00247 start_off = offset;
00248 st_frd_size = frd_size;
00249 st_n_filetypes = n_filetypes;
00250
00251 if (buftype_is_contig && !filetype_is_contig) {
00252
00253
00254
00255
00256
00257 size_t mem_lengths;
00258 size_t mem_offsets;
00259
00260 i = 0;
00261 j = st_index;
00262 n_filetypes = st_n_filetypes;
00263
00264 mem_list_count = 1;
00265
00266
00267 f_data_read = ADIOI_MIN(st_frd_size, bufsize);
00268 total_blks_to_read = 1;
00269 if (j < (flat_file->count-1)) j++;
00270 else {
00271 j = 0;
00272 n_filetypes++;
00273 }
00274 while (f_data_read < bufsize) {
00275 f_data_read += flat_file->blocklens[j];
00276 total_blks_to_read++;
00277 if (j<(flat_file->count-1)) j++;
00278 else j = 0;
00279 }
00280
00281 j = st_index;
00282 n_filetypes = st_n_filetypes;
00283 n_read_lists = total_blks_to_read/MAX_ARRAY_SIZE;
00284 extra_blks = total_blks_to_read%MAX_ARRAY_SIZE;
00285
00286 mem_offsets = (size_t)buf;
00287 mem_lengths = 0;
00288
00289
00290
00291 if (n_read_lists) {
00292 file_offsets = (int64_t*)ADIOI_Malloc(MAX_ARRAY_SIZE*
00293 sizeof(int64_t));
00294 file_lengths = (uint64_t*)ADIOI_Malloc(MAX_ARRAY_SIZE*
00295 sizeof(uint64_t));
00296 }
00297
00298
00299 else {
00300 file_offsets = (int64_t*)ADIOI_Malloc(extra_blks*
00301 sizeof(int64_t));
00302 file_lengths = (uint64_t*)ADIOI_Malloc(extra_blks*
00303 sizeof(uint64_t));
00304 }
00305
00306
00307 for (i=0; i<n_read_lists; i++) {
00308 file_list_count = MAX_ARRAY_SIZE;
00309 if(!i) {
00310 file_offsets[0] = offset;
00311 file_lengths[0] = st_frd_size;
00312 mem_lengths = st_frd_size;
00313 }
00314 for (k=0; k<MAX_ARRAY_SIZE; k++) {
00315 if (i || k) {
00316 file_offsets[k] = disp +
00317 ((ADIO_Offset)n_filetypes)*filetype_extent
00318 + flat_file->indices[j];
00319 file_lengths[k] = flat_file->blocklens[j];
00320 mem_lengths += file_lengths[k];
00321 }
00322 if (j<(flat_file->count - 1)) j++;
00323 else {
00324 j = 0;
00325 n_filetypes++;
00326 }
00327 }
00328
00329 #ifdef ADIOI_MPE_LOGGING
00330 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
00331 #endif
00332 NO_STALE(err_flag, fd, zoidfs_obj_ptr,
00333 zoidfs_read(zoidfs_obj_ptr,
00334 1, buf, &mem_lengths,
00335 file_list_count,
00336 file_offsets, file_lengths, ZOIDFS_NO_OP_HINT));
00337 #ifdef ADIOI_MPE_LOGGING
00338 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
00339 #endif
00340
00341 if (err_flag != ZFS_OK) {
00342 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00343 MPIR_ERR_RECOVERABLE,
00344 myname, __LINE__,
00345 ADIOI_ZOIDFS_error_convert(err_flag),
00346 "Error in zoidfs_read", 0);
00347 goto error_state;
00348 }
00349
00350 total_bytes_read += mem_lengths;
00351
00352 mem_offsets += mem_lengths;
00353 mem_lengths = 0;
00354 }
00355
00356
00357 if (extra_blks) {
00358 file_list_count = extra_blks;
00359 if(!i) {
00360 file_offsets[0] = offset;
00361 file_lengths[0] = ADIOI_MIN(st_frd_size, bufsize);
00362 }
00363 for (k=0; k<extra_blks; k++) {
00364 if(i || k) {
00365 file_offsets[k] = disp +
00366 ((ADIO_Offset)n_filetypes)*filetype_extent +
00367 flat_file->indices[j];
00368 if (k == (extra_blks - 1)) {
00369 file_lengths[k] = bufsize - mem_lengths
00370 - mem_offsets + (size_t)buf;
00371 }
00372 else file_lengths[k] = flat_file->blocklens[j];
00373 }
00374 mem_lengths += file_lengths[k];
00375 if (j<(flat_file->count - 1)) j++;
00376 else {
00377 j = 0;
00378 n_filetypes++;
00379 }
00380 }
00381 #ifdef ADIOI_MPE_LOGGING
00382 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
00383 #endif
00384 NO_STALE(err_flag, fd, zoidfs_obj_ptr,
00385 zoidfs_read(zoidfs_obj_ptr, 1,
00386 (void **)&mem_offsets,
00387 &mem_lengths,
00388 file_list_count,
00389 file_offsets, file_lengths, ZOIDFS_NO_OP_HINT));
00390 #ifdef ADIOI_MPE_LOGGING
00391 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
00392 #endif
00393
00394 if (err_flag != 0) {
00395 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00396 MPIR_ERR_RECOVERABLE,
00397 myname, __LINE__,
00398 ADIOI_ZOIDFS_error_convert(err_flag),
00399 "Error in zoidfs_read", 0);
00400 goto error_state;
00401 }
00402
00403 total_bytes_read += mem_lengths;
00404 }
00405 }
00406 else {
00407
00408
00409 ADIOI_Flatten_datatype(datatype);
00410 flat_buf = ADIOI_Flatlist;
00411 while (flat_buf->type != datatype) flat_buf = flat_buf->next;
00412
00413 size_read = 0;
00414 n_filetypes = st_n_filetypes;
00415 frd_size = st_frd_size;
00416 brd_size = flat_buf->blocklens[0];
00417 buf_count = 0;
00418 start_mem_offset = 0;
00419 start_k = k = 0;
00420 start_j = st_index;
00421 max_mem_list = 0;
00422 max_file_list = 0;
00423
00424
00425
00426
00427
00428 while (size_read < bufsize) {
00429 k = start_k;
00430 new_buffer_read = 0;
00431 mem_list_count = 0;
00432 while ((mem_list_count < MAX_ARRAY_SIZE) &&
00433 (new_buffer_read < bufsize-size_read)) {
00434
00435
00436
00437
00438
00439 if(mem_list_count) {
00440 if((new_buffer_read + flat_buf->blocklens[k] +
00441 size_read) > bufsize) {
00442 end_brd_size = new_buffer_read +
00443 flat_buf->blocklens[k] - (bufsize - size_read);
00444 new_buffer_read = bufsize - size_read;
00445 }
00446 else {
00447 new_buffer_read += flat_buf->blocklens[k];
00448 end_brd_size = flat_buf->blocklens[k];
00449 }
00450 }
00451 else {
00452 if (brd_size > (bufsize - size_read)) {
00453 new_buffer_read = bufsize - size_read;
00454 brd_size = new_buffer_read;
00455 }
00456 else new_buffer_read = brd_size;
00457 }
00458 mem_list_count++;
00459 k = (k + 1)%flat_buf->count;
00460 }
00461
00462 j = start_j;
00463 new_file_read = 0;
00464 file_list_count = 0;
00465 while ((file_list_count < MAX_ARRAY_SIZE) &&
00466 (new_file_read < new_buffer_read)) {
00467 if(file_list_count) {
00468 if((new_file_read + flat_file->blocklens[j]) >
00469 new_buffer_read) {
00470 end_frd_size = new_buffer_read - new_file_read;
00471 new_file_read = new_buffer_read;
00472 j--;
00473 }
00474 else {
00475 new_file_read += flat_file->blocklens[j];
00476 end_frd_size = flat_file->blocklens[j];
00477 }
00478 }
00479 else {
00480 if (frd_size > new_buffer_read) {
00481 new_file_read = new_buffer_read;
00482 frd_size = new_file_read;
00483 }
00484 else new_file_read = frd_size;
00485 }
00486 file_list_count++;
00487 if (j < (flat_file->count - 1)) j++;
00488 else j = 0;
00489
00490 k = start_k;
00491 if ((new_file_read < new_buffer_read) &&
00492 (file_list_count == MAX_ARRAY_SIZE)) {
00493 new_buffer_read = 0;
00494 mem_list_count = 0;
00495 while (new_buffer_read < new_file_read) {
00496 if(mem_list_count) {
00497 if((new_buffer_read + flat_buf->blocklens[k]) >
00498 new_file_read) {
00499 end_brd_size = new_file_read - new_buffer_read;
00500 new_buffer_read = new_file_read;
00501 k--;
00502 }
00503 else {
00504 new_buffer_read += flat_buf->blocklens[k];
00505 end_brd_size = flat_buf->blocklens[k];
00506 }
00507 }
00508 else {
00509 new_buffer_read = brd_size;
00510 if (brd_size > (bufsize - size_read)) {
00511 new_buffer_read = bufsize - size_read;
00512 brd_size = new_buffer_read;
00513 }
00514 }
00515 mem_list_count++;
00516 k = (k + 1)%flat_buf->count;
00517 }
00518 }
00519
00520 }
00521
00522
00523
00524 k = start_k;
00525 j = start_j;
00526 for (i=0; i<mem_list_count; i++) {
00527 if(i) {
00528 if (i == (mem_list_count - 1)) {
00529 if (flat_buf->blocklens[k] == end_brd_size)
00530 brd_size = flat_buf->blocklens[(k+1)%
00531 flat_buf->count];
00532 else {
00533 brd_size = flat_buf->blocklens[k] - end_brd_size;
00534 k--;
00535 buf_count--;
00536 }
00537 }
00538 }
00539 buf_count++;
00540 k = (k + 1)%flat_buf->count;
00541 }
00542 for (i=0; i<file_list_count; i++) {
00543 if (i) {
00544 if (i == (file_list_count - 1)) {
00545 if (flat_file->blocklens[j] == end_frd_size)
00546 frd_size = flat_file->blocklens[(j+1)%
00547 flat_file->count];
00548 else {
00549 frd_size = flat_file->blocklens[j] - end_frd_size;
00550 j--;
00551 }
00552 }
00553 }
00554 if (j < flat_file->count - 1) j++;
00555 else {
00556 j = 0;
00557 n_filetypes++;
00558 }
00559 }
00560 size_read += new_buffer_read;
00561 start_k = k;
00562 start_j = j;
00563 if (max_mem_list < mem_list_count)
00564 max_mem_list = mem_list_count;
00565 if (max_file_list < file_list_count)
00566 max_file_list = file_list_count;
00567 }
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580 if ( ( (file_list_count == 1) &&
00581 (new_file_read < flat_file->blocklens[0] ) ) ||
00582 ((mem_list_count == 1) &&
00583 (new_buffer_read < flat_buf->blocklens[0]) ) ||
00584 ((file_list_count == MAX_ARRAY_SIZE) &&
00585 (new_file_read < flat_buf->blocklens[0]) ) ||
00586 ( (mem_list_count == MAX_ARRAY_SIZE) &&
00587 (new_buffer_read < flat_file->blocklens[0])) )
00588 {
00589
00590 ADIOI_Delete_flattened(datatype);
00591 ADIOI_GEN_ReadStrided_naive(fd, buf, count, datatype,
00592 file_ptr_type, initial_off, status, error_code);
00593 return;
00594 }
00595
00596 mem_offsets = (void *)ADIOI_Malloc(max_mem_list*sizeof(void *));
00597 mem_lengths = (size_t*)ADIOI_Malloc(max_mem_list*sizeof(size_t));
00598 file_offsets = (uint64_t *)ADIOI_Malloc(max_file_list*sizeof(uint64_t));
00599 file_lengths = (uint64_t *)ADIOI_Malloc(max_file_list*sizeof(uint64_t));
00600
00601 size_read = 0;
00602 n_filetypes = st_n_filetypes;
00603 frd_size = st_frd_size;
00604 brd_size = flat_buf->blocklens[0];
00605 buf_count = 0;
00606 start_mem_offset = 0;
00607 start_k = k = 0;
00608 start_j = st_index;
00609
00610
00611
00612
00613
00614 while (size_read < bufsize) {
00615 k = start_k;
00616 new_buffer_read = 0;
00617 mem_list_count = 0;
00618 while ((mem_list_count < MAX_ARRAY_SIZE) &&
00619 (new_buffer_read < bufsize-size_read)) {
00620
00621
00622
00623
00624
00625 if(mem_list_count) {
00626 if((new_buffer_read + flat_buf->blocklens[k] +
00627 size_read) > bufsize) {
00628 end_brd_size = new_buffer_read +
00629 flat_buf->blocklens[k] - (bufsize - size_read);
00630 new_buffer_read = bufsize - size_read;
00631 }
00632 else {
00633 new_buffer_read += flat_buf->blocklens[k];
00634 end_brd_size = flat_buf->blocklens[k];
00635 }
00636 }
00637 else {
00638 if (brd_size > (bufsize - size_read)) {
00639 new_buffer_read = bufsize - size_read;
00640 brd_size = new_buffer_read;
00641 }
00642 else new_buffer_read = brd_size;
00643 }
00644 mem_list_count++;
00645 k = (k + 1)%flat_buf->count;
00646 }
00647
00648 j = start_j;
00649 new_file_read = 0;
00650 file_list_count = 0;
00651 while ((file_list_count < MAX_ARRAY_SIZE) &&
00652 (new_file_read < new_buffer_read)) {
00653 if(file_list_count) {
00654 if((new_file_read + flat_file->blocklens[j]) >
00655 new_buffer_read) {
00656 end_frd_size = new_buffer_read - new_file_read;
00657 new_file_read = new_buffer_read;
00658 j--;
00659 }
00660 else {
00661 new_file_read += flat_file->blocklens[j];
00662 end_frd_size = flat_file->blocklens[j];
00663 }
00664 }
00665 else {
00666 if (frd_size > new_buffer_read) {
00667 new_file_read = new_buffer_read;
00668 frd_size = new_file_read;
00669 }
00670 else new_file_read = frd_size;
00671 }
00672 file_list_count++;
00673 if (j < (flat_file->count - 1)) j++;
00674 else j = 0;
00675
00676 k = start_k;
00677 if ((new_file_read < new_buffer_read) &&
00678 (file_list_count == MAX_ARRAY_SIZE)) {
00679 new_buffer_read = 0;
00680 mem_list_count = 0;
00681 while (new_buffer_read < new_file_read) {
00682 if(mem_list_count) {
00683 if((new_buffer_read + flat_buf->blocklens[k]) >
00684 new_file_read) {
00685 end_brd_size = new_file_read - new_buffer_read;
00686 new_buffer_read = new_file_read;
00687 k--;
00688 }
00689 else {
00690 new_buffer_read += flat_buf->blocklens[k];
00691 end_brd_size = flat_buf->blocklens[k];
00692 }
00693 }
00694 else {
00695 new_buffer_read = brd_size;
00696 if (brd_size > (bufsize - size_read)) {
00697 new_buffer_read = bufsize - size_read;
00698 brd_size = new_buffer_read;
00699 }
00700 }
00701 mem_list_count++;
00702 k = (k + 1)%flat_buf->count;
00703 }
00704 }
00705
00706 }
00707
00708
00709
00710 k = start_k;
00711 j = start_j;
00712 for (i=0; i<mem_list_count; i++) {
00713 mem_offsets[i] = buf +
00714 buftype_extent* (buf_count/flat_buf->count) +
00715 flat_buf->indices[k];
00716 if(!i) {
00717 mem_lengths[0] = brd_size;
00718 mem_offsets[0] += flat_buf->blocklens[k] - brd_size;
00719 }
00720 else {
00721 if (i == (mem_list_count - 1)) {
00722 mem_lengths[i] = end_brd_size;
00723 if (flat_buf->blocklens[k] == end_brd_size)
00724 brd_size = flat_buf->blocklens[(k+1)%
00725 flat_buf->count];
00726 else {
00727 brd_size = flat_buf->blocklens[k] - end_brd_size;
00728 k--;
00729 buf_count--;
00730 }
00731 }
00732 else {
00733 mem_lengths[i] = flat_buf->blocklens[k];
00734 }
00735 }
00736 buf_count++;
00737 k = (k + 1)%flat_buf->count;
00738 }
00739 for (i=0; i<file_list_count; i++) {
00740 file_offsets[i] = disp + flat_file->indices[j] +
00741 ((ADIO_Offset)n_filetypes) * filetype_extent;
00742 if (!i) {
00743 file_lengths[0] = frd_size;
00744 file_offsets[0] += flat_file->blocklens[j] - frd_size;
00745 }
00746 else {
00747 if (i == (file_list_count - 1)) {
00748 file_lengths[i] = end_frd_size;
00749 if (flat_file->blocklens[j] == end_frd_size)
00750 frd_size = flat_file->blocklens[(j+1)%
00751 flat_file->count];
00752 else {
00753 frd_size = flat_file->blocklens[j] - end_frd_size;
00754 j--;
00755 }
00756 }
00757 else file_lengths[i] = flat_file->blocklens[j];
00758 }
00759 if (j < flat_file->count - 1) j++;
00760 else {
00761 j = 0;
00762 n_filetypes++;
00763 }
00764 }
00765
00766 #ifdef ADIOI_MPE_LOGGING
00767 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
00768 #endif
00769 NO_STALE(err_flag, fd, zoidfs_obj_ptr,
00770 zoidfs_read(zoidfs_obj_ptr,
00771 mem_list_count, mem_offsets, mem_lengths,
00772 file_list_count,
00773 file_offsets, file_lengths, ZOIDFS_NO_OP_HINT));
00774 #ifdef ADIOI_MPE_LOGGING
00775 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
00776 #endif
00777
00778 if (err_flag != ZFS_OK) {
00779 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00780 MPIR_ERR_RECOVERABLE,
00781 myname, __LINE__,
00782 ADIOI_ZOIDFS_error_convert(err_flag),
00783 "Error in zoidfs_read", 0);
00784 }
00785
00786 size_read += new_buffer_read;
00787 total_bytes_read += new_buffer_read;
00788 start_k = k;
00789 start_j = j;
00790 }
00791 ADIOI_Free(mem_offsets);
00792 ADIOI_Free(mem_lengths);
00793 }
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804 if (file_ptr_type == ADIO_INDIVIDUAL) {
00805 fd->fp_ind = file_offsets[file_list_count-1]+
00806 file_lengths[file_list_count-1];
00807 }
00808
00809 ADIOI_Free(file_offsets);
00810 ADIOI_Free(file_lengths);
00811
00812 if (err_flag == 0) *error_code = MPI_SUCCESS;
00813
00814 error_state:
00815 fd->fp_sys_posn = -1;
00816
00817 #ifdef HAVE_STATUS_SET_BYTES
00818 MPIR_Status_set_bytes(status, datatype, bufsize);
00819
00820
00821
00822 #endif
00823
00824 if (!buftype_is_contig) ADIOI_Delete_flattened(datatype);
00825 }
00826