1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpioimpl.h"
7
8 #ifdef HAVE_WEAK_SYMBOLS
9
10 #if defined(HAVE_PRAGMA_WEAK)
11 #pragma weak MPI_File_iwrite_all = PMPI_File_iwrite_all
12 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
13 #pragma _HP_SECONDARY_DEF PMPI_File_iwrite_all MPI_File_iwrite_all
14 #elif defined(HAVE_PRAGMA_CRI_DUP)
15 #pragma _CRI duplicate MPI_File_iwrite_all as PMPI_File_iwrite_all
16 /* end of weak pragmas */
17 #elif defined(HAVE_WEAK_ATTRIBUTE)
18 int MPI_File_iwrite_all(MPI_File fh, const void *buf, int count, MPI_Datatype datatype,
19 MPI_Request * request)
20 __attribute__ ((weak, alias("PMPI_File_iwrite_all")));
21 #endif
22
23 /* Include mapping from MPI->PMPI */
24 #define MPIO_BUILD_PROFILING
25 #include "mpioprof.h"
26 #endif
27
28 #ifdef HAVE_MPI_GREQUEST
29 #include "mpiu_greq.h"
30 #endif
31
32 /*@
33 MPI_File_iwrite_all - Nonblocking collective write using individual file pointer
34
35 Input Parameters:
36 . fh - file handle (handle)
37 . buf - initial address of buffer (choice)
38 . count - number of elements in buffer (nonnegative integer)
39 . datatype - datatype of each buffer element (handle)
40
41 Output Parameters:
42 . request - request object (handle)
43
44 .N fortran
45 @*/
MPI_File_iwrite_all(MPI_File fh,ROMIO_CONST void * buf,int count,MPI_Datatype datatype,MPI_Request * request)46 int MPI_File_iwrite_all(MPI_File fh, ROMIO_CONST void *buf, int count,
47 MPI_Datatype datatype, MPI_Request * request)
48 {
49 int error_code;
50 static char myname[] = "MPI_FILE_IWRITE_ALL";
51 #ifdef MPI_hpux
52 int fl_xmpi;
53
54 HPMP_IO_START(fl_xmpi, BLKMPIFILEIWRITEALL, TRDTBLOCK, fh, datatype, count);
55 #endif /* MPI_hpux */
56
57 error_code = MPIOI_File_iwrite_all(fh, (MPI_Offset) 0,
58 ADIO_INDIVIDUAL, buf, count, datatype, myname, request);
59
60 #ifdef MPI_hpux
61 HPMP_IO_END(fl_xmpi, fh, datatype, count);
62 #endif /* MPI_hpux */
63
64 return error_code;
65 }
66
67 /* Note: MPIOI_File_iwrite_all also used by MPI_File_iwrite_at_all */
68 /* prevent multiple definitions of this routine */
69 #ifdef MPIO_BUILD_PROFILING
MPIOI_File_iwrite_all(MPI_File fh,MPI_Offset offset,int file_ptr_type,const void * buf,int count,MPI_Datatype datatype,char * myname,MPI_Request * request)70 int MPIOI_File_iwrite_all(MPI_File fh,
71 MPI_Offset offset,
72 int file_ptr_type,
73 const void *buf,
74 int count, MPI_Datatype datatype, char *myname, MPI_Request * request)
75 {
76 int error_code;
77 MPI_Count datatype_size;
78 ADIO_File adio_fh;
79 void *e32buf = NULL;
80 const void *xbuf = NULL;
81
82 ROMIO_THREAD_CS_ENTER();
83
84 adio_fh = MPIO_File_resolve(fh);
85
86 /* --BEGIN ERROR HANDLING-- */
87 MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
88 MPIO_CHECK_COUNT(adio_fh, count, myname, error_code);
89 MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
90
91 if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) {
92 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
93 myname, __LINE__, MPI_ERR_ARG, "**iobadoffset", 0);
94 error_code = MPIO_Err_return_file(adio_fh, error_code);
95 goto fn_exit;
96 }
97 /* --END ERROR HANDLING-- */
98
99 MPI_Type_size_x(datatype, &datatype_size);
100
101 /* --BEGIN ERROR HANDLING-- */
102 MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
103 MPIO_CHECK_WRITABLE(adio_fh, myname, error_code);
104 MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
105 MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
106 /* --END ERROR HANDLING-- */
107
108 xbuf = buf;
109 if (adio_fh->is_external32) {
110 error_code = MPIU_external32_buffer_setup(buf, count, datatype, &e32buf);
111 if (error_code != MPI_SUCCESS)
112 goto fn_exit;
113
114 xbuf = e32buf;
115 }
116
117 ADIO_IwriteStridedColl(adio_fh, xbuf, count, datatype, file_ptr_type,
118 offset, request, &error_code);
119
120 /* --BEGIN ERROR HANDLING-- */
121 if (error_code != MPI_SUCCESS)
122 error_code = MPIO_Err_return_file(adio_fh, error_code);
123 /* --END ERROR HANDLING-- */
124
125 fn_exit:
126 if (e32buf != NULL)
127 ADIOI_Free(e32buf);
128 ROMIO_THREAD_CS_EXIT();
129
130 return error_code;
131 }
132 #endif
133