1 /*
2  * Copyright (c) 2015-2019, 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 /* mp.h  -  various OpenMP definitions */
19 
20 #ifndef __MP_H__
21 #define __MP_H__
22 
23 /* Bit-maskable OpenMP Tasking Flags */
24 #define MP_TASK_UNTIED 0x01
25 #define MP_TASK_IF 0x02
26 #define MP_TASK_ORPHANED 0x04
27 #define MP_TASK_NESTED 0x08
28 #define MP_TASK_FORCED_DEFER 0x10
29 #define MP_TASK_FINAL 0x20
30 #define MP_TASK_IMMEDIATE 0x40
31 #define MP_TASK_MERGEABLE 0x80
32 #define MP_TASK_PRIORITY 0x100
33 #define MP_TASK_NOGROUP 0x1000
34 #define MP_TASK_GRAINSIZE 0x2000
35 #define MP_TASK_NUM_TASKS 0x4000
36 
37 /* Schedule attributes for MP_SCH_
38  * These are used to represent the MP_XXX for C or DI_XXX for FTN
39  *
40  * Basic type of schedule (auto, static, dynamic, guided, etc.)
41  * are represented by the low byte
42  */
43 #define MP_SCH_TYPE_MASK 0x000000FF
44 #define MP_SCH_STATIC 0x0
45 #define MP_SCH_DYNAMIC 0x1
46 #define MP_SCH_GUIDED 0x2
47 #define MP_SCH_INTERLEAVE 0x3
48 #define MP_SCH_RUNTIME 0x4
49 #define MP_SCH_AUTO 0x5
50 #define MP_SCH_DIST_STATIC 0x6  /* use in distribute parallel for */
51 #define MP_SCH_DIST_DYNAMIC 0x7 /* use in distribute parallel for */
52 
53 /* The second byte represents special case flags for static (maskable) */
54 #define MP_SCH_SPC_MASK 0x0000FF00
55 #define MP_SCH_SPC_SHIFT 8
56 #define MP_SCH_CHUNK_1 0x00000100 /* Chunk == 1 (static cyclic) */
57 #define MP_SCH_BLK_CYC 0x00000200 /* Chunk > 1  (block cyclic)  */
58 #define MP_SCH_BLK_ALN 0x00000400 /* Static block aligned       */
59 
60 /* The high (third) byte represents attributes (maskable) */
61 #define MP_SCH_ATTR_MASK 0x00FF0000
62 #define MP_SCH_ATTR_SHIFT 16
63 #define MP_SCH_ATTR_ORDERED 0x00010000 /* Ordered */
64 #define MP_SCH_ATTR_CHUNKED 0x00020000 /* Chunked */
65 #define MP_SCH_ATTR_DIST 0x00040000    /* distributed */
66 #define MP_SCH_ATTR_DEVICEDIST 0x00080000    /* fast GPU scheduler for TTDPF */
67 
68 /* Target/Target combine attribute */
69 #define MP_TGT_NOWAIT 0x01   /* if NOWAIT is present */
70 #define MP_TGT_IFTARGET 0x02 /* IF(target)   clause is present */
71 #define MP_TGT_IFPAR 0x04    /* IF(parallel) clause is present */
72 #define MP_TGT_DEPEND_IN                               \
73   0x08 /* depend is present and has dependence-type IN \
74           */
75 #define MP_TGT_DEPEND_OUT \
76   0x10 /* depend is present and has dependence-type OUT */
77 #define MP_TGT_DEPEND_INOUT \
78   0x20 /* Depend is present and has dependence-type INOUT */
79 #define MP_CMB_TEAMS      0x40  /* teams clause is present */
80 #define MP_CMB_DISTRIBUTE 0x80  /* distribute clause is present */
81 #define MP_CMB_PARALLEL   0x100 /* parallel clause is present */
82 #define MP_CMB_FOR        0x200 /* for clause is present */
83 #define MP_CMB_SIMD       0x400 /* simd clause is present */
84 #define MP_CMB_PARFOR     (MP_CMB_FOR|MP_CMB_PARALLEL)
85 
86 typedef enum omp_proc_bind_t {
87   MP_PROC_BIND_FALSE = 0,
88   MP_PROC_BIND_TRUE,
89   MP_PROC_BIND_MASTER,
90   MP_PROC_BIND_CLOSE,
91   MP_PROC_BIND_SPREAD,
92 } omp_proc_bind_t;
93 
94 typedef enum omp_iftype {
95   IF_DEFAULT = 0,
96   IF_TARGET = 1,
97   IF_TARGETDATA = (1 << 1),
98   IF_TARGETENTERDATA = (1 << 2),
99   IF_TARGETEXITDATA = (1 << 3),
100   IF_TARGETUPDATE = (1 << 4),
101   IF_PARALLEL = (1 << 5),
102   IF_TASK = (1 << 6),
103   IF_TASKLOOP = (1 << 7),
104 } omp_iftype;
105 
106 /* Keep up to date with pgcplus_omp_cancel_type init_omp()*/
107 typedef enum omp_canceltype {
108   CANCEL_PARALLEL = 1,
109   CANCEL_FOR = 2,
110   CANCEL_SECTIONS = 3,
111   CANCEL_TASKGROUP = 4,
112 } omp_canceltype;
113 
114 #endif /* __MP_H__ */
115