blob: 3b612958c5312ea0b532c12ee63ec03295c42a17 [file] [log] [blame]
Jonas Hahnfeld43322802017-12-06 21:59:07 +00001//===---------- private.h - Target independent OpenMP target RTL ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.txt for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Private function declarations and helper macros for debugging output.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef _OMPTARGET_PRIVATE_H
15#define _OMPTARGET_PRIVATE_H
16
17#include <omptarget.h>
18
19#include <cstdint>
20
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000021extern int target_data_begin(DeviceTy &Device, int32_t arg_num,
22 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types);
23
24extern int target_data_end(DeviceTy &Device, int32_t arg_num, void **args_base,
25 void **args, int64_t *arg_sizes, int64_t *arg_types);
26
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000027extern int target_data_update(DeviceTy &Device, int32_t arg_num,
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000028 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types);
29
Jonas Hahnfeld43322802017-12-06 21:59:07 +000030extern int target(int64_t device_id, void *host_ptr, int32_t arg_num,
31 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types,
32 int32_t team_num, int32_t thread_limit, int IsTeamConstruct);
33
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000034extern int CheckDeviceAndCtors(int64_t device_id);
35
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000036// enum for OMP_TARGET_OFFLOAD; keep in sync with kmp.h definition
37enum kmp_target_offload_kind {
38 tgt_disabled = 0,
39 tgt_default = 1,
40 tgt_mandatory = 2
41};
42typedef enum kmp_target_offload_kind kmp_target_offload_kind_t;
43extern kmp_target_offload_kind_t TargetOffloadPolicy;
44
Alexandre Eichenbergere9b7d8d2018-08-27 18:20:15 +000045////////////////////////////////////////////////////////////////////////////////
46// implemtation for fatal messages
47////////////////////////////////////////////////////////////////////////////////
48
49#define FATAL_MESSAGE0(_num, _str) \
50 do { \
51 fprintf(stderr, "Libomptarget fatal error %d: %s\n", _num, _str); \
52 exit(1); \
53 } while (0)
54
55#define FATAL_MESSAGE(_num, _str, ...) \
56 do { \
57 fprintf(stderr, "Libomptarget fatal error %d:" _str "\n", _num, \
58 __VA_ARGS__); \
59 exit(1); \
60 } while (0)
61
George Rokos2878c392018-03-16 20:40:09 +000062// Implemented in libomp, they are called from within __tgt_* functions.
George Rokos6b9bb5e2018-03-17 02:07:42 +000063#ifdef __cplusplus
64extern "C" {
65#endif
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000066// functions that extract info from libomp; keep in sync
George Rokos2878c392018-03-16 20:40:09 +000067int omp_get_default_device(void) __attribute__((weak));
68int32_t __kmpc_omp_taskwait(void *loc_ref, int32_t gtid) __attribute__((weak));
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000069int __kmpc_get_target_offload(void) __attribute__((weak));
George Rokos6b9bb5e2018-03-17 02:07:42 +000070#ifdef __cplusplus
71}
72#endif
George Rokos2878c392018-03-16 20:40:09 +000073
Jonas Hahnfeld43322802017-12-06 21:59:07 +000074#ifdef OMPTARGET_DEBUG
75extern int DebugLevel;
76
77#define DP(...) \
78 do { \
79 if (DebugLevel > 0) { \
80 DEBUGP("Libomptarget", __VA_ARGS__); \
81 } \
82 } while (false)
83#else // OMPTARGET_DEBUG
84#define DP(...) {}
85#endif // OMPTARGET_DEBUG
86
87#endif