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_write_shared = PMPI_File_write_shared
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_write_shared MPI_File_write_shared
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_write_shared as PMPI_File_write_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
00041
00042 int MPI_File_write_shared(MPI_File mpi_fh, void *buf, int count,
00043 MPI_Datatype datatype, MPI_Status *status)
00044 {
00045 int error_code, bufsize, buftype_is_contig, filetype_is_contig;
00046 static char myname[] = "MPI_FILE_READ_SHARED";
00047 int datatype_size, incr;
00048 ADIO_Offset off, shared_fp;
00049 ADIO_File fh;
00050
00051 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00052
00053 fh = MPIO_File_resolve(mpi_fh);
00054
00055
00056 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00057 MPIO_CHECK_COUNT(fh, count, myname, error_code);
00058 MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
00059
00060
00061 MPI_Type_size(datatype, &datatype_size);
00062
00063
00064 MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
00065
00066
00067 if (count*datatype_size == 0) {
00068 #ifdef HAVE_STATUS_SET_BYTES
00069 MPIR_Status_set_bytes(status, datatype, 0);
00070 #endif
00071 error_code = MPI_SUCCESS;
00072 goto fn_exit;
00073 }
00074
00075
00076 MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
00077 MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
00078
00079
00080 ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
00081 ADIOI_Datatype_iscontig(fh->filetype, &filetype_is_contig);
00082
00083 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00084
00085 incr = (count*datatype_size)/fh->etype_size;
00086
00087 ADIO_Get_shared_fp(fh, incr, &shared_fp, &error_code);
00088
00089 if (error_code != MPI_SUCCESS)
00090 {
00091 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL,
00092 myname, __LINE__, MPI_ERR_INTERN,
00093 "**iosharedfailed", 0);
00094 error_code = MPIO_Err_return_file(fh, error_code);
00095 goto fn_exit;
00096 }
00097
00098
00099 if (buftype_is_contig && filetype_is_contig)
00100 {
00101
00102 bufsize = datatype_size * count;
00103 off = fh->disp + fh->etype_size * shared_fp;
00104
00105
00106
00107
00108
00109 if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
00110 ADIOI_WRITE_LOCK(fh, off, SEEK_SET, bufsize);
00111
00112 ADIO_WriteContig(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00113 off, status, &error_code);
00114
00115 if ((fh->atomicity) && (fh->file_system != ADIO_NFS))
00116 ADIOI_UNLOCK(fh, off, SEEK_SET, bufsize);
00117 }
00118 else
00119 {
00120 ADIO_WriteStrided(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00121 shared_fp, status, &error_code);
00122
00123 }
00124
00125
00126 if (error_code != MPI_SUCCESS)
00127 error_code = MPIO_Err_return_file(fh, error_code);
00128
00129
00130 fn_exit:
00131 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00132 return error_code;
00133 }