Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 +0000 | [diff] [blame] | 1 | //===---------- 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 Hahnfeld | a7c4f32 | 2017-12-06 21:59:15 +0000 | [diff] [blame] | 21 | extern 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 | |
| 24 | extern 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 Eichenberger | 1b4a666 | 2018-08-23 16:22:42 +0000 | [diff] [blame^] | 27 | extern int target_data_update(DeviceTy &Device, int32_t arg_num, |
Jonas Hahnfeld | a7c4f32 | 2017-12-06 21:59:15 +0000 | [diff] [blame] | 28 | void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types); |
| 29 | |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 +0000 | [diff] [blame] | 30 | extern 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 Hahnfeld | a7c4f32 | 2017-12-06 21:59:15 +0000 | [diff] [blame] | 34 | extern int CheckDeviceAndCtors(int64_t device_id); |
| 35 | |
Alexandre Eichenberger | 1b4a666 | 2018-08-23 16:22:42 +0000 | [diff] [blame^] | 36 | // enum for OMP_TARGET_OFFLOAD; keep in sync with kmp.h definition |
| 37 | enum kmp_target_offload_kind { |
| 38 | tgt_disabled = 0, |
| 39 | tgt_default = 1, |
| 40 | tgt_mandatory = 2 |
| 41 | }; |
| 42 | typedef enum kmp_target_offload_kind kmp_target_offload_kind_t; |
| 43 | extern kmp_target_offload_kind_t TargetOffloadPolicy; |
| 44 | |
George Rokos | 2878c39 | 2018-03-16 20:40:09 +0000 | [diff] [blame] | 45 | // Implemented in libomp, they are called from within __tgt_* functions. |
George Rokos | 6b9bb5e | 2018-03-17 02:07:42 +0000 | [diff] [blame] | 46 | #ifdef __cplusplus |
| 47 | extern "C" { |
| 48 | #endif |
Alexandre Eichenberger | 1b4a666 | 2018-08-23 16:22:42 +0000 | [diff] [blame^] | 49 | // functions that extract info from libomp; keep in sync |
George Rokos | 2878c39 | 2018-03-16 20:40:09 +0000 | [diff] [blame] | 50 | int omp_get_default_device(void) __attribute__((weak)); |
| 51 | int32_t __kmpc_omp_taskwait(void *loc_ref, int32_t gtid) __attribute__((weak)); |
Alexandre Eichenberger | 1b4a666 | 2018-08-23 16:22:42 +0000 | [diff] [blame^] | 52 | int __kmpc_get_target_offload(void) __attribute__((weak)); |
George Rokos | 6b9bb5e | 2018-03-17 02:07:42 +0000 | [diff] [blame] | 53 | #ifdef __cplusplus |
| 54 | } |
| 55 | #endif |
George Rokos | 2878c39 | 2018-03-16 20:40:09 +0000 | [diff] [blame] | 56 | |
Alexandre Eichenberger | 1b4a666 | 2018-08-23 16:22:42 +0000 | [diff] [blame^] | 57 | void FatalMessage(const int errorNum, const char *fmt, ...); |
| 58 | |
Jonas Hahnfeld | 4332280 | 2017-12-06 21:59:07 +0000 | [diff] [blame] | 59 | #ifdef OMPTARGET_DEBUG |
| 60 | extern int DebugLevel; |
| 61 | |
| 62 | #define DP(...) \ |
| 63 | do { \ |
| 64 | if (DebugLevel > 0) { \ |
| 65 | DEBUGP("Libomptarget", __VA_ARGS__); \ |
| 66 | } \ |
| 67 | } while (false) |
| 68 | #else // OMPTARGET_DEBUG |
| 69 | #define DP(...) {} |
| 70 | #endif // OMPTARGET_DEBUG |
| 71 | |
| 72 | #endif |