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_shared = PMPI_File_iwrite_shared
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_iwrite_shared MPI_File_iwrite_shared
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_iwrite_shared as PMPI_File_iwrite_shared
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_shared(MPI_File mpi_fh, void *buf, int count,
00045 MPI_Datatype datatype, MPIO_Request *request)
00046 {
00047 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00048 ADIO_File fh;
00049 int datatype_size, incr;
00050 ADIO_Status status;
00051 ADIO_Offset off, shared_fp;
00052 static char myname[] = "MPI_FILE_IWRITE_SHARED";
00053
00054 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00055
00056 fh = MPIO_File_resolve(mpi_fh);
00057
00058
00059 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00060 MPIO_CHECK_COUNT(fh, count, myname, error_code);
00061 MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
00062
00063
00064 MPI_Type_size(datatype, &datatype_size);
00065
00066
00067 MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
00068 MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
00069 MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
00070
00071
00072 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00073 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00074
00075 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00076
00077 incr = (count*datatype_size)/fh->etype_size;
00078 ADIO_Get_shared_fp(fh, incr, &shared_fp, &error_code);
00079 if (error_code != MPI_SUCCESS) {
00080
00081 MPIO_Err_return_file(fh, error_code);
00082 }
00083
00084
00085 if (buftype_is_contig && filetype_is_contig) {
00086
00087 bufsize = datatype_size * count;
00088 off = fh->disp + fh->etype_size * shared_fp;
00089 if (!(fh->atomicity))
00090 ADIO_IwriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00091 off, request, &error_code);
00092 else {
00093
00094
00095
00096 if (fh->file_system != ADIO_NFS)
00097 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00098
00099 ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00100 off, &status, &error_code);
00101
00102 if (fh->file_system != ADIO_NFS)
00103 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00104
00105 MPIO_Completed_request_create(&fh, bufsize, &error_code, request);
00106 }
00107 }
00108 else
00109 ADIO_IwriteStrided(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00110 shared_fp, request, &error_code);
00111
00112 fn_exit:
00113 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00114
00115 return error_code;
00116 }