Debian Codegraph @

src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h

raw
1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #ifndef MPID_NEM_DEFS_H_INCLUDED
7 #define MPID_NEM_DEFS_H_INCLUDED
8
9 #include "mpid_nem_datatypes.h"
10 #include "mpi.h"
11 #include "mpiimpl.h"
12 #include "mpidu_init_shm.h"
13
14 /* FIXME: This definition should be gotten from mpidi_ch3_impl.h */
15 #ifndef MAX_HOSTNAME_LEN
16 #define MAX_HOSTNAME_LEN 256
17 #endif /* MAX_HOSTNAME_LEN */
18
19 extern char MPID_nem_hostname[MAX_HOSTNAME_LEN];
20
21 #define MPID_NEM_RET_OK 1
22 #define MPID_NEM_RET_NG -1
23 #define MPID_NEM_KEY 632236
24 #define MPID_NEM_ANY_SOURCE -1
25 #define MPID_NEM_IN 1
26 #define MPID_NEM_OUT 0
27
28 #define MPID_NEM_POLL_IN 0
29 #define MPID_NEM_POLL_OUT 1
30
31 #define MPID_NEM_ASYMM_NULL_VAL 64
32 extern char *MPID_nem_asymm_base_addr;
33
34 #define MPID_NEM_REL_NULL (0x0)
35 #define MPID_NEM_IS_REL_NULL(rel_ptr) (MPL_atomic_acquire_load_ptr(&(rel_ptr).p) == MPID_NEM_REL_NULL)
36 #define MPID_NEM_SET_REL_NULL(rel_ptr) (MPL_atomic_release_store_ptr(&((rel_ptr).p), MPID_NEM_REL_NULL))
37 #define MPID_NEM_REL_ARE_EQUAL(rel_ptr1, rel_ptr2) \
38 (MPL_atomic_acquire_load_ptr(&(rel_ptr1).p) == MPL_atomic_acquire_load_ptr(&(rel_ptr2).p))
39
40 #ifndef MPID_NEM_SYMMETRIC_QUEUES
41
42 /* NOTE: we are casting to uintptr_t and using integer arithmetic here. While it is pedantically
43 * undefined usage, we don't anticipate issues because the REL addresses will not be directly accessed,
44 * and only consistency matters. We can't use pointer arithmetic here because both the address
45 * (p or a) and MPID_nem_asymm_base_addr could overflow `ptrdiff_t`.
46 */
47 static inline MPID_nem_cell_ptr_t MPID_NEM_REL_TO_ABS (MPID_nem_cell_rel_ptr_t r)
48 {
49 void *p = MPL_atomic_acquire_load_ptr(&r.p);
50 return (MPID_nem_cell_ptr_t) (void *) ((uintptr_t) p + (uintptr_t) MPID_nem_asymm_base_addr);
51 }
52
53 static inline MPID_nem_cell_rel_ptr_t MPID_NEM_ABS_TO_REL (MPID_nem_cell_ptr_t a)
54 {
55 MPID_nem_cell_rel_ptr_t ret;
56 MPL_atomic_release_store_ptr(&ret.p, (void *) ((uintptr_t) a - (uintptr_t) MPID_nem_asymm_base_addr));
57 return ret;
58 }
59
60 #else /*MPID_NEM_SYMMETRIC_QUEUES */
61 #define MPID_NEM_REL_TO_ABS(ptr) (ptr)
62 #define MPID_NEM_ABS_TO_REL(ptr) (ptr)
63 #endif /*MPID_NEM_SYMMETRIC_QUEUES */
64
65 /* NOTE: MPID_NEM_IS_LOCAL should only be used when the process is known to be
66 in your comm_world (such as at init time). This will generally not work for
67 dynamic processes. Check vc_ch->is_local instead. If that is true, then
68 it's safe to use MPID_NEM_LOCAL_RANK. */
69 #define MPID_NEM_NON_LOCAL -1
70 #define MPID_NEM_IS_LOCAL(grank) (MPID_nem_mem_region.local_ranks[grank] != MPID_NEM_NON_LOCAL)
71 #define MPID_NEM_LOCAL_RANK(grank) (MPID_nem_mem_region.local_ranks[grank])
72
73 typedef struct MPID_nem_mem_region
74 {
75 void *shm_ptr;
76 int map_lock;
77 int num_local;
78 int num_procs;
79 int *local_procs; /* local_procs[lrank] gives the global rank of proc with local rank lrank */
80 int local_rank;
81 int *local_ranks; /* local_ranks[grank] gives the local rank of proc with global rank grank or MPID_NEM_NON_LOCAL */
82 int ext_procs; /* Number of non-local processes */
83 int *ext_ranks; /* Ranks of non-local processes */
84 MPID_nem_fbox_arrays_t mailboxes;
85 MPID_nem_cell_ptr_t Elements;
86 MPID_nem_queue_ptr_t *FreeQ;
87 MPID_nem_queue_ptr_t *RecvQ;
88 MPID_nem_queue_ptr_t my_freeQ;
89 MPID_nem_queue_ptr_t my_recvQ;
90 int rank;
91 struct MPID_nem_mem_region *next;
92 } MPID_nem_mem_region_t, *MPID_nem_mem_region_ptr_t;
93
94 /* #define MEM_REGION_IN_HEAP */
95 #ifdef MEM_REGION_IN_HEAP
96 #define MPID_nem_mem_region (*MPID_nem_mem_region_ptr)
97 extern MPID_nem_mem_region_t *MPID_nem_mem_region_ptr;
98 #else /* MEM_REGION_IN_HEAP */
99 extern MPID_nem_mem_region_t MPID_nem_mem_region;
100 #endif /* MEM_REGION_IN_HEAP */
101
102
103
104
105 #endif /* MPID_NEM_DEFS_H_INCLUDED */