OpenMPI  0.1.1
coll_fca_convertor.h
1 #ifndef MCA_COLL_FCA_CONVERTOR_H
2 #define MCA_COLL_FCA_CONVERTOR_H
3 
4 
5 
6 
7 enum {
8  MCA_COLL_CONVERTOR_NULL = 0,
9  MCA_COLL_FCA_CONV_SEND,
10  MCA_COLL_FCA_CONV_RECV
11 };
12 
13 
15  int type;
16  FCA_CONVERTOR_T ompic;
17  size_t size;
18  void *buf;
19 };
20 
21 #define MCA_COLL_FCA_DECLARE_CONVERTOR(__name) \
22  struct mca_coll_fca_convertor __name = {MCA_COLL_CONVERTOR_NULL}
23 
24 
25 static inline void mca_coll_fca_convertor_set(struct mca_coll_fca_convertor *conv,
26  struct ompi_datatype_t *datatype,
27  void *buffer, int count)
28 {
29  if (conv->type == MCA_COLL_FCA_CONV_SEND) {
30  FCA_CONVERTOR_COPY_AND_PREPARE_FOR_SEND(ompi_mpi_local_convertor,
31  &datatype->super, count,
32  buffer, 0, &conv->ompic);
33  } else if (conv->type == MCA_COLL_FCA_CONV_RECV) {
34  FCA_CONVERTOR_COPY_AND_PREPARE_FOR_RECV(ompi_mpi_local_convertor,
35  &datatype->super, count,
36  buffer, 0, &conv->ompic);
37  }
38 }
39 
40 static inline void mca_coll_fca_convertor_create(struct mca_coll_fca_convertor *conv,
41  struct ompi_datatype_t *datatype,
42  int count, void *buffer, int type,
43  void **tmpbuf, size_t *size)
44 {
45  OBJ_CONSTRUCT(&conv->ompic, FCA_CONVERTOR_T);
46  conv->type = type;
47  mca_coll_fca_convertor_set(conv, datatype, buffer, count);
48  FCA_CONVERTOR_CONVERTOR_GET_PACKED_SIZE(&conv->ompic, &conv->size);
49  conv->buf = malloc(conv->size);
50  *tmpbuf = conv->buf;
51  *size = conv->size;
52 }
53 
54 static inline int mca_coll_fca_convertor_valid(struct mca_coll_fca_convertor *conv)
55 {
56  return conv->type != MCA_COLL_CONVERTOR_NULL;
57 }
58 
59 static inline void mca_coll_fca_convertor_destroy(struct mca_coll_fca_convertor *conv)
60 {
61  if (mca_coll_fca_convertor_valid(conv)) {
62  free(conv->buf);
63  OBJ_DESTRUCT(&conv->ompic);
64  }
65 }
66 
67 static inline int32_t mca_coll_fca_convertor_process(struct mca_coll_fca_convertor *conv,
68  size_t offset)
69 {
70  struct iovec invec;
71  unsigned iov_count;
72  size_t size;
73 
74  iov_count = 1;
75  invec.iov_base = (char*)conv->buf + offset;
76  invec.iov_len = conv->size;
77  size = conv->size;
78 
79  if (conv->type == MCA_COLL_FCA_CONV_SEND) {
80  return FCA_CONVERTOR_CONVERTOR_PACK(&conv->ompic, &invec, &iov_count, &size);
81  } else if (conv->type == MCA_COLL_FCA_CONV_RECV) {
82  return FCA_CONVERTOR_CONVERTOR_UNPACK(&conv->ompic, &invec, &iov_count, &size);
83  }
84  return 0;
85 }
86 #endif
Definition: ompi_datatype.h:68
Definition: coll_fca_convertor.h:14
opal_datatype_t super
Base opal_datatype_t superclass.
Definition: ompi_datatype.h:69
#define OBJ_CONSTRUCT(object, type)
Construct (initialize) objects that are not dynamically allocated.
Definition: opal_object.h:342
Definition: ompi_uio.h:29
#define OBJ_DESTRUCT(object)
Destruct (finalize) an object that is not dynamically allocated.
Definition: opal_object.h:374