00001
00002
00003
00009
00010
00011
00012
00013
00014
00015 #include "ad_bgl.h"
00016 #include "adio_extern.h"
00017
00018 #include "ad_bgl_tuning.h"
00019
00020 #ifdef AGGREGATION_PROFILE
00021 #include "mpe.h"
00022 #endif
00023
00024 void ADIOI_BGL_WriteContig(ADIO_File fd, void *buf, int count,
00025 MPI_Datatype datatype, int file_ptr_type,
00026 ADIO_Offset offset, ADIO_Status *status, int *error_code)
00027 {
00028 int err=-1, datatype_size;
00029 ADIO_Offset len;
00030 static char myname[] = "ADIOI_BGL_WRITECONTIG";
00031 #ifdef AGGREGATION_PROFILE
00032 MPE_Log_event (5036, 0, NULL);
00033 #endif
00034 #if BGL_PROFILE
00035
00036 double io_time, io_time2;
00037
00038 if (bglmpio_timing) {
00039 io_time = MPI_Wtime();
00040 bglmpio_prof_cw[ BGLMPIO_CIO_DATA_SIZE ] += len;
00041 }
00042 #endif
00043
00044 MPI_Type_size(datatype, &datatype_size);
00045 len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
00046 ADIOI_Assert(len == (unsigned int) len);
00047
00048 #if BGL_PROFILE
00049
00050 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00051 if (bglmpio_timing2) io_time2 = MPI_Wtime();
00052 if (fd->fp_sys_posn != offset)
00053 lseek(fd->fd_sys, offset, SEEK_SET);
00054 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_SEEK ] += (MPI_Wtime() - io_time2);
00055 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
00056 if (bglmpio_timing2) io_time2 = MPI_Wtime();
00057 err = write(fd->fd_sys, buf, (unsigned int)len);
00058 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2);
00059 ADIOI_UNLOCK(fd, offset, SEEK_SET, len);
00060 fd->fp_sys_posn = offset + err;
00061
00062 }
00063 else {
00064 offset = fd->fp_ind;
00065 if (bglmpio_timing2) io_time2 = MPI_Wtime();
00066 if (fd->fp_sys_posn != fd->fp_ind)
00067 lseek(fd->fd_sys, fd->fp_ind, SEEK_SET);
00068 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_SEEK ] += (MPI_Wtime() - io_time2);
00069 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
00070 if (bglmpio_timing2) io_time2 = MPI_Wtime();
00071 err = write(fd->fd_sys, buf, (unsigned int)len);
00072 if (bglmpio_timing2) bglmpio_prof_cw[ BGLMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time2);
00073 ADIOI_UNLOCK(fd, offset, SEEK_SET, len);
00074 fd->fp_ind += err;
00075 fd->fp_sys_posn = fd->fp_ind;
00076 }
00077
00078 #else
00079
00080 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00081 if (fd->fp_sys_posn != offset)
00082 lseek(fd->fd_sys, offset, SEEK_SET);
00083 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
00084 err = write(fd->fd_sys, buf, (unsigned int)len);
00085 ADIOI_UNLOCK(fd, offset, SEEK_SET, len);
00086 fd->fp_sys_posn = offset + err;
00087
00088 }
00089 else {
00090 offset = fd->fp_ind;
00091 if (fd->fp_sys_posn != fd->fp_ind)
00092 lseek(fd->fd_sys, fd->fp_ind, SEEK_SET);
00093 ADIOI_WRITE_LOCK(fd, offset, SEEK_SET, len);
00094 err = write(fd->fd_sys, buf, (unsigned int)len);
00095 ADIOI_UNLOCK(fd, offset, SEEK_SET, len);
00096 fd->fp_ind += err;
00097 fd->fp_sys_posn = fd->fp_ind;
00098 }
00099
00100 #endif
00101
00102 #if BGL_PROFILE
00103 if (bglmpio_timing) bglmpio_prof_cw[ BGLMPIO_CIO_T_MPIO_RW ] += (MPI_Wtime() - io_time);
00104 #endif
00105
00106
00107 if (err == -1) {
00108 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00109 myname, __LINE__, MPI_ERR_IO,
00110 "**io",
00111 "**io %s", strerror(errno));
00112 return;
00113 }
00114
00115
00116 #ifdef HAVE_STATUS_SET_BYTES
00117 MPIR_Status_set_bytes(status, datatype, err);
00118 #endif
00119
00120 *error_code = MPI_SUCCESS;
00121 #ifdef AGGREGATION_PROFILE
00122 MPE_Log_event (5037, 0, NULL);
00123 #endif
00124 }
00125
00126
00127 #define ADIOI_BUFFERED_WRITE \
00128 { \
00129 if (req_off >= writebuf_off + writebuf_len) { \
00130 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00131 err = write(fd->fd_sys, writebuf, writebuf_len); \
00132 if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00133 if (err == -1) err_flag = 1; \
00134 writebuf_off = req_off; \
00135 writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
00136 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00137 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00138 err = read(fd->fd_sys, writebuf, writebuf_len); \
00139 if (err == -1) { \
00140 *error_code = MPIO_Err_create_code(MPI_SUCCESS, \
00141 MPIR_ERR_RECOVERABLE, myname, \
00142 __LINE__, MPI_ERR_IO, \
00143 "**ioRMWrdwr", 0); \
00144 return; \
00145 } \
00146 } \
00147 write_sz = (unsigned) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \
00148 ADIOI_Assert((ADIO_Offset)write_sz == ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off));\
00149 memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\
00150 while (write_sz != req_len) { \
00151 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00152 err = write(fd->fd_sys, writebuf, writebuf_len); \
00153 if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00154 if (err == -1) err_flag = 1; \
00155 req_len -= write_sz; \
00156 userbuf_off += write_sz; \
00157 writebuf_off += writebuf_len; \
00158 writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
00159 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00160 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00161 err = read(fd->fd_sys, writebuf, writebuf_len); \
00162 if (err == -1) { \
00163 *error_code = MPIO_Err_create_code(MPI_SUCCESS, \
00164 MPIR_ERR_RECOVERABLE, myname, \
00165 __LINE__, MPI_ERR_IO, \
00166 "**ioRMWrdwr", 0); \
00167 return; \
00168 } \
00169 write_sz = ADIOI_MIN(req_len, writebuf_len); \
00170 memcpy(writebuf, (char *)buf + userbuf_off, write_sz);\
00171 } \
00172 }
00173
00174
00175
00176
00177 #define ADIOI_BUFFERED_WRITE_WITHOUT_READ \
00178 { \
00179 if (req_off >= writebuf_off + writebuf_len) { \
00180 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00181 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00182 err = write(fd->fd_sys, writebuf, writebuf_len); \
00183 if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00184 if (err == -1) err_flag = 1; \
00185 writebuf_off = req_off; \
00186 writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
00187 } \
00188 write_sz = (unsigned) (ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off)); \
00189 ADIOI_Assert((ADIO_Offset)write_sz == ADIOI_MIN(req_len, writebuf_off + writebuf_len - req_off));\
00190 memcpy(writebuf+req_off-writebuf_off, (char *)buf +userbuf_off, write_sz);\
00191 while (write_sz != req_len) { \
00192 lseek(fd->fd_sys, writebuf_off, SEEK_SET); \
00193 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00194 err = write(fd->fd_sys, writebuf, writebuf_len); \
00195 if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len); \
00196 if (err == -1) err_flag = 1; \
00197 req_len -= write_sz; \
00198 userbuf_off += write_sz; \
00199 writebuf_off += writebuf_len; \
00200 writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));\
00201 write_sz = ADIOI_MIN(req_len, writebuf_len); \
00202 memcpy(writebuf, (char *)buf + userbuf_off, write_sz);\
00203 } \
00204 }
00205
00206
00207
00208 void ADIOI_BGL_WriteStrided(ADIO_File fd, void *buf, int count,
00209 MPI_Datatype datatype, int file_ptr_type,
00210 ADIO_Offset offset, ADIO_Status *status, int
00211 *error_code)
00212 {
00213
00214
00215
00216
00217 ADIOI_Flatlist_node *flat_buf, *flat_file;
00218 ADIO_Offset i_offset, sum, size_in_filetype;
00219 int i, j, k, err=-1, st_index=0;
00220 int n_etypes_in_filetype;
00221 ADIO_Offset num, size, n_filetypes, etype_in_filetype, st_n_filetypes;
00222 ADIO_Offset abs_off_in_filetype=0;
00223 int filetype_size, etype_size, buftype_size;
00224 MPI_Aint filetype_extent, buftype_extent;
00225 int buf_count, buftype_is_contig, filetype_is_contig;
00226 ADIO_Offset userbuf_off;
00227 ADIO_Offset off, req_off, disp, end_offset=0, writebuf_off, start_off;
00228 char *writebuf, *value;
00229 unsigned bufsize, writebuf_len, max_bufsize, write_sz;
00230 int err_flag=0, info_flag;
00231 ADIO_Offset new_bwr_size, new_fwr_size, st_fwr_size, fwr_size=0, bwr_size, req_len;
00232 static char myname[] = "ADIOI_BGL_WRITESTRIDED";
00233
00234 if (fd->hints->ds_write == ADIOI_HINT_DISABLE) {
00235
00236
00237
00238
00239 ADIOI_GEN_WriteStrided_naive(fd,
00240 buf,
00241 count,
00242 datatype,
00243 file_ptr_type,
00244 offset,
00245 status,
00246 error_code);
00247 return;
00248 }
00249
00250
00251 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00252 ADIOI_Datatype_iscontig(fd->filetype, &filetype_is_contig);
00253
00254 MPI_Type_size(fd->filetype, &filetype_size);
00255 if ( ! filetype_size ) {
00256 *error_code = MPI_SUCCESS;
00257 return;
00258 }
00259
00260 MPI_Type_extent(fd->filetype, &filetype_extent);
00261 MPI_Type_size(datatype, &buftype_size);
00262 MPI_Type_extent(datatype, &buftype_extent);
00263 etype_size = fd->etype_size;
00264
00265 ADIOI_Assert((buftype_size * count) == ((ADIO_Offset)(unsigned)buftype_size * (ADIO_Offset)count));
00266 bufsize = buftype_size * count;
00267
00268
00269
00270 value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
00271 ADIOI_Info_get(fd->info, "ind_wr_buffer_size", MPI_MAX_INFO_VAL, value,
00272 &info_flag);
00273 max_bufsize = atoi(value);
00274 ADIOI_Free(value);
00275
00276 if (!buftype_is_contig && filetype_is_contig) {
00277
00278
00279
00280 ADIOI_Flatten_datatype(datatype);
00281 flat_buf = ADIOI_Flatlist;
00282 while (flat_buf->type != datatype) flat_buf = flat_buf->next;
00283
00284 off = (file_ptr_type == ADIO_INDIVIDUAL) ? fd->fp_ind :
00285 fd->disp + etype_size * offset;
00286
00287 start_off = off;
00288 end_offset = off + bufsize - 1;
00289 writebuf_off = off;
00290 writebuf = (char *) ADIOI_Malloc(max_bufsize);
00291 writebuf_len = (unsigned) (ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
00292
00293
00294 if (fd->atomicity)
00295 ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
00296
00297 for (j=0; j<count; j++)
00298 {
00299 int i;
00300 for (i=0; i<flat_buf->count; i++) {
00301 userbuf_off = (ADIO_Offset)j*(ADIO_Offset)buftype_extent + flat_buf->indices[i];
00302 req_off = off;
00303 req_len = flat_buf->blocklens[i];
00304 ADIOI_BUFFERED_WRITE_WITHOUT_READ
00305 off += flat_buf->blocklens[i];
00306 }
00307 }
00308
00309
00310 lseek(fd->fd_sys, writebuf_off, SEEK_SET);
00311 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
00312 err = write(fd->fd_sys, writebuf, writebuf_len);
00313 if (!(fd->atomicity)) ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
00314 if (err == -1) err_flag = 1;
00315
00316 if (fd->atomicity)
00317 ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
00318
00319 ADIOI_Free(writebuf);
00320
00321 if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
00322 if (err_flag) {
00323 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00324 MPIR_ERR_RECOVERABLE, myname,
00325 __LINE__, MPI_ERR_IO, "**io",
00326 "**io %s", strerror(errno));
00327 }
00328 else *error_code = MPI_SUCCESS;
00329 }
00330
00331 else {
00332
00333
00334 flat_file = ADIOI_Flatlist;
00335 while (flat_file->type != fd->filetype) flat_file = flat_file->next;
00336 disp = fd->disp;
00337
00338 if (file_ptr_type == ADIO_INDIVIDUAL) {
00339
00340 offset = fd->fp_ind - disp;
00341 n_filetypes = (offset - flat_file->indices[0]) / filetype_extent;
00342 offset -= (ADIO_Offset)n_filetypes * filetype_extent;
00343
00344
00345
00346 for (i=0; i<flat_file->count; i++) {
00347 ADIO_Offset dist;
00348 if (flat_file->blocklens[i] == 0) continue;
00349 dist = flat_file->indices[i] + flat_file->blocklens[i] - offset;
00350
00351 if (dist == 0) {
00352 i++;
00353 offset = flat_file->indices[i];
00354 fwr_size = flat_file->blocklens[i];
00355 break;
00356 }
00357 if (dist > 0) {
00358 fwr_size = dist;
00359 break;
00360 }
00361 }
00362 st_index = i;
00363 offset += disp + (ADIO_Offset)n_filetypes*filetype_extent;
00364 }
00365 else {
00366 int i;
00367 n_etypes_in_filetype = filetype_size/etype_size;
00368 n_filetypes = offset / n_etypes_in_filetype;
00369 etype_in_filetype = offset % n_etypes_in_filetype;
00370 size_in_filetype = etype_in_filetype * etype_size;
00371
00372 sum = 0;
00373 for (i=0; i<flat_file->count; i++) {
00374 sum += flat_file->blocklens[i];
00375 if (sum > size_in_filetype) {
00376 st_index = i;
00377 fwr_size = sum - size_in_filetype;
00378 abs_off_in_filetype = flat_file->indices[i] +
00379 size_in_filetype - (sum - flat_file->blocklens[i]);
00380 break;
00381 }
00382 }
00383
00384
00385 offset = disp + (ADIO_Offset) n_filetypes*filetype_extent +
00386 abs_off_in_filetype;
00387 }
00388
00389 start_off = offset;
00390
00391
00392
00393 if (buftype_is_contig && bufsize <= fwr_size) {
00394 ADIO_WriteContig(fd, buf, bufsize, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
00395 offset, status, error_code);
00396
00397 if (file_ptr_type == ADIO_INDIVIDUAL) {
00398
00399
00400 fd->fp_ind = offset + bufsize;
00401 if (bufsize == fwr_size) {
00402 do {
00403 st_index++;
00404 if (st_index == flat_file->count) {
00405 st_index = 0;
00406 n_filetypes++;
00407 }
00408 } while (flat_file->blocklens[st_index] == 0);
00409 fd->fp_ind = disp + flat_file->indices[st_index]
00410 + (ADIO_Offset)n_filetypes*filetype_extent;
00411 }
00412 }
00413 fd->fp_sys_posn = -1;
00414 #ifdef HAVE_STATUS_SET_BYTES
00415 MPIR_Status_set_bytes(status, datatype, bufsize);
00416 #endif
00417 return;
00418 }
00419
00420
00421
00422
00423 st_fwr_size = fwr_size;
00424 st_n_filetypes = n_filetypes;
00425 i_offset = 0;
00426 j = st_index;
00427 off = offset;
00428 fwr_size = ADIOI_MIN(st_fwr_size, bufsize);
00429 while (i_offset < bufsize) {
00430 i_offset += fwr_size;
00431 end_offset = off + fwr_size - 1;
00432
00433 j = (j+1) % flat_file->count;
00434 n_filetypes += (j == 0) ? 1 : 0;
00435 while (flat_file->blocklens[j]==0) {
00436 j = (j+1) % flat_file->count;
00437 n_filetypes += (j == 0) ? 1 : 0;
00438 }
00439
00440 off = disp + flat_file->indices[j] +
00441 n_filetypes*(ADIO_Offset)filetype_extent;
00442 fwr_size = ADIOI_MIN(flat_file->blocklens[j], bufsize-i_offset);
00443 }
00444
00445
00446 if (fd->atomicity)
00447 ADIOI_WRITE_LOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
00448
00449
00450 writebuf_off = offset;
00451 writebuf = (char *) ADIOI_Malloc(max_bufsize);
00452 writebuf_len = (unsigned)(ADIOI_MIN(max_bufsize,end_offset-writebuf_off+1));
00453 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
00454 lseek(fd->fd_sys, writebuf_off, SEEK_SET);
00455 err = read(fd->fd_sys, writebuf, writebuf_len);
00456 if (err == -1) {
00457 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00458 MPIR_ERR_RECOVERABLE,
00459 myname, __LINE__,
00460 MPI_ERR_IO,
00461 "ADIOI_BGL_WriteStrided: ROMIO tries to optimize this access by doing a read-modify-write, but is unable to read the file. Please give the file read permission and open it with MPI_MODE_RDWR.", 0);
00462 return;
00463 }
00464
00465 if (buftype_is_contig && !filetype_is_contig) {
00466
00467
00468
00469
00470 i_offset = 0;
00471 j = st_index;
00472 off = offset;
00473 n_filetypes = st_n_filetypes;
00474 fwr_size = ADIOI_MIN(st_fwr_size, bufsize);
00475 while (i_offset < bufsize) {
00476 if (fwr_size) {
00477
00478
00479
00480
00481
00482 req_off = off;
00483 req_len = fwr_size;
00484 userbuf_off = i_offset;
00485 ADIOI_BUFFERED_WRITE
00486 }
00487 i_offset += fwr_size;
00488
00489 if (off + fwr_size < disp + flat_file->indices[j] +
00490 flat_file->blocklens[j] + n_filetypes*(ADIO_Offset)filetype_extent)
00491 off += fwr_size;
00492
00493
00494 else {
00495 j = (j+1) % flat_file->count;
00496 n_filetypes += (j == 0) ? 1 : 0;
00497 while (flat_file->blocklens[j]==0) {
00498 j = (j+1) % flat_file->count;
00499 n_filetypes += (j == 0) ? 1 : 0;
00500 }
00501 off = disp + flat_file->indices[j] +
00502 n_filetypes*(ADIO_Offset)filetype_extent;
00503 fwr_size = ADIOI_MIN(flat_file->blocklens[j],
00504 bufsize-i_offset);
00505 }
00506 }
00507 }
00508 else {
00509
00510
00511 ADIOI_Flatten_datatype(datatype);
00512 flat_buf = ADIOI_Flatlist;
00513 while (flat_buf->type != datatype) flat_buf = flat_buf->next;
00514
00515 k = num = buf_count = 0;
00516 i_offset = flat_buf->indices[0];
00517 j = st_index;
00518 off = offset;
00519 n_filetypes = st_n_filetypes;
00520 fwr_size = st_fwr_size;
00521 bwr_size = flat_buf->blocklens[0];
00522
00523 while (num < bufsize) {
00524 size = ADIOI_MIN(fwr_size, bwr_size);
00525 if (size) {
00526
00527
00528
00529 req_off = off;
00530 req_len = size;
00531 userbuf_off = i_offset;
00532 ADIOI_BUFFERED_WRITE
00533 }
00534
00535 new_fwr_size = fwr_size;
00536 new_bwr_size = bwr_size;
00537
00538 if (size == fwr_size) {
00539
00540 j = (j+1) % flat_file->count;
00541 n_filetypes += (j == 0) ? 1 : 0;
00542 while (flat_file->blocklens[j]==0) {
00543 j = (j+1) % flat_file->count;
00544 n_filetypes += (j == 0) ? 1 : 0;
00545 }
00546
00547 off = disp + flat_file->indices[j] +
00548 n_filetypes*(ADIO_Offset)filetype_extent;
00549
00550 new_fwr_size = flat_file->blocklens[j];
00551 if (size != bwr_size) {
00552 i_offset += size;
00553 new_bwr_size -= size;
00554 }
00555 }
00556
00557 if (size == bwr_size) {
00558
00559
00560 k = (k + 1)%flat_buf->count;
00561 buf_count++;
00562 i_offset = (ADIO_Offset)buftype_extent*(ADIO_Offset)(buf_count/flat_buf->count) +
00563 flat_buf->indices[k];
00564 new_bwr_size = flat_buf->blocklens[k];
00565 if (size != fwr_size) {
00566 off += size;
00567 new_fwr_size -= size;
00568 }
00569 }
00570 num += size;
00571 fwr_size = new_fwr_size;
00572 bwr_size = new_bwr_size;
00573 }
00574 }
00575
00576
00577 lseek(fd->fd_sys, writebuf_off, SEEK_SET);
00578 if (!(fd->atomicity)) ADIOI_WRITE_LOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
00579 err = write(fd->fd_sys, writebuf, writebuf_len);
00580
00581 if (!(fd->atomicity))
00582 ADIOI_UNLOCK(fd, writebuf_off, SEEK_SET, writebuf_len);
00583 else ADIOI_UNLOCK(fd, start_off, SEEK_SET, end_offset-start_off+1);
00584
00585 if (err == -1) err_flag = 1;
00586
00587 ADIOI_Free(writebuf);
00588
00589 if (file_ptr_type == ADIO_INDIVIDUAL) fd->fp_ind = off;
00590 if (err_flag) {
00591 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00592 MPIR_ERR_RECOVERABLE, myname,
00593 __LINE__, MPI_ERR_IO, "**io",
00594 "**io %s", strerror(errno));
00595 }
00596 else *error_code = MPI_SUCCESS;
00597 }
00598
00599 fd->fp_sys_posn = -1;
00600
00601 #ifdef HAVE_STATUS_SET_BYTES
00602 MPIR_Status_set_bytes(status, datatype, bufsize);
00603
00604
00605 #endif
00606
00607 if (!buftype_is_contig) ADIOI_Delete_flattened(datatype);
00608 }