root/ompi/mpi/c/win_allocate.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Win_allocate

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2006      Cisco Systems, Inc.  All rights reserved.
  13  * Copyright (c) 2015      Research Organization for Information Science
  14  *                         and Technology (RIST). All rights reserved.
  15  * Copyright (c) 2017      IBM Corporation. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 #include "ompi_config.h"
  23 
  24 #include <stdio.h>
  25 
  26 #include "ompi/mpi/c/bindings.h"
  27 #include "ompi/runtime/params.h"
  28 #include "ompi/communicator/communicator.h"
  29 #include "ompi/errhandler/errhandler.h"
  30 #include "ompi/info/info.h"
  31 #include "ompi/win/win.h"
  32 #include "ompi/memchecker.h"
  33 
  34 #if OMPI_BUILD_MPI_PROFILING
  35 #if OPAL_HAVE_WEAK_SYMBOLS
  36 #pragma weak MPI_Win_allocate = PMPI_Win_allocate
  37 #endif
  38 #define MPI_Win_allocate PMPI_Win_allocate
  39 #endif
  40 
  41 static const char FUNC_NAME[] = "MPI_Win_allocate";
  42 
  43 
  44 int MPI_Win_allocate(MPI_Aint size, int disp_unit, MPI_Info info,
  45                      MPI_Comm comm, void *baseptr, MPI_Win *win)
  46 {
  47     int ret = MPI_SUCCESS;
  48 
  49     MEMCHECKER(
  50         memchecker_comm(comm);
  51     );
  52     /* argument checking */
  53     if (MPI_PARAM_CHECK) {
  54         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  55 
  56         if (ompi_comm_invalid (comm)) {
  57             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  58                                           FUNC_NAME);
  59 
  60         } else if (NULL == info || ompi_info_is_freed(info)) {
  61             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_INFO,
  62                                           FUNC_NAME);
  63 
  64         } else if (NULL == win) {
  65             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_WIN, FUNC_NAME);
  66         } else if ( size < 0 ) {
  67             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_SIZE, FUNC_NAME);
  68         } else if ( disp_unit <= 0 ) {
  69             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_DISP, FUNC_NAME);
  70         }
  71     }
  72 
  73     /* communicator must be an intracommunicator */
  74     if (OMPI_COMM_IS_INTER(comm)) {
  75         return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COMM, FUNC_NAME);
  76     }
  77 
  78     OPAL_CR_ENTER_LIBRARY();
  79 
  80     /* create window and return */
  81     ret = ompi_win_allocate((size_t)size, disp_unit, &(info->super),
  82                             comm, baseptr, win);
  83     if (OMPI_SUCCESS != ret) {
  84         *win = MPI_WIN_NULL;
  85         OPAL_CR_EXIT_LIBRARY();
  86         return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_WIN, FUNC_NAME);
  87     }
  88 
  89     OPAL_CR_EXIT_LIBRARY();
  90     return MPI_SUCCESS;
  91 }

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