00001
00002
00003
00004
00005
00006
00007
00008 #include "mpioimpl.h"
00009
00010 #ifdef HAVE_WEAK_SYMBOLS
00011
00012 #if defined(HAVE_PRAGMA_WEAK)
00013 #pragma weak MPI_File_iwrite = PMPI_File_iwrite
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_iwrite MPI_File_iwrite
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_iwrite as PMPI_File_iwrite
00018
00019 #endif
00020
00021
00022 #define MPIO_BUILD_PROFILING
00023 #include "mpioprof.h"
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifdef HAVE_MPI_GREQUEST
00041 #include "mpiu_greq.h"
00042 #endif
00043
00044 int MPI_File_iwrite(MPI_File mpi_fh, void *buf, int count,
00045 MPI_Datatype datatype, MPI_Request *request)
00046 {
00047 int error_code=MPI_SUCCESS;
00048 static char myname[] = "MPI_FILE_IWRITE";
00049 #ifdef MPI_hpux
00050 int fl_xmpi;
00051
00052 HPMP_IO_START(fl_xmpi, BLKMPIFILEIWRITE, TRDTSYSTEM, mpi_fh, datatype,
00053 count);
00054 #endif
00055
00056 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00057
00058 error_code = MPIOI_File_iwrite(mpi_fh, (MPI_Offset) 0, ADIO_INDIVIDUAL,
00059 buf, count, datatype, myname, request);
00060
00061
00062 if (error_code != MPI_SUCCESS)
00063 error_code = MPIO_Err_return_file(mpi_fh, error_code);
00064
00065
00066 #ifdef MPI_hpux
00067 HPMP_IO_END(fl_xmpi, mpi_fh, datatype, count);
00068 #endif
00069 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00070
00071 return error_code;
00072 }
00073
00074
00075
00076 int MPIOI_File_iwrite(MPI_File mpi_fh,
00077 MPI_Offset offset,
00078 int file_ptr_type,
00079 void *buf,
00080 int count,
00081 MPI_Datatype datatype,
00082 char *myname,
00083 MPI_Request *request)
00084 {
00085 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00086 int datatype_size;
00087 ADIO_Status status;
00088 ADIO_Offset off;
00089 ADIO_File fh;
00090 MPI_Offset nbytes=0;
00091
00092 fh = MPIO_File_resolve(mpi_fh);
00093
00094
00095 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00096 MPIO_CHECK_COUNT(fh, count, myname, error_code);
00097 MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
00098
00099 if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) {
00100 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00101 myname, __LINE__, MPI_ERR_ARG,
00102 "**iobadoffset", 0);
00103 error_code = MPIO_Err_return_file(fh, error_code);
00104 goto fn_exit;
00105 }
00106
00107
00108 MPI_Type_size(datatype, &datatype_size);
00109
00110
00111 MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
00112 MPIO_CHECK_WRITABLE(fh, myname, error_code);
00113 MPIO_CHECK_NOT_SEQUENTIAL_MODE(fh, myname, error_code);
00114 MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
00115
00116
00117 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00118 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00119
00120 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00121
00122 if (buftype_is_contig && filetype_is_contig) {
00123
00124 bufsize = datatype_size * count;
00125 if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
00126 off = fh->disp + fh->etype_size * offset;
00127 }
00128 else {
00129 off = fh->fp_ind;
00130 }
00131
00132 if (!(fh->atomicity)) {
00133 ADIO_IwriteContig(fh, buf, count, datatype, file_ptr_type,
00134 off, request, &error_code);
00135 }
00136 else {
00137
00138
00139 if (ADIO_Feature(fh, ADIO_LOCKS) )
00140 {
00141 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00142 }
00143
00144 ADIO_WriteContig(fh, buf, count, datatype, file_ptr_type, off,
00145 &status, &error_code);
00146
00147 if (ADIO_Feature(fh, ADIO_LOCKS) )
00148 {
00149 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00150 }
00151 if (error_code == MPI_SUCCESS) {
00152 nbytes = count * datatype_size;
00153 }
00154
00155 MPIO_Completed_request_create(&fh, nbytes, &error_code, request);
00156 }
00157 }
00158 else {
00159 ADIO_IwriteStrided(fh, buf, count, datatype, file_ptr_type,
00160 offset, request, &error_code);
00161 }
00162 fn_exit:
00163 return error_code;
00164 }
00165