1 /* 2 * Copyright (c) 2004-2005 The Trustees of Indiana University. 3 * All rights reserved. 4 * Copyright (c) 2004-2005 The Trustees of the University of Tennessee. 5 * All rights reserved. 6 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 7 * University of Stuttgart. All rights reserved. 8 * Copyright (c) 2004-2005 The Regents of the University of California. 9 * All rights reserved. 10 * Copyright (c) 2015 Research Organization for Information Science 11 * and Technology (RIST). All rights reserved. 12 * $COPYRIGHT$ 13 * 14 * Additional copyrights may follow 15 * 16 * $HEADER$ 17 */ 18 19 /** 20 * @file 21 * 22 * Utility functions for Open MPI object manipulation by the One-sided code 23 * 24 * Utility functions for creating / finding handles for Open MPI 25 * objects, usually based on indexes sent from remote peers. 26 */ 27 28 #include "ompi_config.h" 29 #include "ompi/datatype/ompi_datatype.h" 30 #include "ompi/proc/proc.h" 31 #include "ompi/op/op.h" 32 33 BEGIN_C_DECLS 34 35 /** 36 * Create datatype based on packed payload 37 * 38 * Create a useable MPI datatype based on it's packed description. 39 * The datatype is owned by the calling process and must be 40 * OBJ_RELEASEd when no longer in use. 41 * 42 * @param remote_proc The ompi_proc_t pointer for the remote process 43 * @param payload A pointer to the pointer to the payload. The 44 * pointer to the payload will be moved past the 45 * datatype information upon successful return. 46 * 47 * @retval NULL A failure occrred 48 * @retval non-NULL A fully operational datatype 49 */ 50 static inline 51 struct ompi_datatype_t* 52 ompi_osc_base_datatype_create(ompi_proc_t *remote_proc, void **payload) 53 { 54 struct ompi_datatype_t *datatype = 55 ompi_datatype_create_from_packed_description(payload, remote_proc); 56 if (NULL == datatype) return NULL; 57 OMPI_DATATYPE_RETAIN(datatype); 58 return datatype; 59 } 60 61 62 /** 63 * Create datatype based on Fortran Index 64 * 65 * Create a useable MPI datatype based on it's Fortran index, which is 66 * globally the same for predefined operations. The op handle is 67 * owned by the calling process and must be OBJ_RELEASEd when no 68 * longer in use. 69 * 70 * @param op_id The fortran index for the operaton 71 * 72 * @retval NULL A failure occrred 73 * @retval non-NULL An op handle 74 */ 75 static inline 76 ompi_op_t * 77 ompi_osc_base_op_create(int op_id) 78 { 79 ompi_op_t *op = PMPI_Op_f2c(op_id); 80 OBJ_RETAIN(op); 81 return op; 82 } 83 84 85 /** 86 * Get the primitive datatype information for a legal one-sided accumulate datatype 87 * 88 * Get the primitive datatype information for a legal one-sided 89 * accumulate datatype. This includes the primitive datatype used to 90 * build the datatype (there can be only one) and the number of 91 * instances of that primitive datatype in the datatype (there can be 92 * many). 93 * 94 * @param datatype legal one-sided datatype 95 * @param prim_datatype The primitive datatype used to build datatype 96 * @param prim_count Number of instances of prim_datattpe in datatype 97 * 98 * @retval OMPI_SUCCESS Success 99 */ 100 OMPI_DECLSPEC int ompi_osc_base_get_primitive_type_info(ompi_datatype_t *datatype, 101 ompi_datatype_t **prim_datatype, 102 uint32_t *prim_count); 103 104 105 /** 106 * Apply the operation specified from inbuf to outbut 107 * 108 * Apply the specified reduction operation from inbuf to outbuf. 109 * inbuf must contain count instances of datatype, in the local 110 * process's binary mode. 111 * 112 * @retval OMPI_SUCCESS Success 113 * @retval OMPI_ERR_NOT_SUPPORTED Called with op == ompi_mpi_op_replace 114 */ 115 OMPI_DECLSPEC int ompi_osc_base_process_op(void *outbuf, 116 void *inbuf, 117 size_t inbuflen, 118 struct ompi_datatype_t *datatype, 119 int count, 120 ompi_op_t *op); 121 122 OMPI_DECLSPEC int ompi_osc_base_sndrcv_op(const void *origin, 123 int32_t origin_count, 124 struct ompi_datatype_t *origin_dt, 125 void *target, 126 int32_t target_count, 127 struct ompi_datatype_t *target_dt, 128 ompi_op_t *op); 129 130 END_C_DECLS