rput.c 5.98 KB
Newer Older
1
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2
3
4
5
6
7
8
9
/*
 *
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpiimpl.h"

10
/* -- Begin Profiling Symbol Block for routine MPI_Rput */
11
#if defined(HAVE_PRAGMA_WEAK)
12
#pragma weak MPI_Rput = PMPI_Rput
13
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
14
#pragma _HP_SECONDARY_DEF PMPI_Rput  MPI_Rput
15
#elif defined(HAVE_PRAGMA_CRI_DUP)
16
#pragma _CRI duplicate MPI_Rput as PMPI_Rput
17
18
19
20
21
22
#endif
/* -- End Profiling Symbol Block */

/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
   the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
23
24
#undef MPI_Rput
#define MPI_Rput PMPI_Rput
25
26
27
28

#endif

#undef FUNCNAME
29
#define FUNCNAME MPI_Rput
30
31

/*@
32
33
34
35
36
37
38
39
40
41
42
43
MPI_Rput - Put data into a memory window on a remote process and return a
request handle for the operation.


'MPI_Rput' is similar to 'MPI_Put,' except that it allocates a
communication request object and associates it with the request handle (the
argument request). The completion of an 'MPI_Rput' operation (i.e., after the
corresponding test or wait) indicates that the sender is now free to update
the locations in the origin buffer. It does not indicate that the data is
available at the target window. If remote completion is required,
'MPI_Win_flush,' 'MPI_Win_flush_all,' 'MPI_Win_unlock,' or 'MPI_Win_unlock_all' can be
used.
44

45
Input Parameters:
46
47
48
49
50
51
52
53
+ origin_addr -initial address of origin buffer (choice)
. origin_count -number of entries in origin buffer (nonnegative integer)
. origin_datatype -datatype of each entry in origin buffer (handle)
. target_rank -rank of target (nonnegative integer)
. target_disp -displacement from start of window to target buffer (nonnegative integer)
. target_count -number of entries in target buffer (nonnegative integer)
. target_datatype -datatype of each entry in target buffer (handle)
- win - window object used for communication (handle)
54

55
Output Parameters:
56
57
58
59
60
61
62
63
64
65
66
67
68
. request -RMA request (handle)

.N ThreadSafe

.N Fortran

.N Errors
.N MPI_SUCCESS
.N MPI_ERR_ARG
.N MPI_ERR_COUNT
.N MPI_ERR_RANK
.N MPI_ERR_TYPE
.N MPI_ERR_WIN
69
70

.seealso: MPI_Put
71
@*/
72
int MPI_Rput(const void *origin_addr, int origin_count, MPI_Datatype
73
74
75
76
            origin_datatype, int target_rank, MPI_Aint target_disp,
            int target_count, MPI_Datatype target_datatype, MPI_Win
            win, MPI_Request *request)
{
77
    static const char FCNAME[] = "MPI_Rput";
78
79
80
    int mpi_errno = MPI_SUCCESS;
    MPID_Win *win_ptr = NULL;
    MPID_Request *request_ptr = NULL;
81
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_RPUT);
82
83
84
85

    MPIR_ERRTEST_INITIALIZED_ORDIE();
    
    MPIU_THREAD_CS_ENTER(ALLFUNC,);
86
    MPID_MPI_RMA_FUNC_ENTER(MPID_STATE_MPI_RPUT);
87
88
89
90
91
92
93
94
95
96

    /* Validate parameters, especially handles needing to be converted */
#   ifdef HAVE_ERROR_CHECKING
    {
        MPID_BEGIN_ERROR_CHECKS;
        {
            MPIR_ERRTEST_WIN(win, mpi_errno);
        }
        MPID_END_ERROR_CHECKS;
    }
97
#   endif /* HAVE_ERROR_CHECKING */
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    
    /* Convert MPI object handles to object pointers */
    MPID_Win_get_ptr( win, win_ptr );

    /* Validate parameters and objects (post conversion) */
#   ifdef HAVE_ERROR_CHECKING
    {
        MPID_BEGIN_ERROR_CHECKS;
        {
            MPID_Comm * comm_ptr;

            /* Validate win_ptr */
            MPID_Win_valid_ptr( win_ptr, mpi_errno );
            if (mpi_errno) goto fn_fail;

            MPIR_ERRTEST_COUNT(origin_count, mpi_errno);
114
            MPIR_ERRTEST_DATATYPE(origin_datatype, "origin_datatype", mpi_errno);
115
            MPIR_ERRTEST_COUNT(target_count, mpi_errno);
116
            MPIR_ERRTEST_DATATYPE(target_datatype, "target_datatype", mpi_errno);
117
            if (win_ptr->create_flavor != MPI_WIN_FLAVOR_DYNAMIC)
118
                MPIR_ERRTEST_DISP(target_disp, mpi_errno);
119
120
121
122
123
124
125

            if (HANDLE_GET_KIND(origin_datatype) != HANDLE_KIND_BUILTIN)
            {
                MPID_Datatype *datatype_ptr = NULL;
                
                MPID_Datatype_get_ptr(origin_datatype, datatype_ptr);
                MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
126
                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
127
                MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
128
                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
129
130
131
132
133
134
135
136
            }

            if (HANDLE_GET_KIND(target_datatype) != HANDLE_KIND_BUILTIN)
            {
                MPID_Datatype *datatype_ptr = NULL;
                
                MPID_Datatype_get_ptr(target_datatype, datatype_ptr);
                MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
137
                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
138
                MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
139
                if (mpi_errno != MPI_SUCCESS) goto fn_fail;
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
            }

            comm_ptr = win_ptr->comm_ptr;
            MPIR_ERRTEST_SEND_RANK(comm_ptr, target_rank, mpi_errno);
            MPIR_ERRTEST_ARGNULL(request,"request",mpi_errno);
        }
        MPID_END_ERROR_CHECKS;
    }
#   endif /* HAVE_ERROR_CHECKING */

    /* ... body of routine ...  */
    
    mpi_errno = MPIU_RMA_CALL(win_ptr,
                              Rput(origin_addr, origin_count, origin_datatype,
                                  target_rank, target_disp, target_count,
                                  target_datatype, win_ptr, &request_ptr));
    if (mpi_errno != MPI_SUCCESS) goto fn_fail;

    *request = request_ptr->handle;

    /* ... end of body of routine ... */

  fn_exit:
163
    MPID_MPI_RMA_FUNC_EXIT(MPID_STATE_MPI_RPUT);
164
165
166
167
168
169
170
171
    MPIU_THREAD_CS_EXIT(ALLFUNC,);
    return mpi_errno;

  fn_fail:
    /* --BEGIN ERROR HANDLING-- */
#   ifdef HAVE_ERROR_CHECKING
    {
        mpi_errno = MPIR_Err_create_code(
172
            mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_rput", "**mpi_rput %p %d %D %d %d %d %D %W %p",
173
174
175
176
177
178
179
180
            origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win, request);
    }
#   endif
    mpi_errno = MPIR_Err_return_win( win_ptr, FCNAME, mpi_errno );
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}