root/ompi/mpi/c/comm_connect.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_Comm_connect

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2006-2015 Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2008      University of Houston.  All rights reserved.
  15  * Copyright (c) 2013      Los Alamos National Security, LLC. All rights
  16  *                         reserved.
  17  * Copyright (c) 2015      Intel, Inc. All rights reserved.
  18  * Copyright (c) 2015      Research Organization for Information Science
  19  *                         and Technology (RIST). All rights reserved.
  20  * $COPYRIGHT$
  21  *
  22  * Additional copyrights may follow
  23  *
  24  * $HEADER$
  25  */
  26 #include "ompi_config.h"
  27 #include <stdio.h>
  28 
  29 #include "opal/util/show_help.h"
  30 
  31 #include "ompi/mpi/c/bindings.h"
  32 #include "ompi/runtime/params.h"
  33 #include "ompi/runtime/mpiruntime.h"
  34 #include "ompi/communicator/communicator.h"
  35 #include "ompi/errhandler/errhandler.h"
  36 #include "ompi/info/info.h"
  37 #include "ompi/dpm/dpm.h"
  38 #include "ompi/memchecker.h"
  39 
  40 #if OMPI_BUILD_MPI_PROFILING
  41 #if OPAL_HAVE_WEAK_SYMBOLS
  42 #pragma weak MPI_Comm_connect = PMPI_Comm_connect
  43 #endif
  44 #define MPI_Comm_connect PMPI_Comm_connect
  45 #endif
  46 
  47 static const char FUNC_NAME[] = "MPI_Comm_connect";
  48 
  49 
  50 int MPI_Comm_connect(const char *port_name, MPI_Info info, int root,
  51                      MPI_Comm comm, MPI_Comm *newcomm)
  52 {
  53     int rank, rc;
  54     bool send_first=true;   /* yes, we are the active part in this game */
  55     ompi_communicator_t *newcomp=MPI_COMM_NULL;
  56 
  57     MEMCHECKER(
  58         memchecker_comm(comm);
  59     );
  60 
  61     if ( MPI_PARAM_CHECK ) {
  62         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  63 
  64         if (ompi_comm_invalid (comm)) {
  65             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
  66                                           FUNC_NAME);
  67         }
  68         if ( OMPI_COMM_IS_INTER(comm)) {
  69             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COMM,
  70                                           FUNC_NAME);
  71         }
  72         if ( (0 > root) || (ompi_comm_size(comm) <= root) ) {
  73             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
  74                                           FUNC_NAME);
  75         }
  76         if ( NULL == newcomm ) {
  77             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
  78                                           FUNC_NAME);
  79         }
  80         if (NULL == info || ompi_info_is_freed(info)) {
  81           return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO,
  82                                         FUNC_NAME);
  83         }
  84     }
  85 
  86     rank = ompi_comm_rank ( comm );
  87     if ( MPI_PARAM_CHECK ) {
  88         if ( rank == root ) {
  89             if ( NULL == port_name )
  90                 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
  91                                               FUNC_NAME);
  92         }
  93     }
  94 
  95     if (!ompi_mpi_dynamics_is_enabled(FUNC_NAME)) {
  96         return OMPI_ERRHANDLER_INVOKE(comm, OMPI_ERR_NOT_SUPPORTED, FUNC_NAME);
  97     }
  98 
  99     /* parse info object. No prefedined values for this function in MPI-2,
 100      * so lets ignore it for the moment.
 101      *
 102      * if ( rank == root && MPI_INFO_NULL != info ) {
 103      * }
 104      */
 105 
 106     OPAL_CR_ENTER_LIBRARY();
 107 
 108     if ( rank == root ) {
 109         rc = ompi_dpm_connect_accept (comm, root, port_name, send_first,
 110                                       &newcomp);
 111     }
 112     else {
 113         rc = ompi_dpm_connect_accept (comm, root, NULL, send_first,
 114                                       &newcomp);
 115     }
 116 
 117     OPAL_CR_EXIT_LIBRARY();
 118 
 119     if (OPAL_ERR_NOT_SUPPORTED == rc) {
 120         opal_show_help("help-mpi-api.txt",
 121                        "MPI function not supported",
 122                        true,
 123                        FUNC_NAME,
 124                        "Underlying runtime environment does not support accept/connect functionality");
 125     }
 126 
 127     *newcomm = newcomp;
 128     OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
 129 }

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