1//===-------- LegacyAPI.cpp - Target independent OpenMP target RTL --------===//
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// Legacy interfaces for libomptarget used to maintain backwards-compatibility.
10//
11//===----------------------------------------------------------------------===//
12
13#include "OpenMP/OMPT/Interface.h"
14#include "omptarget.h"
15#include "private.h"
16
17#include "Shared/Profile.h"
18
19#ifdef OMPT_SUPPORT
20using namespace llvm::omp::target::ompt;
21#endif
22
23EXTERN void __tgt_target_data_begin(int64_t DeviceId, int32_t ArgNum,
24 void **ArgsBase, void **Args,
25 int64_t *ArgSizes, int64_t *ArgTypes) {
26 TIMESCOPE();
27 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
28 __tgt_target_data_begin_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
29 ArgSizes, ArgTypes, nullptr, nullptr);
30}
31
32EXTERN void __tgt_target_data_begin_nowait(int64_t DeviceId, int32_t ArgNum,
33 void **ArgsBase, void **Args,
34 int64_t *ArgSizes, int64_t *ArgTypes,
35 int32_t DepNum, void *DepList,
36 int32_t NoAliasDepNum,
37 void *NoAliasDepList) {
38 TIMESCOPE();
39 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
40 __tgt_target_data_begin_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
41 ArgSizes, ArgTypes, nullptr, nullptr);
42}
43
44EXTERN void __tgt_target_data_end(int64_t DeviceId, int32_t ArgNum,
45 void **ArgsBase, void **Args,
46 int64_t *ArgSizes, int64_t *ArgTypes) {
47 TIMESCOPE();
48 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
49 __tgt_target_data_end_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
50 ArgSizes, ArgTypes, nullptr, nullptr);
51}
52
53EXTERN void __tgt_target_data_update(int64_t DeviceId, int32_t ArgNum,
54 void **ArgsBase, void **Args,
55 int64_t *ArgSizes, int64_t *ArgTypes) {
56 TIMESCOPE();
57 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
58 __tgt_target_data_update_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
59 ArgSizes, ArgTypes, nullptr, nullptr);
60}
61
62EXTERN void __tgt_target_data_update_nowait(
63 int64_t DeviceId, int32_t ArgNum, void **ArgsBase, void **Args,
64 int64_t *ArgSizes, int64_t *ArgTypes, int32_t DepNum, void *DepList,
65 int32_t NoAliasDepNum, void *NoAliasDepList) {
66 TIMESCOPE();
67 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
68 __tgt_target_data_update_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
69 ArgSizes, ArgTypes, nullptr, nullptr);
70}
71
72EXTERN void __tgt_target_data_end_nowait(int64_t DeviceId, int32_t ArgNum,
73 void **ArgsBase, void **Args,
74 int64_t *ArgSizes, int64_t *ArgTypes,
75 int32_t DepNum, void *DepList,
76 int32_t NoAliasDepNum,
77 void *NoAliasDepList) {
78 TIMESCOPE();
79 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
80 __tgt_target_data_end_mapper(nullptr, DeviceId, ArgNum, ArgsBase, Args,
81 ArgSizes, ArgTypes, nullptr, nullptr);
82}
83
84EXTERN int __tgt_target_mapper(ident_t *Loc, int64_t DeviceId, void *HostPtr,
85 uint32_t ArgNum, void **ArgsBase, void **Args,
86 int64_t *ArgSizes, int64_t *ArgTypes,
87 map_var_info_t *ArgNames, void **ArgMappers) {
88 TIMESCOPE_WITH_IDENT(Loc);
89 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
90 KernelArgsTy KernelArgs{1, ArgNum, ArgsBase, Args, ArgSizes,
91 ArgTypes, ArgNames, ArgMappers, 0};
92 return __tgt_target_kernel(Loc, DeviceId, -1, -1, HostPtr, &KernelArgs);
93}
94
95EXTERN int __tgt_target(int64_t DeviceId, void *HostPtr, int32_t ArgNum,
96 void **ArgsBase, void **Args, int64_t *ArgSizes,
97 int64_t *ArgTypes) {
98 TIMESCOPE();
99 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
100 return __tgt_target_mapper(nullptr, DeviceId, HostPtr, ArgNum, ArgsBase, Args,
101 ArgSizes, ArgTypes, nullptr, nullptr);
102}
103
104EXTERN int __tgt_target_nowait(int64_t DeviceId, void *HostPtr, int32_t ArgNum,
105 void **ArgsBase, void **Args, int64_t *ArgSizes,
106 int64_t *ArgTypes, int32_t DepNum, void *DepList,
107 int32_t NoAliasDepNum, void *NoAliasDepList) {
108 TIMESCOPE();
109 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
110 return __tgt_target_mapper(nullptr, DeviceId, HostPtr, ArgNum, ArgsBase, Args,
111 ArgSizes, ArgTypes, nullptr, nullptr);
112}
113
114EXTERN int __tgt_target_nowait_mapper(
115 ident_t *Loc, int64_t DeviceId, void *HostPtr, int32_t ArgNum,
116 void **ArgsBase, void **Args, int64_t *ArgSizes, int64_t *ArgTypes,
117 map_var_info_t *ArgNames, void **ArgMappers, int32_t DepNum, void *DepList,
118 int32_t NoAliasDepNum, void *NoAliasDepList) {
119 TIMESCOPE_WITH_IDENT(Loc);
120 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
121 return __tgt_target_mapper(Loc, DeviceId, HostPtr, ArgNum, ArgsBase, Args,
122 ArgSizes, ArgTypes, ArgNames, ArgMappers);
123}
124
125EXTERN int __tgt_target_teams_mapper(ident_t *Loc, int64_t DeviceId,
126 void *HostPtr, uint32_t ArgNum,
127 void **ArgsBase, void **Args,
128 int64_t *ArgSizes, int64_t *ArgTypes,
129 map_var_info_t *ArgNames,
130 void **ArgMappers, int32_t NumTeams,
131 int32_t ThreadLimit) {
132 TIMESCOPE_WITH_IDENT(Loc);
133 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
134 KernelArgsTy KernelArgs{1, ArgNum, ArgsBase, Args, ArgSizes,
135 ArgTypes, ArgNames, ArgMappers, 0};
136 return __tgt_target_kernel(Loc, DeviceId, NumTeams, ThreadLimit, HostPtr,
137 &KernelArgs);
138}
139
140EXTERN int __tgt_target_teams(int64_t DeviceId, void *HostPtr, int32_t ArgNum,
141 void **ArgsBase, void **Args, int64_t *ArgSizes,
142 int64_t *ArgTypes, int32_t NumTeams,
143 int32_t ThreadLimit) {
144 TIMESCOPE();
145 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
146 return __tgt_target_teams_mapper(nullptr, DeviceId, HostPtr, ArgNum, ArgsBase,
147 Args, ArgSizes, ArgTypes, nullptr, nullptr,
148 NumTeams, ThreadLimit);
149}
150
151EXTERN int __tgt_target_teams_nowait(int64_t DeviceId, void *HostPtr,
152 int32_t ArgNum, void **ArgsBase,
153 void **Args, int64_t *ArgSizes,
154 int64_t *ArgTypes, int32_t NumTeams,
155 int32_t ThreadLimit, int32_t DepNum,
156 void *DepList, int32_t NoAliasDepNum,
157 void *NoAliasDepList) {
158 TIMESCOPE();
159 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
160 return __tgt_target_teams_mapper(nullptr, DeviceId, HostPtr, ArgNum, ArgsBase,
161 Args, ArgSizes, ArgTypes, nullptr, nullptr,
162 NumTeams, ThreadLimit);
163}
164
165EXTERN int __tgt_target_teams_nowait_mapper(
166 ident_t *Loc, int64_t DeviceId, void *HostPtr, int32_t ArgNum,
167 void **ArgsBase, void **Args, int64_t *ArgSizes, int64_t *ArgTypes,
168 map_var_info_t *ArgNames, void **ArgMappers, int32_t NumTeams,
169 int32_t ThreadLimit, int32_t DepNum, void *DepList, int32_t NoAliasDepNum,
170 void *NoAliasDepList) {
171 TIMESCOPE_WITH_IDENT(Loc);
172 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
173 return __tgt_target_teams_mapper(Loc, DeviceId, HostPtr, ArgNum, ArgsBase,
174 Args, ArgSizes, ArgTypes, ArgNames,
175 ArgMappers, NumTeams, ThreadLimit);
176}
177
178EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *Loc, int64_t DeviceId,
179 uint64_t LoopTripcount) {
180 TIMESCOPE_WITH_IDENT(Loc);
181 DP("WARNING: __kmpc_push_target_tripcount has been deprecated and is a noop");
182}
183
184EXTERN void __kmpc_push_target_tripcount(int64_t DeviceId,
185 uint64_t LoopTripcount) {
186 __kmpc_push_target_tripcount_mapper(Loc: nullptr, DeviceId, LoopTripcount);
187}
188
189EXTERN int __tgt_target_kernel_nowait(ident_t *Loc, int64_t DeviceId,
190 int32_t NumTeams, int32_t ThreadLimit,
191 void *HostPtr, KernelArgsTy *KernelArgs,
192 int32_t DepNum, void *DepList,
193 int32_t NoAliasDepNum,
194 void *NoAliasDepList) {
195 TIMESCOPE_WITH_IDENT(Loc);
196 OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
197 return __tgt_target_kernel(Loc, DeviceId, NumTeams, ThreadLimit, HostPtr,
198 KernelArgs);
199}
200

source code of offload/src/LegacyAPI.cpp