[AArch64] Add fpext and fpround costs (#119292)
[llvm-project.git] / offload / DeviceRTL / include / DeviceTypes.h
blob259bc008f91d13b0b80fafc73c31ab42eb132d83
1 //===---------- DeviceTypes.h - OpenMP types ---------------------- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //
10 //===----------------------------------------------------------------------===//
12 #ifndef OMPTARGET_TYPES_H
13 #define OMPTARGET_TYPES_H
15 #include <stddef.h>
16 #include <stdint.h>
18 // Tell the compiler that we do not have any "call-like" inline assembly in the
19 // device rutime. That means we cannot have inline assembly which will call
20 // another function but only inline assembly that performs some operation or
21 // side-effect and then continues execution with something on the existing call
22 // stack.
24 // TODO: Find a good place for this
25 #pragma omp assumes ext_no_call_asm
27 enum omp_proc_bind_t {
28 omp_proc_bind_false = 0,
29 omp_proc_bind_true = 1,
30 omp_proc_bind_master = 2,
31 omp_proc_bind_close = 3,
32 omp_proc_bind_spread = 4
35 enum omp_sched_t {
36 omp_sched_static = 1, /* chunkSize >0 */
37 omp_sched_dynamic = 2, /* chunkSize >0 */
38 omp_sched_guided = 3, /* chunkSize >0 */
39 omp_sched_auto = 4, /* no chunkSize */
42 enum kmp_sched_t {
43 kmp_sched_static_chunk = 33,
44 kmp_sched_static_nochunk = 34,
45 kmp_sched_dynamic = 35,
46 kmp_sched_guided = 36,
47 kmp_sched_runtime = 37,
48 kmp_sched_auto = 38,
50 kmp_sched_static_balanced_chunk = 45,
52 kmp_sched_static_ordered = 65,
53 kmp_sched_static_nochunk_ordered = 66,
54 kmp_sched_dynamic_ordered = 67,
55 kmp_sched_guided_ordered = 68,
56 kmp_sched_runtime_ordered = 69,
57 kmp_sched_auto_ordered = 70,
59 kmp_sched_distr_static_chunk = 91,
60 kmp_sched_distr_static_nochunk = 92,
61 kmp_sched_distr_static_chunk_sched_static_chunkone = 93,
63 kmp_sched_default = kmp_sched_static_nochunk,
64 kmp_sched_unordered_first = kmp_sched_static_chunk,
65 kmp_sched_unordered_last = kmp_sched_auto,
66 kmp_sched_ordered_first = kmp_sched_static_ordered,
67 kmp_sched_ordered_last = kmp_sched_auto_ordered,
68 kmp_sched_distribute_first = kmp_sched_distr_static_chunk,
69 kmp_sched_distribute_last =
70 kmp_sched_distr_static_chunk_sched_static_chunkone,
72 /* Support for OpenMP 4.5 monotonic and nonmonotonic schedule modifiers.
73 * Since we need to distinguish the three possible cases (no modifier,
74 * monotonic modifier, nonmonotonic modifier), we need separate bits for
75 * each modifier. The absence of monotonic does not imply nonmonotonic,
76 * especially since 4.5 says that the behaviour of the "no modifier" case
77 * is implementation defined in 4.5, but will become "nonmonotonic" in 5.0.
79 * Since we're passing a full 32 bit value, we can use a couple of high
80 * bits for these flags; out of paranoia we avoid the sign bit.
82 * These modifiers can be or-ed into non-static schedules by the compiler
83 * to pass the additional information. They will be stripped early in the
84 * processing in __kmp_dispatch_init when setting up schedules, so
85 * most of the code won't ever see schedules with these bits set.
87 kmp_sched_modifier_monotonic = (1 << 29),
88 /**< Set if the monotonic schedule modifier was present */
89 kmp_sched_modifier_nonmonotonic = (1 << 30),
90 /**< Set if the nonmonotonic schedule modifier was present */
92 #define SCHEDULE_WITHOUT_MODIFIERS(s) \
93 (enum kmp_sched_t)( \
94 (s) & ~(kmp_sched_modifier_nonmonotonic | kmp_sched_modifier_monotonic))
95 #define SCHEDULE_HAS_MONOTONIC(s) (((s) & kmp_sched_modifier_monotonic) != 0)
96 #define SCHEDULE_HAS_NONMONOTONIC(s) \
97 (((s) & kmp_sched_modifier_nonmonotonic) != 0)
98 #define SCHEDULE_HAS_NO_MODIFIERS(s) \
99 (((s) & (kmp_sched_modifier_nonmonotonic | kmp_sched_modifier_monotonic)) == \
104 struct TaskDescriptorTy;
105 using TaskFnTy = int32_t (*)(int32_t global_tid, TaskDescriptorTy *taskDescr);
106 struct TaskDescriptorTy {
107 void *Payload;
108 TaskFnTy TaskFn;
111 #pragma omp begin declare variant match(device = {arch(amdgcn)})
112 using LaneMaskTy = uint64_t;
113 #pragma omp end declare variant
115 #pragma omp begin declare variant match( \
116 device = {arch(amdgcn)}, implementation = {extension(match_none)})
117 using LaneMaskTy = uint64_t;
118 #pragma omp end declare variant
120 namespace lanes {
121 enum : LaneMaskTy { All = ~(LaneMaskTy)0 };
122 } // namespace lanes
124 /// The ident structure that describes a source location. The struct is
125 /// identical to the one in the kmp.h file. We maintain the same data structure
126 /// for compatibility.
127 struct IdentTy {
128 int32_t reserved_1; /**< might be used in Fortran; see above */
129 int32_t flags; /**< also f.flags; KMP_IDENT_xxx flags; KMP_IDENT_KMPC
130 identifies this union member */
131 int32_t reserved_2; /**< not really used in Fortran any more; see above */
132 int32_t reserved_3; /**< source[4] in Fortran, do not use for C++ */
133 char const *psource; /**< String describing the source location.
134 The string is composed of semi-colon separated fields
135 which describe the source file, the function and a pair
136 of line numbers that delimit the construct. */
139 using __kmpc_impl_lanemask_t = LaneMaskTy;
141 using ParallelRegionFnTy = void *;
143 using CriticalNameTy = int32_t[8];
145 struct omp_lock_t {
146 void *Lock;
149 using InterWarpCopyFnTy = void (*)(void *src, int32_t warp_num);
150 using ShuffleReductFnTy = void (*)(void *rhsData, int16_t lane_id,
151 int16_t lane_offset, int16_t shortCircuit);
152 using ListGlobalFnTy = void (*)(void *buffer, int idx, void *reduce_data);
154 /// Macros for allocating variables in different address spaces.
155 ///{
157 // Follows the pattern in interface.h
158 typedef enum omp_allocator_handle_t {
159 omp_null_allocator = 0,
160 omp_default_mem_alloc = 1,
161 omp_large_cap_mem_alloc = 2,
162 omp_const_mem_alloc = 3,
163 omp_high_bw_mem_alloc = 4,
164 omp_low_lat_mem_alloc = 5,
165 omp_cgroup_mem_alloc = 6,
166 omp_pteam_mem_alloc = 7,
167 omp_thread_mem_alloc = 8,
168 KMP_ALLOCATOR_MAX_HANDLE = ~(0LU)
169 } omp_allocator_handle_t;
171 #define __PRAGMA(STR) _Pragma(#STR)
172 #define OMP_PRAGMA(STR) __PRAGMA(omp STR)
174 #define SHARED(NAME) \
175 NAME [[clang::loader_uninitialized]]; \
176 OMP_PRAGMA(allocate(NAME) allocator(omp_pteam_mem_alloc))
178 // TODO: clang should use address space 5 for omp_thread_mem_alloc, but right
179 // now that's not the case.
180 #define THREAD_LOCAL(NAME) \
181 [[clang::address_space(5)]] NAME [[clang::loader_uninitialized]]
183 // TODO: clang should use address space 4 for omp_const_mem_alloc, maybe it
184 // does?
185 #define CONSTANT(NAME) \
186 [[clang::address_space(4)]] NAME [[clang::loader_uninitialized]]
188 ///}
190 #endif