00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "mpioimpl.h"
00010
00011 #ifdef HAVE_WEAK_SYMBOLS
00012
00013 #if defined(HAVE_PRAGMA_WEAK)
00014 #pragma weak MPI_File_preallocate = PMPI_File_preallocate
00015 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
00016 #pragma _HP_SECONDARY_DEF PMPI_File_preallocate MPI_File_preallocate
00017 #elif defined(HAVE_PRAGMA_CRI_DUP)
00018 #pragma _CRI duplicate MPI_File_preallocate as PMPI_File_preallocate
00019
00020 #endif
00021
00022
00023 #define MPIO_BUILD_PROFILING
00024 #include "mpioprof.h"
00025 #endif
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 int MPI_File_preallocate(MPI_File fh, MPI_Offset size)
00037 {
00038 ADIO_Fcntl_t *fcntl_struct;
00039 int error_code, mynod;
00040 #ifndef PRINT_ERR_MSG
00041 static char myname[] = "MPI_FILE_PREALLOCATE";
00042 #endif
00043 MPI_Offset tmp_sz;
00044 #ifdef MPI_hpux
00045 int fl_xmpi;
00046
00047 HPMP_IO_START(fl_xmpi, BLKMPIFILEPREALLOCATE, TRDTBLOCK,
00048 fh, MPI_DATATYPE_NULL, -1);
00049 #endif
00050
00051 #ifdef PRINT_ERR_MSG
00052 if ((fh <= (MPI_File) 0) || (fh->cookie != ADIOI_FILE_COOKIE)) {
00053 FPRINTF(stderr, "MPI_File_preallocate: Invalid file handle\n");
00054 MPI_Abort(MPI_COMM_WORLD, 1);
00055 }
00056 #else
00057 ADIOI_TEST_FILE_HANDLE(fh, myname);
00058 #endif
00059
00060 if (size < 0) {
00061 #ifdef PRINT_ERR_MSG
00062 FPRINTF(stderr, "MPI_File_preallocate: Invalid size argument\n");
00063 MPI_Abort(MPI_COMM_WORLD, 1);
00064 #else
00065 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_SIZE_ARG,
00066 myname, (char *) 0, (char *) 0);
00067 return ADIOI_Error(fh, error_code, myname);
00068 #endif
00069 }
00070
00071 tmp_sz = size;
00072 MPI_Bcast(&tmp_sz, 1, ADIO_OFFSET, 0, fh->comm);
00073
00074 if (tmp_sz != size) {
00075 #ifdef PRINT_ERR_MSG
00076 FPRINTF(stderr, "MPI_File_preallocate: size argument must be the same on all processes\n");
00077 MPI_Abort(MPI_COMM_WORLD, 1);
00078 #else
00079 error_code = MPIR_Err_setmsg(MPI_ERR_ARG, MPIR_ERR_SIZE_ARG_NOT_SAME,
00080 myname, (char *) 0, (char *) 0);
00081 return ADIOI_Error(fh, error_code, myname);
00082 #endif
00083 }
00084
00085 if (size == 0) return MPI_SUCCESS;
00086
00087 MPI_Comm_rank(fh->comm, &mynod);
00088 if (!mynod) {
00089 fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
00090 fcntl_struct->diskspace = size;
00091 ADIO_Fcntl(fh, ADIO_FCNTL_SET_DISKSPACE, fcntl_struct, &error_code);
00092 ADIOI_Free(fcntl_struct);
00093 }
00094 MPI_Barrier(fh->comm);
00095
00096 #ifdef MPI_hpux
00097 HPMP_IO_END(fl_xmpi, fh, MPI_DATATYPE_NULL, -1);
00098 #endif
00099 if (!mynod) return error_code;
00100 else return MPI_SUCCESS;
00101 }