blob: b48415cc61afe0f243f4e7678685992bc4337be4 [file] [log] [blame]
Jonas Hahnfeld43322802017-12-06 21:59:07 +00001//===---------- private.h - Target independent OpenMP target RTL ----------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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
Jonas Hahnfeld43322802017-12-06 21:59:07 +00006//
7//===----------------------------------------------------------------------===//
8//
9// Private function declarations and helper macros for debugging output.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef _OMPTARGET_PRIVATE_H
14#define _OMPTARGET_PRIVATE_H
15
16#include <omptarget.h>
17
18#include <cstdint>
19
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000020extern int target_data_begin(DeviceTy &Device, int32_t arg_num,
21 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types);
22
23extern int target_data_end(DeviceTy &Device, int32_t arg_num, void **args_base,
24 void **args, int64_t *arg_sizes, int64_t *arg_types);
25
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000026extern int target_data_update(DeviceTy &Device, int32_t arg_num,
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000027 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types);
28
Jonas Hahnfeld43322802017-12-06 21:59:07 +000029extern int target(int64_t device_id, void *host_ptr, int32_t arg_num,
30 void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types,
31 int32_t team_num, int32_t thread_limit, int IsTeamConstruct);
32
Jonas Hahnfelda7c4f322017-12-06 21:59:15 +000033extern int CheckDeviceAndCtors(int64_t device_id);
34
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000035// enum for OMP_TARGET_OFFLOAD; keep in sync with kmp.h definition
36enum kmp_target_offload_kind {
37 tgt_disabled = 0,
38 tgt_default = 1,
39 tgt_mandatory = 2
40};
41typedef enum kmp_target_offload_kind kmp_target_offload_kind_t;
42extern kmp_target_offload_kind_t TargetOffloadPolicy;
43
Alexandre Eichenbergere9b7d8d2018-08-27 18:20:15 +000044////////////////////////////////////////////////////////////////////////////////
45// implemtation for fatal messages
46////////////////////////////////////////////////////////////////////////////////
47
48#define FATAL_MESSAGE0(_num, _str) \
49 do { \
50 fprintf(stderr, "Libomptarget fatal error %d: %s\n", _num, _str); \
51 exit(1); \
52 } while (0)
53
54#define FATAL_MESSAGE(_num, _str, ...) \
55 do { \
56 fprintf(stderr, "Libomptarget fatal error %d:" _str "\n", _num, \
57 __VA_ARGS__); \
58 exit(1); \
59 } while (0)
60
George Rokos2878c392018-03-16 20:40:09 +000061// Implemented in libomp, they are called from within __tgt_* functions.
George Rokos6b9bb5e2018-03-17 02:07:42 +000062#ifdef __cplusplus
63extern "C" {
64#endif
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000065// functions that extract info from libomp; keep in sync
George Rokos2878c392018-03-16 20:40:09 +000066int omp_get_default_device(void) __attribute__((weak));
67int32_t __kmpc_omp_taskwait(void *loc_ref, int32_t gtid) __attribute__((weak));
Alexandre Eichenberger1b4a6662018-08-23 16:22:42 +000068int __kmpc_get_target_offload(void) __attribute__((weak));
George Rokos6b9bb5e2018-03-17 02:07:42 +000069#ifdef __cplusplus
70}
71#endif
George Rokos2878c392018-03-16 20:40:09 +000072
Jonas Hahnfeld43322802017-12-06 21:59:07 +000073#ifdef OMPTARGET_DEBUG
74extern int DebugLevel;
75
76#define DP(...) \
77 do { \
78 if (DebugLevel > 0) { \
79 DEBUGP("Libomptarget", __VA_ARGS__); \
80 } \
81 } while (false)
82#else // OMPTARGET_DEBUG
83#define DP(...) {}
84#endif // OMPTARGET_DEBUG
85
86#endif