1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpiimpl.h"
7
8 /* -- Begin Profiling Symbol Block for routine MPI_T_pvar_write */
9 #if defined(HAVE_PRAGMA_WEAK)
10 #pragma weak MPI_T_pvar_write = PMPI_T_pvar_write
11 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
12 #pragma _HP_SECONDARY_DEF PMPI_T_pvar_write MPI_T_pvar_write
13 #elif defined(HAVE_PRAGMA_CRI_DUP)
14 #pragma _CRI duplicate MPI_T_pvar_write as PMPI_T_pvar_write
15 #elif defined(HAVE_WEAK_ATTRIBUTE)
16 int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, const void *buf)
17 __attribute__ ((weak, alias("PMPI_T_pvar_write")));
18 #endif
19 /* -- End Profiling Symbol Block */
20
21 /* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
22 the MPI routines */
23 #ifndef MPICH_MPI_FROM_PMPI
24 #undef MPI_T_pvar_write
25 #define MPI_T_pvar_write PMPI_T_pvar_write
26
27 /* any non-MPI functions go here, especially non-static ones */
28
MPIR_T_pvar_write_impl(MPI_T_pvar_session session,MPI_T_pvar_handle handle,const void * buf)29 int MPIR_T_pvar_write_impl(MPI_T_pvar_session session, MPI_T_pvar_handle handle, const void *buf)
30 {
31 /* This function should never be called */
32 return MPI_ERR_INTERN;
33 }
34
35 #endif /* MPICH_MPI_FROM_PMPI */
36
37 /*@
38 MPI_T_pvar_write - Write a performance variable
39
40 Input Parameters:
41 + session - identifier of performance experiment session (handle)
42 . handle - handle of a performance variable (handle)
43 - buf - initial address of storage location for variable value (choice)
44
45 Notes:
46 The MPI_T_pvar_write() call attempts to write the value of the performance variable
47 with the handle identified by the parameter handle in the session identified by the parameter
48 session. The value to be written is passed in the buffer identified by the parameter buf. The
49 user must ensure that the buffer is of the appropriate size to hold the entire value of the
50 performance variable (based on the datatype and count returned by the corresponding previous
51 calls to MPI_T_pvar_get_info() and MPI_T_pvar_handle_alloc(), respectively).
52
53 The constant MPI_T_PVAR_ALL_HANDLES cannot be used as an argument for the function
54 MPI_T_pvar_write().
55
56 .N ThreadSafe
57
58 .N Errors
59 .N MPI_SUCCESS
60 .N MPI_T_ERR_NOT_INITIALIZED
61 .N MPI_T_ERR_INVALID_SESSION
62 .N MPI_T_ERR_INVALID_HANDLE
63 .N MPI_T_ERR_PVAR_NO_WRITE
64 @*/
MPI_T_pvar_write(MPI_T_pvar_session session,MPI_T_pvar_handle handle,const void * buf)65 int MPI_T_pvar_write(MPI_T_pvar_session session, MPI_T_pvar_handle handle, const void *buf)
66 {
67 int mpi_errno = MPI_SUCCESS;
68
69 MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_T_PVAR_WRITE);
70 MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
71 MPIR_T_THREAD_CS_ENTER();
72 MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_T_PVAR_WRITE);
73
74 /* Validate parameters, especially handles needing to be converted */
75 #ifdef HAVE_ERROR_CHECKING
76 {
77 MPID_BEGIN_ERROR_CHECKS;
78 {
79 MPIR_ERRTEST_PVAR_SESSION(session, mpi_errno);
80 MPIR_ERRTEST_PVAR_HANDLE(handle, mpi_errno);
81 MPIR_ERRTEST_ARGNULL(buf, "buf", mpi_errno);
82 if (handle == MPI_T_PVAR_ALL_HANDLES || handle->session != session) {
83 mpi_errno = MPI_T_ERR_INVALID_HANDLE;
84 goto fn_fail;
85 }
86 }
87 MPID_END_ERROR_CHECKS;
88 }
89 #endif /* HAVE_ERROR_CHECKING */
90
91 /* ... body of routine ... */
92
93 if (MPIR_T_pvar_is_readonly(handle)) {
94 mpi_errno = MPI_T_ERR_PVAR_NO_WRITE;
95 goto fn_fail;
96 }
97
98 mpi_errno = MPIR_T_pvar_write_impl(session, handle, buf);
99 if (mpi_errno != MPI_SUCCESS)
100 goto fn_fail;
101
102 /* ... end of body of routine ... */
103
104 fn_exit:
105 MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_T_PVAR_WRITE);
106 MPIR_T_THREAD_CS_EXIT();
107 return mpi_errno;
108
109 fn_fail:
110 /* --BEGIN ERROR HANDLING-- */
111 #ifdef HAVE_ERROR_CHECKING
112 {
113 mpi_errno =
114 MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, __func__, __LINE__, MPI_ERR_OTHER,
115 "**mpi_t_pvar_write", "**mpi_t_pvar_write %p %p %p", session,
116 handle, buf);
117 }
118 #endif
119 mpi_errno = MPIR_Err_return_comm(NULL, __func__, mpi_errno);
120 goto fn_exit;
121 /* --END ERROR HANDLING-- */
122 }
123