OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

mtl_base_datatype.h
1 /*
2 * Copyright (c) 2004-2005 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-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2006 The Regents of the University of California.
11 * All rights reserved.
12 * $COPYRIGHT$
13 *
14 * Additional copyrights may follow
15 *
16 * $HEADER$
17 */
18
19 #include "ompi_config.h"
20
21 #include "opal/mca/mca.h"
22 #include "ompi/mca/mtl/mtl.h"
23 #include "ompi/mca/mtl/base/base.h"
24 #include "ompi/constants.h"
25 #include "ompi/datatype/ompi_datatype.h"
26 #include "opal/datatype/opal_convertor.h"
27 #include "opal/datatype/opal_datatype_internal.h"
28
29 static inline int
30 ompi_mtl_datatype_pack(struct opal_convertor_t *convertor,
31 void **buffer,
32 size_t *buffer_len,
33 bool *freeAfter)
34 {
35 struct iovec iov;
36 uint32_t iov_count = 1;
37
38 opal_convertor_get_packed_size(convertor, buffer_len);
39 *freeAfter = false;
40 if( 0 == *buffer_len ) {
41 *buffer = NULL;
42 return OMPI_SUCCESS;
43 }
44 iov.iov_len = *buffer_len;
45 iov.iov_base = NULL;
46 if (opal_convertor_need_buffers(convertor)) {
47 iov.iov_base = malloc(*buffer_len);
48 if (NULL == iov.iov_base) return OMPI_ERR_OUT_OF_RESOURCE;
49 *freeAfter = true;
50 }
51
52 opal_convertor_pack( convertor, &iov, &iov_count, buffer_len );
53
54 *buffer = iov.iov_base;
55
56 return OMPI_SUCCESS;
57 }
58
59
60 static inline int
61 ompi_mtl_datatype_recv_buf(struct opal_convertor_t *convertor,
62 void ** buffer,
63 size_t *buffer_len,
64 bool *free_on_error)
65 {
66 opal_convertor_get_packed_size(convertor, buffer_len);
67 *free_on_error = false;
68 if( 0 == *buffer_len ) {
69 *buffer = NULL;
70 *buffer_len = 0;
71 return OMPI_SUCCESS;
72 }
73 if (opal_convertor_need_buffers(convertor)) {
74 *buffer = malloc(*buffer_len);
75 *free_on_error = true;
76 } else {
77 *buffer = convertor->pBaseBuf +
78 convertor->use_desc->desc[convertor->use_desc->used].end_loop.first_elem_disp;
79 }
80 return OMPI_SUCCESS;
81 }
82
83
84 static inline int
85 ompi_mtl_datatype_unpack(struct opal_convertor_t *convertor,
86 void *buffer,
87 size_t buffer_len)
88 {
89 struct iovec iov;
90 uint32_t iov_count = 1;
91
92 if (buffer_len > 0 && opal_convertor_need_buffers(convertor)) {
93 iov.iov_len = buffer_len;
94 iov.iov_base = buffer;
95
96 opal_convertor_unpack(convertor, &iov, &iov_count, &buffer_len );
97
98 free(buffer);
99 }
100
101 return OMPI_SUCCESS;
102 }
ddt_endloop_desc::first_elem_disp
OPAL_PTRDIFF_TYPE first_elem_disp
the displacement of the first block in the loop
Definition: opal_datatype_internal.h:180
opal_convertor_t::pBaseBuf
unsigned char * pBaseBuf
initial buffer as supplied by the user
Definition: opal_convertor.h:101
mca.h
Top-level interface for all MCA components.
iovec
Definition: ompi_uio.h:29
opal_convertor_t
Definition: opal_convertor.h:90
dt_type_desc_t::used
opal_datatype_count_t used
the number of used elements in the description array
Definition: opal_datatype.h:94
mtl.h
Matching Transport Layer.
opal_convertor_t::use_desc
const dt_type_desc_t * use_desc
the version used by the convertor (normal or optimized)
Definition: opal_convertor.h:97