1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #ifndef MPIR_TAGS_H_INCLUDED
7 #define MPIR_TAGS_H_INCLUDED
8 
9 /* Tags for point to point operations which implement collective and other
10    internal operations */
11 #define MPIR_BARRIER_TAG               1
12 #define MPIR_BCAST_TAG                 2
13 #define MPIR_GATHER_TAG                3
14 #define MPIR_GATHERV_TAG               4
15 #define MPIR_SCATTER_TAG               5
16 #define MPIR_SCATTERV_TAG              6
17 #define MPIR_ALLGATHER_TAG             7
18 #define MPIR_ALLGATHERV_TAG            8
19 #define MPIR_ALLTOALL_TAG              9
20 #define MPIR_ALLTOALLV_TAG            10
21 #define MPIR_REDUCE_TAG               11
22 #define MPIR_USER_REDUCE_TAG          12
23 #define MPIR_USER_REDUCEA_TAG         13
24 #define MPIR_ALLREDUCE_TAG            14
25 #define MPIR_USER_ALLREDUCE_TAG       15
26 #define MPIR_USER_ALLREDUCEA_TAG      16
27 #define MPIR_REDUCE_SCATTER_TAG       17
28 #define MPIR_USER_REDUCE_SCATTER_TAG  18
29 #define MPIR_USER_REDUCE_SCATTERA_TAG 19
30 #define MPIR_SCAN_TAG                 20
31 #define MPIR_USER_SCAN_TAG            21
32 #define MPIR_USER_SCANA_TAG           22
33 #define MPIR_LOCALCOPY_TAG            23
34 #define MPIR_EXSCAN_TAG               24
35 #define MPIR_ALLTOALLW_TAG            25
36 #define MPIR_TOPO_A_TAG               26
37 #define MPIR_TOPO_B_TAG               27
38 #define MPIR_REDUCE_SCATTER_BLOCK_TAG 28
39 #define MPIR_SHRINK_TAG               29
40 #define MPIR_AGREE_TAG                30
41 #define MPIR_FIRST_HCOLL_TAG          31
42 #define MPIR_LAST_HCOLL_TAG           (MPIR_FIRST_HCOLL_TAG + 255)
43 #define MPIR_FIRST_NBC_TAG            (MPIR_LAST_HCOLL_TAG + 1)
44 
45 #define MPIR_TAG_BITS_DEFAULT (31)
46 
47 /* These macros must be used carefully. These macros will not work with
48  * negative tags. By definition, users are not to use negative tags and the
49  * only negative tag in MPICH is MPI_ANY_TAG which is checked seperately, but
50  * if there is a time where negative tags become more common, this setup won't
51  * work anymore. */
52 
53 /* MPID_TAG_BITS should be declared by device later */
54 #ifdef HAVE_TAG_ERROR_BITS
55 /* This bitmask can be used to manually mask the tag space wherever it might
56  * be necessary to do so (for instance in the receive queue */
57 #define MPIR_TAG_ERROR_BIT (1 << (MPIR_Process.tag_bits - 1))
58 /* This bitmask is used to differentiate between a process failure
59  * (MPIX_ERR_PROC_FAILED) and any other kind of failure (MPI_ERR_OTHER). */
60 #define MPIR_TAG_PROC_FAILURE_BIT (1 << (MPIR_Process.tag_bits - 2))
61 #define MPIR_TAG_ERROR_BITS (2)
62 #else
63 #define MPIR_TAG_ERROR_BITS (0)
64 #endif
65 
66 /* This bitmask is used to differentiate between collective operations
67    with user-supplied tags and internally-defined tags. */
68 #define MPIR_TAG_COLL_BIT (1 << (MPIR_Process.tag_bits - MPIR_TAG_ERROR_BITS - 1))
69 
70 /* This macro checks the value of the error bit in the MPI tag and returns 1
71  * if the tag is set and 0 if it is not. */
72 #ifdef HAVE_TAG_ERROR_BITS
73 #define MPIR_TAG_CHECK_ERROR_BIT(tag) ((MPIR_TAG_ERROR_BIT & (tag)) == MPIR_TAG_ERROR_BIT ? 1 : 0)
74 #else
75 #define MPIR_TAG_CHECK_ERROR_BIT(tag) 0
76 #endif
77 
78 /* This macro checks the value of the process failure bit in the MPI tag and
79  * returns 1 if the tag is set and 0 if it is not. */
80 #ifdef HAVE_TAG_ERROR_BITS
81 #define MPIR_TAG_CHECK_PROC_FAILURE_BIT(tag) ((MPIR_TAG_PROC_FAILURE_BIT & (tag)) == MPIR_TAG_PROC_FAILURE_BIT ? 1 : 0)
82 #else
83 #define MPIR_TAG_CHECK_PROC_FAILURE_BIT(tag) 0
84 #endif
85 
86 /* This macro sets the value of the error bit in the MPI tag to 1 */
87 #ifdef HAVE_TAG_ERROR_BITS
88 #define MPIR_TAG_SET_ERROR_BIT(tag) ((tag) |= MPIR_TAG_ERROR_BIT)
89 #else
90 #define MPIR_TAG_SET_ERROR_BIT(tag) (tag)
91 #endif
92 
93 /* This macro sets the value of the process failure bit in the MPI tag to 1 */
94 #ifdef HAVE_TAG_ERROR_BITS
95 #define MPIR_TAG_SET_PROC_FAILURE_BIT(tag) ((tag) |= (MPIR_TAG_ERROR_BIT | MPIR_TAG_PROC_FAILURE_BIT))
96 #else
97 #define MPIR_TAG_SET_PROC_FAILURE_BIT(tag) (tag)
98 #endif
99 
100 /* This macro clears the value of the error bits in the MPI tag */
101 #ifdef HAVE_TAG_ERROR_BITS
102 #define MPIR_TAG_CLEAR_ERROR_BITS(tag) ((tag) &= ~(MPIR_TAG_ERROR_BIT ^ MPIR_TAG_PROC_FAILURE_BIT))
103 #else
104 #define MPIR_TAG_CLEAR_ERROR_BITS(tag) (tag)
105 #endif
106 
107 /* This macro masks the value of the error bits in the MPI tag */
108 #ifdef HAVE_TAG_ERROR_BITS
109 #define MPIR_TAG_MASK_ERROR_BITS(tag) ((tag) & ~(MPIR_TAG_ERROR_BIT ^ MPIR_TAG_PROC_FAILURE_BIT))
110 #else
111 #define MPIR_TAG_MASK_ERROR_BITS(tag) (tag)
112 #endif
113 
114 /* This macro defines tag bits available for user tags */
115 #define MPIR_TAG_USABLE_BITS ((1 << (MPIR_Process.tag_bits - MPIR_TAG_ERROR_BITS - 1)) - 1)
116 
117 #endif /* MPIR_TAGS_H_INCLUDED */
118