File: coll_fca_convertor.h

package info (click to toggle)
openmpi 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 99,912 kB
  • ctags: 55,589
  • sloc: ansic: 525,999; f90: 18,307; makefile: 12,062; sh: 6,583; java: 6,278; asm: 3,515; cpp: 2,227; perl: 2,136; python: 1,350; lex: 734; fortran: 52; tcl: 12
file content (86 lines) | stat: -rw-r--r-- 2,860 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef MCA_COLL_FCA_CONVERTOR_H
#define MCA_COLL_FCA_CONVERTOR_H




enum {
    MCA_COLL_CONVERTOR_NULL = 0,
    MCA_COLL_FCA_CONV_SEND,
    MCA_COLL_FCA_CONV_RECV
};


struct mca_coll_fca_convertor {
    int               type;
    FCA_CONVERTOR_T  ompic;
    size_t            size;
    void              *buf;
};

#define MCA_COLL_FCA_DECLARE_CONVERTOR(__name) \
    struct mca_coll_fca_convertor __name = {MCA_COLL_CONVERTOR_NULL}


static inline void mca_coll_fca_convertor_set(struct mca_coll_fca_convertor *conv,
                                              struct ompi_datatype_t *datatype,
                                              void *buffer, int count)
{
    if (conv->type == MCA_COLL_FCA_CONV_SEND) {
        FCA_CONVERTOR_COPY_AND_PREPARE_FOR_SEND(ompi_mpi_local_convertor,
                                                 &datatype->super, count,
                                                 buffer, 0, &conv->ompic);
    } else if (conv->type == MCA_COLL_FCA_CONV_RECV) {
        FCA_CONVERTOR_COPY_AND_PREPARE_FOR_RECV(ompi_mpi_local_convertor,
                                                 &datatype->super, count,
                                                 buffer, 0, &conv->ompic);
    }
}

static inline void mca_coll_fca_convertor_create(struct mca_coll_fca_convertor *conv,
                                                 struct ompi_datatype_t *datatype,
                                                 int count, void *buffer, int type,
                                                 void **tmpbuf, size_t *size)
{
    OBJ_CONSTRUCT(&conv->ompic, FCA_CONVERTOR_T);
    conv->type = type;
    mca_coll_fca_convertor_set(conv, datatype, buffer, count);
    FCA_CONVERTOR_CONVERTOR_GET_PACKED_SIZE(&conv->ompic, &conv->size);
    conv->buf = malloc(conv->size);
    *tmpbuf = conv->buf;
    *size = conv->size;
}

static inline int mca_coll_fca_convertor_valid(struct mca_coll_fca_convertor *conv)
{
    return conv->type != MCA_COLL_CONVERTOR_NULL;
}

static inline void mca_coll_fca_convertor_destroy(struct mca_coll_fca_convertor *conv)
{
    if (mca_coll_fca_convertor_valid(conv)) {
        free(conv->buf);
        OBJ_DESTRUCT(&conv->ompic);
    }
}

static inline int32_t mca_coll_fca_convertor_process(struct mca_coll_fca_convertor *conv,
                                                     size_t offset)
{
    struct iovec invec;
    unsigned iov_count;
    size_t size;

    iov_count = 1;
    invec.iov_base = (char*)conv->buf + offset;
    invec.iov_len = conv->size;
    size = conv->size;

    if (conv->type == MCA_COLL_FCA_CONV_SEND) {
        return FCA_CONVERTOR_CONVERTOR_PACK(&conv->ompic, &invec, &iov_count, &size);
    } else if (conv->type == MCA_COLL_FCA_CONV_RECV) {
        return FCA_CONVERTOR_CONVERTOR_UNPACK(&conv->ompic, &invec, &iov_count, &size);
    }
    return 0;
}
#endif