This source file includes following definitions.
- ADIOI_GEN_WriteContig
1
2
3
4
5
6
7
8
9 #include "adio.h"
10 #include <unistd.h>
11
12 #ifdef AGGREGATION_PROFILE
13 #include "mpe.h"
14 #endif
15
16 #ifdef ROMIO_GPFS
17 #include "adio/ad_gpfs/ad_gpfs_tuning.h"
18 #endif
19
20 #ifdef HAVE_LIMITS_H
21 #include <limits.h>
22 #endif
23
24
25 void ADIOI_GEN_WriteContig(ADIO_File fd, const void *buf, int count,
26 MPI_Datatype datatype, int file_ptr_type,
27 ADIO_Offset offset, ADIO_Status *status,
28 int *error_code)
29 {
30 ssize_t err = -1;
31 MPI_Count datatype_size;
32 ADIO_Offset len, bytes_xfered=0;
33 size_t wr_count;
34 static char myname[] = "ADIOI_GEN_WRITECONTIG";
35 #ifdef ROMIO_GPFS
36 double io_time=0;
37 #endif
38 char * p;
39
40 #ifdef AGGREGATION_PROFILE
41 MPE_Log_event (5036, 0, NULL);
42 #endif
43
44 MPI_Type_size_x(datatype, &datatype_size);
45 len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
46
47 #ifdef ROMIO_GPFS
48 io_time = MPI_Wtime();
49 if (gpfsmpio_timing) {
50 gpfsmpio_prof_cw[ GPFSMPIO_CIO_DATA_SIZE ] += len;
51 }
52 #endif
53
54 if (file_ptr_type == ADIO_INDIVIDUAL) {
55 offset = fd->fp_ind;
56 }
57
58 p = (char *)buf;
59 while (bytes_xfered < len) {
60 #ifdef ADIOI_MPE_LOGGING
61 MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
62 #endif
63 wr_count = len - bytes_xfered;
64
65 if (wr_count > INT_MAX)
66 wr_count = INT_MAX;
67
68 #ifdef ROMIO_GPFS
69 if (gpfsmpio_devnullio)
70 err = pwrite(fd->null_fd, p, wr_count, offset+bytes_xfered);
71 else
72 #endif
73 err = pwrite(fd->fd_sys, p, wr_count, offset+bytes_xfered);
74
75 if (err == -1) {
76 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
77 MPIR_ERR_RECOVERABLE,
78 myname, __LINE__,
79 MPI_ERR_IO, "**io",
80 "**io %s", strerror(errno));
81 fd->fp_sys_posn = -1;
82 return;
83 }
84
85 #ifdef ADIOI_MPE_LOGGING
86 MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
87 #endif
88 bytes_xfered += err;
89 p += err;
90 }
91
92 #ifdef ROMIO_GPFS
93 if (gpfsmpio_timing) gpfsmpio_prof_cw[ GPFSMPIO_CIO_T_POSI_RW ] += (MPI_Wtime() - io_time);
94 #endif
95 fd->fp_sys_posn = offset + bytes_xfered;
96
97 if (file_ptr_type == ADIO_INDIVIDUAL) {
98 fd->fp_ind += bytes_xfered;
99 }
100
101 #ifdef ROMIO_GPFS
102 if (gpfsmpio_timing) gpfsmpio_prof_cw[ GPFSMPIO_CIO_T_MPIO_RW ] += (MPI_Wtime() - io_time);
103 #endif
104
105 #ifdef HAVE_STATUS_SET_BYTES
106
107 if (err != -1 && status) MPIR_Status_set_bytes(status, datatype, bytes_xfered);
108 #endif
109
110 *error_code = MPI_SUCCESS;
111 #ifdef AGGREGATION_PROFILE
112 MPE_Log_event (5037, 0, NULL);
113 #endif
114 }