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-2017 Research Organization for Information Science
14 * and Technology (RIST). All rights reserved.
15 * Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 */
22 #include "ompi_config.h"
23 #include <stdio.h>
24
25 #include "ompi/mpi/c/bindings.h"
26 #include "ompi/runtime/params.h"
27 #include "ompi/communicator/communicator.h"
28 #include "ompi/mca/pml/pml.h"
29 #include "ompi/request/request.h"
30 #include "ompi/errhandler/errhandler.h"
31 #include "ompi/memchecker.h"
32
33 #if OMPI_BUILD_MPI_PROFILING
34 #if OPAL_HAVE_WEAK_SYMBOLS
35 #pragma weak MPI_Start = PMPI_Start
36 #endif
37 #define MPI_Start PMPI_Start
38 #endif
39
40 static const char FUNC_NAME[] = "MPI_Start";
41
42
43 int MPI_Start(MPI_Request *request)
44 {
45 int ret = OMPI_SUCCESS;
46
47 MEMCHECKER(
48 memchecker_request(request);
49 );
50
51 if ( MPI_PARAM_CHECK ) {
52 int rc = MPI_SUCCESS;
53 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
54 if (request == NULL) {
55 rc = MPI_ERR_REQUEST;
56 }
57 OMPI_ERRHANDLER_CHECK(rc, MPI_COMM_WORLD, rc, FUNC_NAME);
58 }
59 /**
60 * Per definition of the handling of persistent request in the
61 * MPI standard 3.1 page 78 line 19: we must have the following
62 * sequence CREATE (START COMPLETE)* FREE. The upper level is
63 * responsible for handling any concurency. The PML must handle
64 * this case, as it is the only one knowing if the request can
65 * be reused or not (it is PML completed or not?).
66 */
67
68 switch((*request)->req_type) {
69 case OMPI_REQUEST_PML:
70 case OMPI_REQUEST_COLL:
71 if ( MPI_PARAM_CHECK && !(*request)->req_persistent) {
72 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_REQUEST, FUNC_NAME);
73 }
74 OPAL_CR_ENTER_LIBRARY();
75
76 ret = (*request)->req_start(1, request);
77
78 OPAL_CR_EXIT_LIBRARY();
79 return ret;
80
81 case OMPI_REQUEST_NOOP:
82 /**
83 * We deal with a MPI_PROC_NULL request. If the request is
84 * already active, fall back to the error case in the default.
85 * Otherwise, mark it active so we can correctly handle it in
86 * the wait*.
87 */
88 if( OMPI_REQUEST_INACTIVE == (*request)->req_state ) {
89 (*request)->req_state = OMPI_REQUEST_ACTIVE;
90 return MPI_SUCCESS;
91 }
92
93 default:
94 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_REQUEST, FUNC_NAME);
95 }
96 }
97