File: sshmem_types.h

package info (click to toggle)
openmpi 5.0.8-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 201,692 kB
  • sloc: ansic: 613,078; makefile: 42,353; sh: 11,194; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,179; python: 1,859; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (133 lines) | stat: -rw-r--r-- 4,078 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (c) 2014      Mellanox Technologies, Inc.
 *                         All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

/**
 * @file
 *
 * shmem (shared memory backing facility) framework types, convenience macros,
 * etc.
 */

#ifndef MCA_SSHMEM_TYPES_H
#define MCA_SSHMEM_TYPES_H

#include "oshmem_config.h"

BEGIN_C_DECLS

/**
 * flag indicating the state (valid/invalid) of the sshmem data structure
 * 0x0* - reserved for non-internal flags
 */
#define MAP_SEGMENT_FLAGS_VALID 0x01

/**
 * invalid id value
 */
#define MAP_SEGMENT_SHM_INVALID         (-1)

/**
 * macro that sets all bits in flags to 0
 */
#define MAP_SEGMENT_RESET_FLAGS(ds_buf)                                      \
do {                                                                         \
    (ds_buf)->flags = 0x00;                                                  \
} while (0)

/**
 * sets valid bit in flags to 1
 */
#define MAP_SEGMENT_SET_VALID(ds_buf)                                        \
do {                                                                         \
    (ds_buf)->flags |= MAP_SEGMENT_FLAGS_VALID;                              \
} while (0)

/**
 * sets valid bit in flags to 0
 */
#define MAP_SEGMENT_INVALIDATE(ds_buf)                                       \
do {                                                                         \
    (ds_buf)->flags &= ~MAP_SEGMENT_FLAGS_VALID;                             \
} while (0)

/**
 * evaluates to 1 if the valid bit in flags is set to 1.  evaluates to 0
 * otherwise.
 */
#define MAP_SEGMENT_IS_VALID(ds_buf)                                         \
    ( (ds_buf)->flags & MAP_SEGMENT_FLAGS_VALID )

typedef uint8_t segment_flag_t;

typedef enum {
    MAP_SEGMENT_STATIC = 0,
    MAP_SEGMENT_ALLOC_MMAP,
    MAP_SEGMENT_ALLOC_SHM,
    MAP_SEGMENT_ALLOC_IBV,
    MAP_SEGMENT_ALLOC_IBV_NOSHMR,
    MAP_SEGMENT_ALLOC_UCX,
    MAP_SEGMENT_UNKNOWN
} segment_type_t;

/**
 * memory key
 * There are following types of keys:
 * 1. 'shared memory' keys. Memory segment must be attached before access
 *   such keys use va_base = 0, len = 0 and key != MAP_SEGMENT_SHM_INVALID
 *   va_base will be set once segment is attached.
 * 2. empty key: len = 0, key == MAP_SEGMENT_SHM_INVALID
 * 3. generic key: Key is passed with each put/get op.
 *    use va_base = <remote vaddr>, key is stored in mkey struct:
 *    len > 0, data = &<key_blob>
 */
typedef struct sshmem_mkey {
    void* va_base;
    uint16_t len;
    union {
        void *data;
        uint64_t key;
    } u;
    void *spml_context;       /* spml module can attach internal structures here */
} sshmem_mkey_t;

typedef struct map_base_segment {
    void    *va_base;       /* base address of the segment */
    void    *va_end;        /* final address of the segment */
} map_base_segment_t;

typedef struct mkey_segment {
    map_base_segment_t  super;
    void               *rva_base;     /* base va on remote pe */
} mkey_segment_t;

typedef struct segment_allocator segment_allocator_t;

typedef struct map_segment {
    map_base_segment_t   super;
    sshmem_mkey_t      **mkeys_cache;    /* includes remote segment bases in va_base */
    sshmem_mkey_t       *mkeys;          /* includes local segment bases in va_base */
    segment_flag_t       flags;          /* enable/disable flag */
    int                  seg_id;
    size_t               seg_size;       /* length of the segment */
    segment_type_t       type;           /* type of the segment */
    long                 alloc_hints;    /* allocation hints this segment supports */
    void                *context;        /* allocator can use this field to store
                                            its own private data */
    segment_allocator_t *allocator;      /* segment-specific allocator */
} map_segment_t;

struct segment_allocator {
    int      (*sa_realloc)(map_segment_t*, size_t newsize, void *, void **);
    int         (*sa_free)(map_segment_t*, void*);
};

END_C_DECLS

#endif /* MCA_SSHMEM_TYPES_H */