root/ompi/mca/io/romio321/romio/mpi-io/set_atom.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_set_atomicity

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "mpioimpl.h"
   9 
  10 #ifdef HAVE_WEAK_SYMBOLS
  11 
  12 #if defined(HAVE_PRAGMA_WEAK)
  13 #pragma weak MPI_File_set_atomicity = PMPI_File_set_atomicity
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPI_File_set_atomicity MPI_File_set_atomicity
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPI_File_set_atomicity as PMPI_File_set_atomicity
  18 /* end of weak pragmas */
  19 #elif defined(HAVE_WEAK_ATTRIBUTE)
  20 int MPI_File_set_atomicity(MPI_File fh, int flag) __attribute__((weak,alias("PMPI_File_set_atomicity")));
  21 #endif
  22 
  23 /* Include mapping from MPI->PMPI */
  24 #define MPIO_BUILD_PROFILING
  25 #include "mpioprof.h"
  26 #endif
  27 
  28 /*@
  29     MPI_File_set_atomicity - Sets the atomicity mode
  30 
  31 Input Parameters:
  32 . fh - file handle (handle)
  33 . flag - true to set atomic mode, false to set nonatomic mode (logical)
  34 
  35 .N fortran
  36 @*/
  37 int MPI_File_set_atomicity(MPI_File fh, int flag)
  38 {
  39     int error_code, tmp_flag;
  40     static char myname[] = "MPI_FILE_SET_ATOMICITY";
  41     ADIO_Fcntl_t *fcntl_struct;
  42     ADIO_File adio_fh;
  43 
  44     ROMIO_THREAD_CS_ENTER();
  45 
  46     adio_fh = MPIO_File_resolve(fh);
  47 
  48     /* --BEGIN ERROR HANDLING-- */
  49     MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
  50     /* --END ERROR HANDLING-- */
  51 
  52     ADIOI_TEST_DEFERRED(adio_fh, myname, &error_code);
  53 
  54     if (flag) flag = 1;  /* take care of non-one values! */
  55 
  56 /* check if flag is the same on all processes */
  57     tmp_flag = flag;
  58     MPI_Bcast(&tmp_flag, 1, MPI_INT, 0, adio_fh->comm);
  59 
  60     /* --BEGIN ERROR HANDLING-- */
  61     if (tmp_flag != flag) {
  62         error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
  63                                           myname, __LINE__, MPI_ERR_ARG, 
  64                                           "**notsame", 0);
  65         error_code = MPIO_Err_return_file(adio_fh, error_code);
  66         goto fn_exit;
  67     }
  68     /* --END ERROR HANDLING-- */
  69 
  70     if (adio_fh->atomicity == flag){
  71             error_code = MPI_SUCCESS;
  72             goto fn_exit;
  73     }
  74 
  75 
  76     fcntl_struct = (ADIO_Fcntl_t *) ADIOI_Malloc(sizeof(ADIO_Fcntl_t));
  77     fcntl_struct->atomicity = flag;
  78     ADIO_Fcntl(adio_fh, ADIO_FCNTL_SET_ATOMICITY, fcntl_struct, &error_code);
  79     /* TODO: what do we do with this error code? */
  80 
  81     /* --BEGIN ERROR HANDLING-- */
  82     if (error_code != MPI_SUCCESS)
  83         error_code = MPIO_Err_return_file(adio_fh, error_code);
  84     /* --END ERROR HANDLING-- */
  85 
  86     ADIOI_Free(fcntl_struct);
  87 
  88 fn_exit:
  89     ROMIO_THREAD_CS_EXIT();
  90     return error_code;
  91 }

/* [<][>][^][v][top][bottom][index][help] */