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