| 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 |
//===----------------------------------------------------------------------===// |
| 11 |
|
| 12 |
#ifndef OMPTARGET_TYPES_H |
| 13 |
#define OMPTARGET_TYPES_H |
| 14 |
|
| 15 |
#include <gpuintrin.h> |
| 16 |
#include <stddef.h> |
| 17 |
#include <stdint.h> |
| 18 |
|
| 19 |
template <typename T> using Private = __gpu_private T; |
| 20 |
template <typename T> using Constant = __gpu_constant T; |
| 21 |
template <typename T> using Local = __gpu_local T; |
| 22 |
template <typename T> using Global = __gpu_local T; |
| 23 |
|
| 24 |
// See definition in OpenMP (omp.h.var/omp_lib.(F90|h).var) |
| 25 |
#define omp_invalid_device -2 |
| 26 |
|
| 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 |
| 33 |
}; |
| 34 |
|
| 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 */ |
| 40 |
}; |
| 41 |
|
| 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, |
| 49 |
|
| 50 |
kmp_sched_static_balanced_chunk = 45, |
| 51 |
|
| 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, |
| 58 |
|
| 59 |
kmp_sched_distr_static_chunk = 91, |
| 60 |
kmp_sched_distr_static_nochunk = 92, |
| 61 |
kmp_sched_distr_static_chunk_sched_static_chunkone = 93, |
| 62 |
|
| 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, |
| 71 |
|
| 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. |
| 78 |
* |
| 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. |
| 81 |
* |
| 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. |
| 86 |
*/ |
| 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 */ |
| 91 |
|
| 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)) == \ |
| 100 |
0) |
| 101 |
|
| 102 |
}; |
| 103 |
|
| 104 |
struct TaskDescriptorTy; |
| 105 |
using TaskFnTy = int32_t (*)(int32_t global_tid, TaskDescriptorTy *taskDescr); |
| 106 |
struct TaskDescriptorTy { |
| 107 |
void *Payload; |
| 108 |
TaskFnTy TaskFn; |
| 109 |
}; |
| 110 |
|
| 111 |
using LaneMaskTy = uint64_t; |
| 112 |
|
| 113 |
namespace lanes { |
| 114 |
enum : LaneMaskTy { All = ~(LaneMaskTy)0 }; |
| 115 |
} // namespace lanes |
| 116 |
|
| 117 |
/// The ident structure that describes a source location. The struct is |
| 118 |
/// identical to the one in the kmp.h file. We maintain the same data structure |
| 119 |
/// for compatibility. |
| 120 |
struct IdentTy { |
| 121 |
int32_t reserved_1; /**< might be used in Fortran; see above */ |
| 122 |
int32_t flags; /**< also f.flags; KMP_IDENT_xxx flags; KMP_IDENT_KMPC |
| 123 |
identifies this union member */ |
| 124 |
int32_t reserved_2; /**< not really used in Fortran any more; see above */ |
| 125 |
int32_t reserved_3; /**< source[4] in Fortran, do not use for C++ */ |
| 126 |
char const *psource; /**< String describing the source location. |
| 127 |
The string is composed of semi-colon separated fields |
| 128 |
which describe the source file, the function and a pair |
| 129 |
of line numbers that delimit the construct. */ |
| 130 |
}; |
| 131 |
|
| 132 |
using __kmpc_impl_lanemask_t = LaneMaskTy; |
| 133 |
|
| 134 |
using ParallelRegionFnTy = void *; |
| 135 |
|
| 136 |
using CriticalNameTy = int32_t[8]; |
| 137 |
|
| 138 |
struct omp_lock_t { |
| 139 |
void *Lock; |
| 140 |
}; |
| 141 |
|
| 142 |
using InterWarpCopyFnTy = void (*)(void *src, int32_t warp_num); |
| 143 |
using ShuffleReductFnTy = void (*)(void *rhsData, int16_t lane_id, |
| 144 |
int16_t lane_offset, int16_t shortCircuit); |
| 145 |
using ListGlobalFnTy = void (*)(void *buffer, int idx, void *reduce_data); |
| 146 |
|
| 147 |
/// Macros for allocating variables in different address spaces. |
| 148 |
///{ |
| 149 |
|
| 150 |
// Follows the pattern in interface.h |
| 151 |
typedef enum omp_allocator_handle_t { |
| 152 |
omp_null_allocator = 0, |
| 153 |
omp_default_mem_alloc = 1, |
| 154 |
omp_large_cap_mem_alloc = 2, |
| 155 |
omp_const_mem_alloc = 3, |
| 156 |
omp_high_bw_mem_alloc = 4, |
| 157 |
omp_low_lat_mem_alloc = 5, |
| 158 |
omp_cgroup_mem_alloc = 6, |
| 159 |
omp_pteam_mem_alloc = 7, |
| 160 |
omp_thread_mem_alloc = 8, |
| 161 |
KMP_ALLOCATOR_MAX_HANDLE = ~(0LU) |
| 162 |
} omp_allocator_handle_t; |
| 163 |
|
| 164 |
#define __PRAGMA(STR) _Pragma(#STR) |
| 165 |
#define OMP_PRAGMA(STR) __PRAGMA(omp STR) |
| 166 |
|
| 167 |
///} |
| 168 |
|
| 169 |
#endif |