1 /*
2  * Copyright (c) 1996-2018, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /** \file rte.h
19  * Run-time data structures
20  */
21 
22 #ifdef RTE_C
23 /*
24  * This section contains declarations which are meant to be visible only
25  * to rte.c; if necessary, other modules may enable these declarations by
26  * defining RTE_C.
27  *
28  * The prototypes, declared at the end of this file, represent the interfaces
29  * to rte.c; these prototypes are always visible to modules which include
30  * this file.
31  */
32 
33 /*
34  * The descriptor has two parts: a header and a number of per-dimension
35  * parts equal to the array rank.
36  * See the file .../rte/hpf/src/pghpf.h for the precise layout of
37  * fields within static descriptors.
38  */
39 
40 #define PROC_HDR_INT_LEN 5
41 #define PROC_DIM_LEN 5
42 
43 /*
44  * for now use just f90 decriptor defs
45  */
46 
47 #define DESC_HDR_INT_LEN 8
48 #define DESC_HDR_PTR_LEN 2
49 #define DESC_HDR_LEN                                             \
50   (((XBIT(49, 0x100) && !XBIT(49, 0x80000000) && !XBIT(68, 0x1)) \
51         ? 2 * DESC_HDR_PTR_LEN                                   \
52         : DESC_HDR_PTR_LEN) +                                    \
53    DESC_HDR_INT_LEN)
54 
55 #define DESC_DIM_LEN 6
56 
57 #define HPF_DESC_HDR_INT_LEN 16
58 #define HPF_DESC_HDR_PTR_LEN 4
59 #define HPF_DESC_HDR_LEN                                                  \
60   (((XBIT(49, 0x100) && !XBIT(49, 0x80000000)) ? 2 * HPF_DESC_HDR_PTR_LEN \
61                                                : HPF_DESC_HDR_PTR_LEN) +  \
62    HPF_DESC_HDR_INT_LEN)
63 
64 #define HPF_DESC_DIM_INT_LEN 34
65 #define DESC_DIM_PTR_LEN 1
66 #define HPF_DESC_DIM_LEN                                              \
67   (((XBIT(49, 0x100) && !XBIT(49, 0x80000000)) ? 2 * DESC_DIM_PTR_LEN \
68                                                : DESC_DIM_PTR_LEN) +  \
69    HPF_DESC_DIM_INT_LEN)
70 
71 /*
72  * HPF/F90 common descriptor fields
73  */
74 #define DESC_HDR_TAG 1      /* descriptor tag */
75 #define DESC_HDR_RANK 2     /* array rank */
76 #define DESC_HDR_KIND 3     /* array base type */
77 #define DESC_HDR_BYTE_LEN 4 /* byte length of base type */
78 #define DESC_HDR_FLAGS 5    /* descriptor flags */
79 #define DESC_HDR_LSIZE 6    /* local section size */
80 #define DESC_HDR_GSIZE 7    /* global section size */
81 #define DESC_HDR_LBASE 8    /* local base index offset */
82 #define DESC_HDR_GBASE 9    /* base address for debugger */
83 
84 /* Descriptor flag used to determine if an array section passed as a parameter
85  * to an F77 subroutine needs to be copied or whether it can be passed as is.
86  * Set in runtime routine ptr_assign and tested by the inline code.
87  */
88 #define __SEQUENTIAL_SECTION 0x20000000
89 #define __SEQUENTIAL_SECTION_BIT_OFFSET 29
90 /*
91  * HPF specific  descriptor fields
92  */
93 
94 #define HPF_DESC_HDR_HEAPB 2 /* global heap block multiplier */
95 #define HPF_DESC_HDR_PBASE 3 /* processor base offset */
96 
97 /*
98  * The f77 declaration of a descriptor for an array or section of rank
99  * 'r' would be:
100  *
101  *	 integer*4 a$d(DESC_HDR_LEN + r*DESC_DIM_LEN)
102  *
103  * Offsets to integer values accessed by the compiler in the header and
104  * per-dimension parts should also be defined in the .h file.
105  */
106 
107 /*
108  * HPF/F90 Common Dimension descriptor fields
109  */
110 #define DESC_DIM_LOWER 1   /* global lower bound index 	 */
111 #define DESC_DIM_EXTENT 2  /* global array extent		 */
112 #define DESC_DIM_SSTRIDE 3 /* section stride 		 */
113 #define DESC_DIM_SOFFSET 4 /* section offset 		 */
114 #define DESC_DIM_LMULT 5   /* index linearizing multiplier  */
115 #define DESC_DIM_UPPER 6   /* global lower bound index  (temporary) */
116 
117 /*
118  * HPF specific dimension descriptor fields
119  */
120 
121 #define HPF_DESC_DIM_LLB 1      /* local lower bound index 	33 */
122 #define HPF_DESC_DIM_LUB 2      /* local upper bound index 	34 */
123 #define HFP_DESC_DIM_COFSTR 4   /* cyclic offset stride            */
124 #define HPF_DESC_DIM_NO 5       /* negative overlap size 	38 */
125 #define HPF_DESC_DIM_PO 6       /* positive overlap size 	39 */
126 #define HPF_DESC_DIM_OLB 7      /* owned lower bound 		40 */
127 #define HPF_DESC_DIM_OUB 8      /* owned upper bound 		41 */
128 #define HPF_DESC_DIM_TOFFSET 13 /* template offset   		46 */
129 #define HPF_DESC_DIM_BLOCK 17   /* template block size 		51 */
130 #define HPF_DESC_DIM_BLOCK_RECIP_HI \
131   18 /* block size reciprocal characteristic 52 */
132 #define HPF_DESC_DIM_BLOCK_RECIP_LO 19 /* block size reciprocal mantissa 53 */
133 #define HPF_DESC_DIM_PSHAPE 23         /* extent of processor dimension 57 */
134 #define HPF_DESC_DIM_PSHAPE_RECIP_HI \
135   24 /* processor extent reciprocal characteristic 58 */
136 #define HPF_DESC_DIM_PSHAPE_RECIP_LO \
137   25 /* processor extent reciprocal mantissa 59 */
138 #define HPF_DESC_DIM_PSTRIDE \
139   27 /* stride of processor numbers in a dimension 61 */
140 #define HPF_DESC_DIM_PTR_GENBLOCK            \
141   1 /* pointer position of gen-block pointer \
142        */
143 
144 #endif /* RTE_C */
145 
146 #ifndef __TAGPOLY
147 #define __TAGPOLY 43
148 #endif
149 #ifndef __TAGDESC
150 #define __TAGDESC 35
151 #endif
152 #ifndef __TAGDERIVED
153 #define __TAGDERIVED 33
154 #endif
155 
156 extern int sym_get_proc_sdescr(char *basename, int rank);
157 extern int sym_get_place_holder(char *basename, int dtype);
158 extern int sym_get_sdescr(int sptr, int rank);
159 extern int sym_get_sdescr_inherit(int);
160 extern void get_static_descriptor(int);
161 extern void get_all_descriptors(int);
162 extern int get_multiplier_index(int);
163 extern int get_global_lower_index(int);
164 extern int get_global_upper_index(int);
165 extern int get_global_extent_index(int);
166 extern int get_section_stride_index(int);
167 extern int get_section_offset_index(int);
168 extern int get_local_multiplier(int, int);
169 extern int get_xbase_index(void);
170 extern int get_xbase(int);
171 extern int get_global_lower(int, int);
172 extern int get_global_upper(int, int);
173 extern int get_extent(int, int);
174 extern int get_section_stride(int, int);
175 extern int get_section_offset(int, int);
176 extern int get_local_lower(int, int);
177 extern int get_local_upper(int, int);
178 extern int get_smp_p2(int);
179 extern int get_desc_len(void);
180 extern int get_desc_flags(int);
181 extern int get_desc_gsize(int);
182 extern int get_desc_gsize_index(void);
183 extern int get_desc_lsize(int);
184 extern int get_lsize_index(void);
185 extern int get_proc_base(int);
186 extern int get_proc_stride(int, int);
187 extern int get_proc_shape(int, int);
188 extern int get_block_size(int, int);
189 extern int get_neg_ovlp(int, int);
190 extern int get_pos_ovlp(int, int);
191 extern int get_template_offset(int, int);
192 extern int get_descriptor_len(int rank);
193 extern int get_owner_lower(int sdsc, int dim);
194 extern int get_owner_upper(int sdsc, int dim);
195 extern int get_genblock(int sdsc, int dim);
196 extern int get_byte_len(int sdsc);
197 extern int get_byte_len_indx(void);
198 extern void set_descriptor_sc(int sc);
199 extern int get_desc_rank(int);
200 extern int get_kind(int);
201 extern int get_gbase(int);
202 extern int get_gbase2(int);
203 extern int get_desc_tag(int);
204 extern void rewrite_asn(int, int, bool, int);
205 extern void get_static_descriptor(int);
206 extern void set_descriptor_sc(int);
207 extern int get_descriptor_sc(void);
208 extern void set_descriptor_rank(int);
209 extern void set_preserve_descriptor(int);
210 extern void set_descriptor_class(int);
211 extern void set_final_descriptor(int);
212 void set_descriptor_sc(int sc);
213 int get_header_member_with_parent(int parent, int sdsc, int info);
214