1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
//===-------- Interface.h - OpenMP interface ---------------------- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#ifndef OMPTARGET_DEVICERTL_INTERFACE_H
#define OMPTARGET_DEVICERTL_INTERFACE_H
#include "Types.h"
/// External API
///
///{
extern "C" {
/// ICV: dyn-var, constant 0
///
/// setter: ignored.
/// getter: returns 0.
///
///{
void omp_set_dynamic(int);
int omp_get_dynamic(void);
///}
/// ICV: nthreads-var, integer
///
/// scope: data environment
///
/// setter: ignored.
/// getter: returns false.
///
/// implementation notes:
///
///
///{
void omp_set_num_threads(int);
int omp_get_max_threads(void);
///}
/// ICV: thread-limit-var, computed
///
/// getter: returns thread limited defined during launch.
///
///{
int omp_get_thread_limit(void);
///}
/// ICV: max-active-level-var, constant 1
///
/// setter: ignored.
/// getter: returns 1.
///
///{
void omp_set_max_active_levels(int);
int omp_get_max_active_levels(void);
///}
/// ICV: places-partition-var
///
///
///{
///}
/// ICV: active-level-var, 0 or 1
///
/// getter: returns 0 or 1.
///
///{
int omp_get_active_level(void);
///}
/// ICV: level-var
///
/// getter: returns parallel region nesting
///
///{
int omp_get_level(void);
///}
/// ICV: run-sched-var
///
///
///{
void omp_set_schedule(omp_sched_t, int);
void omp_get_schedule(omp_sched_t *, int *);
///}
/// TODO this is incomplete.
int omp_get_num_threads(void);
int omp_get_thread_num(void);
void omp_set_nested(int);
int omp_get_nested(void);
void omp_set_max_active_levels(int Level);
int omp_get_max_active_levels(void);
omp_proc_bind_t omp_get_proc_bind(void);
int omp_get_num_places(void);
int omp_get_place_num_procs(int place_num);
void omp_get_place_proc_ids(int place_num, int *ids);
int omp_get_place_num(void);
int omp_get_partition_num_places(void);
void omp_get_partition_place_nums(int *place_nums);
int omp_get_cancellation(void);
void omp_set_default_device(int deviceId);
int omp_get_default_device(void);
int omp_get_num_devices(void);
int omp_get_device_num(void);
int omp_get_num_teams(void);
int omp_get_team_num();
int omp_get_initial_device(void);
void *llvm_omp_target_dynamic_shared_alloc();
/// Synchronization
///
///{
void omp_init_lock(omp_lock_t *Lock);
void omp_destroy_lock(omp_lock_t *Lock);
void omp_set_lock(omp_lock_t *Lock);
void omp_unset_lock(omp_lock_t *Lock);
int omp_test_lock(omp_lock_t *Lock);
///}
/// Tasking
///
///{
int omp_in_final(void);
int omp_get_max_task_priority(void);
///}
/// Misc
///
///{
double omp_get_wtick(void);
double omp_get_wtime(void);
///}
}
extern "C" {
/// Allocate \p Bytes in "shareable" memory and return the address. Needs to be
/// called balanced with __kmpc_free_shared like a stack (push/pop). Can be
/// called by any thread, allocation happens *per thread*.
void *__kmpc_alloc_shared(uint64_t Bytes);
/// Deallocate \p Ptr. Needs to be called balanced with __kmpc_alloc_shared like
/// a stack (push/pop). Can be called by any thread. \p Ptr has to be the
/// allocated by __kmpc_alloc_shared by the same thread.
void __kmpc_free_shared(void *Ptr, uint64_t Bytes);
/// Get a pointer to the memory buffer containing dynamically allocated shared
/// memory configured at launch.
void *__kmpc_get_dynamic_shared();
/// Allocate sufficient space for \p NumArgs sequential `void*` and store the
/// allocation address in \p GlobalArgs.
///
/// Called by the main thread prior to a parallel region.
///
/// We also remember it in GlobalArgsPtr to ensure the worker threads and
/// deallocation function know the allocation address too.
void __kmpc_begin_sharing_variables(void ***GlobalArgs, uint64_t NumArgs);
/// Deallocate the memory allocated by __kmpc_begin_sharing_variables.
///
/// Called by the main thread after a parallel region.
void __kmpc_end_sharing_variables();
/// Store the allocation address obtained via __kmpc_begin_sharing_variables in
/// \p GlobalArgs.
///
/// Called by the worker threads in the parallel region (function).
void __kmpc_get_shared_variables(void ***GlobalArgs);
/// External interface to get the thread ID.
uint32_t __kmpc_get_hardware_thread_id_in_block();
/// External interface to get the number of threads.
uint32_t __kmpc_get_hardware_num_threads_in_block();
/// External interface to get the warp size.
uint32_t __kmpc_get_warp_size();
/// Kernel
///
///{
int8_t __kmpc_is_spmd_exec_mode();
int32_t __kmpc_target_init(IdentTy *Ident, int8_t Mode,
bool UseGenericStateMachine, bool);
void __kmpc_target_deinit(IdentTy *Ident, int8_t Mode, bool);
///}
/// Reduction
///
///{
void __kmpc_nvptx_end_reduce(int32_t TId);
void __kmpc_nvptx_end_reduce_nowait(int32_t TId);
int32_t __kmpc_nvptx_parallel_reduce_nowait_v2(
IdentTy *Loc, int32_t TId, int32_t num_vars, uint64_t reduce_size,
void *reduce_data, ShuffleReductFnTy shflFct, InterWarpCopyFnTy cpyFct);
int32_t __kmpc_nvptx_teams_reduce_nowait_v2(
IdentTy *Loc, int32_t TId, void *GlobalBuffer, uint32_t num_of_records,
void *reduce_data, ShuffleReductFnTy shflFct, InterWarpCopyFnTy cpyFct,
ListGlobalFnTy lgcpyFct, ListGlobalFnTy lgredFct, ListGlobalFnTy glcpyFct,
ListGlobalFnTy glredFct);
///}
/// Synchronization
///
///{
void __kmpc_ordered(IdentTy *Loc, int32_t TId);
void __kmpc_end_ordered(IdentTy *Loc, int32_t TId);
int32_t __kmpc_cancel_barrier(IdentTy *Loc_ref, int32_t TId);
void __kmpc_barrier(IdentTy *Loc_ref, int32_t TId);
void __kmpc_barrier_simple_spmd(IdentTy *Loc_ref, int32_t TId);
void __kmpc_barrier_simple_generic(IdentTy *Loc_ref, int32_t TId);
int32_t __kmpc_master(IdentTy *Loc, int32_t TId);
void __kmpc_end_master(IdentTy *Loc, int32_t TId);
int32_t __kmpc_single(IdentTy *Loc, int32_t TId);
void __kmpc_end_single(IdentTy *Loc, int32_t TId);
void __kmpc_flush(IdentTy *Loc);
uint64_t __kmpc_warp_active_thread_mask(void);
void __kmpc_syncwarp(uint64_t Mask);
void __kmpc_critical(IdentTy *Loc, int32_t TId, CriticalNameTy *Name);
void __kmpc_end_critical(IdentTy *Loc, int32_t TId, CriticalNameTy *Name);
///}
/// Parallelism
///
///{
/// TODO
void __kmpc_kernel_prepare_parallel(ParallelRegionFnTy WorkFn);
/// TODO
bool __kmpc_kernel_parallel(ParallelRegionFnTy *WorkFn);
/// TODO
void __kmpc_kernel_end_parallel();
/// TODO
void __kmpc_push_proc_bind(IdentTy *Loc, uint32_t TId, int ProcBind);
/// TODO
void __kmpc_push_num_teams(IdentTy *Loc, int32_t TId, int32_t NumTeams,
int32_t ThreadLimit);
/// TODO
uint16_t __kmpc_parallel_level(IdentTy *Loc, uint32_t);
///}
/// Tasking
///
///{
TaskDescriptorTy *__kmpc_omp_task_alloc(IdentTy *, uint32_t, int32_t,
uint32_t TaskSizeInclPrivateValues,
uint32_t SharedValuesSize,
TaskFnTy TaskFn);
int32_t __kmpc_omp_task(IdentTy *Loc, uint32_t TId,
TaskDescriptorTy *TaskDescriptor);
int32_t __kmpc_omp_task_with_deps(IdentTy *Loc, uint32_t TId,
TaskDescriptorTy *TaskDescriptor, int32_t,
void *, int32_t, void *);
void __kmpc_omp_task_begin_if0(IdentTy *Loc, uint32_t TId,
TaskDescriptorTy *TaskDescriptor);
void __kmpc_omp_task_complete_if0(IdentTy *Loc, uint32_t TId,
TaskDescriptorTy *TaskDescriptor);
void __kmpc_omp_wait_deps(IdentTy *Loc, uint32_t TId, int32_t, void *, int32_t,
void *);
void __kmpc_taskgroup(IdentTy *Loc, uint32_t TId);
void __kmpc_end_taskgroup(IdentTy *Loc, uint32_t TId);
int32_t __kmpc_omp_taskyield(IdentTy *Loc, uint32_t TId, int);
int32_t __kmpc_omp_taskwait(IdentTy *Loc, uint32_t TId);
void __kmpc_taskloop(IdentTy *Loc, uint32_t TId,
TaskDescriptorTy *TaskDescriptor, int,
uint64_t *LowerBound, uint64_t *UpperBound, int64_t, int,
int32_t, uint64_t, void *);
///}
/// Misc
///
///{
int32_t __kmpc_cancellationpoint(IdentTy *Loc, int32_t TId, int32_t CancelVal);
int32_t __kmpc_cancel(IdentTy *Loc, int32_t TId, int32_t CancelVal);
///}
/// Shuffle
///
///{
int32_t __kmpc_shuffle_int32(int32_t val, int16_t delta, int16_t size);
int64_t __kmpc_shuffle_int64(int64_t val, int16_t delta, int16_t size);
///}
}
#endif
|