1 /* 2 * Copyright (C) Mellanox Technologies Ltd. 2001-2011. ALL RIGHTS RESERVED. 3 * $COPYRIGHT$ 4 * 5 * Additional copyrights may follow 6 * 7 * $HEADER$ 8 */ 9 10 #ifndef PML_UCX_DATATYPE_H_ 11 #define PML_UCX_DATATYPE_H_ 12 13 #include "pml_ucx.h" 14 15 16 #define PML_UCX_DATATYPE_INVALID 0 17 18 #ifdef HAVE_UCP_REQUEST_PARAM_T 19 typedef struct { 20 ucp_datatype_t datatype; 21 int size_shift; 22 struct { 23 ucp_request_param_t send; 24 ucp_request_param_t bsend; 25 ucp_request_param_t recv; 26 } op_param; 27 } pml_ucx_datatype_t; 28 #endif 29 30 struct pml_ucx_convertor { 31 opal_free_list_item_t super; 32 ompi_datatype_t *datatype; 33 opal_convertor_t opal_conv; 34 size_t offset; 35 }; 36 37 ucp_datatype_t mca_pml_ucx_init_datatype(ompi_datatype_t *datatype); 38 39 int mca_pml_ucx_datatype_attr_del_fn(ompi_datatype_t* datatype, int keyval, 40 void *attr_val, void *extra); 41 42 OBJ_CLASS_DECLARATION(mca_pml_ucx_convertor_t); 43 44 45 __opal_attribute_always_inline__ mca_pml_ucx_get_datatype(ompi_datatype_t * datatype)46static inline ucp_datatype_t mca_pml_ucx_get_datatype(ompi_datatype_t *datatype) 47 { 48 #ifdef HAVE_UCP_REQUEST_PARAM_T 49 pml_ucx_datatype_t *ucp_type = (pml_ucx_datatype_t*)datatype->pml_data; 50 51 if (OPAL_LIKELY(ucp_type != PML_UCX_DATATYPE_INVALID)) { 52 return ucp_type->datatype; 53 } 54 #else 55 ucp_datatype_t ucp_type = datatype->pml_data; 56 57 if (OPAL_LIKELY(ucp_type != PML_UCX_DATATYPE_INVALID)) { 58 return ucp_type; 59 } 60 #endif 61 62 return mca_pml_ucx_init_datatype(datatype); 63 } 64 65 #ifdef HAVE_UCP_REQUEST_PARAM_T 66 __opal_attribute_always_inline__ 67 static inline pml_ucx_datatype_t* mca_pml_ucx_get_op_data(ompi_datatype_t * datatype)68mca_pml_ucx_get_op_data(ompi_datatype_t *datatype) 69 { 70 pml_ucx_datatype_t *ucp_type = (pml_ucx_datatype_t*)datatype->pml_data; 71 72 if (OPAL_LIKELY(ucp_type != PML_UCX_DATATYPE_INVALID)) { 73 return ucp_type; 74 } 75 76 mca_pml_ucx_init_datatype(datatype); 77 return (pml_ucx_datatype_t*)datatype->pml_data; 78 } 79 80 __opal_attribute_always_inline__ mca_pml_ucx_get_data_size(pml_ucx_datatype_t * op_data,size_t count)81static inline size_t mca_pml_ucx_get_data_size(pml_ucx_datatype_t *op_data, 82 size_t count) 83 { 84 return count << op_data->size_shift; 85 } 86 #endif 87 88 #endif /* PML_UCX_DATATYPE_H_ */ 89