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_preallocate = PMPI_File_preallocate
00014 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00015 #pragma _HP_SECONDARY_DEF PMPI_File_preallocate MPI_File_preallocate
00016 #elif defined(HAVE_PRAGMA_CRI_DUP)
00017 #pragma _CRI duplicate MPI_File_preallocate as PMPI_File_preallocate
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 int MPI_File_preallocate(MPI_File mpi_fh, MPI_Offset size)
00036 {
00037 ADIO_Fcntl_t *fcntl_struct;
00038 int error_code=0, mynod=0;
00039 ADIO_File fh;
00040 static char myname[] = "MPI_FILE_PREALLOCATE";
00041 MPI_Offset tmp_sz;
00042 #ifdef MPI_hpux
00043 int fl_xmpi;
00044
00045 HPMP_IO_START(fl_xmpi, BLKMPIFILEPREALLOCATE, TRDTBLOCK,
00046 fh, MPI_DATATYPE_NULL, -1);
00047 #endif
00048
00049 MPIU_THREAD_CS_ENTER(ALLFUNC,);
00050
00051 fh = MPIO_File_resolve(mpi_fh);
00052
00053
00054 MPIO_CHECK_FILE_HANDLE(fh, myname, error_code);
00055
00056 if (size < 0) {
00057 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00058 myname, __LINE__, MPI_ERR_ARG,
00059 "**iobadsize", 0);
00060 error_code = MPIO_Err_return_file(fh, error_code);
00061 goto fn_exit;
00062 }
00063
00064 tmp_sz = size;
00065 MPI_Bcast(&tmp_sz, 1, ADIO_OFFSET, 0, fh->comm);
00066
00067 if (tmp_sz != size) {
00068 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
00069 myname, __LINE__, MPI_ERR_ARG,
00070 "**notsame", 0);
00071 error_code = MPIO_Err_return_file(fh, error_code);
00072 goto fn_exit;
00073 }
00074
00075
00076 if (size == 0) goto fn_exit;
00077
00078 ADIOI_TEST_DEFERRED(fh, myname, &error_code);
00079
00080 MPI_Comm_rank(fh->comm, &mynod);
00081 if (!mynod) {
00082 fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
00083 fcntl_struct->diskspace = size;
00084 ADIO_Fcntl(fh, ADIO_FCNTL_SET_DISKSPACE, fcntl_struct, &error_code);
00085 ADIOI_Free(fcntl_struct);
00086
00087 if (error_code != MPI_SUCCESS)
00088 error_code = MPIO_Err_return_file(fh, error_code);
00089
00090 }
00091 MPI_Barrier(fh->comm);
00092
00093 #ifdef MPI_hpux
00094 HPMP_IO_END(fl_xmpi, fh, MPI_DATATYPE_NULL, -1);
00095 #endif
00096
00097
00098 fn_exit:
00099 MPIU_THREAD_CS_EXIT(ALLFUNC,);
00100
00101
00102 if (!mynod) return error_code;
00103 else return MPI_SUCCESS;
00104 }