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_ordered_begin = PMPI_File_write_ordered_begin
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_write_ordered_begin MPI_File_write_ordered_begin
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_write_ordered_begin as PMPI_File_write_ordered_begin
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 int MPI_File_write_ordered_begin(MPI_File mpi_fh, void *buf, int count,
00040 MPI_Datatype datatype)
00041 {
00042 int error_code, datatype_size, nprocs, myrank, incr;
00043 int source, dest;
00044 static char myname[] = "MPI_FILE_WRITE_ORDERED_BEGIN";
00045 ADIO_Offset shared_fp;
00046 ADIO_File fh;
00047
00048 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00049
00050 fh = MPIO_File_resolve(mpi_fh);
00051
00052
00053 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00054 MPIO_CHECK_COUNT(fh, count, myname, error_code);
00055 MPIO_CHECK_DATATYPE(fh, datatype, myname, error_code);
00056
00057 if (fh->split_coll_count)
00058 {
00059 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00060 myname, __LINE__, MPI_ERR_IO,
00061 "**iosplitcoll", 0);
00062 error_code = MPIO_Err_return_file(fh, error_code);
00063 goto fn_exit;
00064 }
00065
00066
00067 fh->split_coll_count = 1;
00068
00069 MPI_Type_size(datatype, &datatype_size);
00070
00071 MPIO_CHECK_INTEGRAL_ETYPE(fh, count, datatype_size, myname, error_code);
00072 MPIO_CHECK_FS_SUPPORTS_SHARED(fh, myname, error_code);
00073 MPIO_CHECK_COUNT_SIZE(fh, count, datatype_size, myname, error_code);
00074
00075
00076 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00077
00078 MPI_Comm_size(fh->comm, &nprocs);
00079 MPI_Comm_rank(fh->comm, &myrank);
00080
00081 incr = (count*datatype_size)/fh->etype_size;
00082
00083 source = myrank - 1;
00084 dest = myrank + 1;
00085 if (source < 0) source = MPI_PROC_NULL;
00086 if (dest >= nprocs) dest = MPI_PROC_NULL;
00087 MPI_Recv(NULL, 0, MPI_BYTE, source, 0, fh->comm, MPI_STATUS_IGNORE);
00088
00089 ADIO_Get_shared_fp(fh, incr, &shared_fp, &error_code);
00090
00091 if (error_code != MPI_SUCCESS)
00092 {
00093 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_FATAL,
00094 myname, __LINE__, MPI_ERR_INTERN,
00095 "**iosharedfailed", 0);
00096 error_code = MPIO_Err_return_file(fh, error_code);
00097 goto fn_exit;
00098 }
00099
00100
00101 MPI_Send(NULL, 0, MPI_BYTE, dest, 0, fh->comm);
00102
00103 ADIO_WriteStridedColl(fh, buf, count, datatype, ADIO_EXPLICIT_OFFSET,
00104 shared_fp, &fh->split_status, &error_code);
00105
00106
00107 if (error_code != MPI_SUCCESS)
00108 error_code = MPIO_Err_return_file(fh, error_code);
00109
00110
00111 fn_exit:
00112 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00113
00114
00115 return error_code;
00116 }