Skip to content

Commit 5d4b9a4

Browse files
Merge commit '2de3274100e0bb2a26cbb1728040cc226b7df6c7' into bolt-2de327
2 parents 10e4e95 + 2de3274 commit 5d4b9a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2616
-930
lines changed

libomptarget/include/SourceInfo.h

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//===------- SourceInfo.h - Target independent OpenMP target RTL -- C++ -*-===//
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+
// Methods used to describe source information in target regions
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef _SOURCE_INFO_H_
14+
#define _SOURCE_INFO_H_
15+
16+
#include <string>
17+
18+
#ifdef _WIN32
19+
static const bool OS_WINDOWS = true;
20+
#else
21+
static const bool OS_WINDOWS = false;
22+
#endif
23+
24+
/// Type alias for source location information for variable mappings with
25+
/// data layout ";name;filename;row;col;;\0" from clang.
26+
using map_var_info_t = void *;
27+
28+
/// The ident structure that describes a source location from kmp.h. with
29+
/// source location string data as ";filename;function;line;column;;\0".
30+
struct ident_t {
31+
// Ident_t flags described in kmp.h.
32+
int32_t reserved_1;
33+
int32_t flags;
34+
int32_t reserved_2;
35+
int32_t reserved_3;
36+
char const *psource;
37+
};
38+
39+
/// Struct to hold source individual location information.
40+
class SourceInfo {
41+
/// Underlying string copy of the original source information.
42+
const std::string sourceStr;
43+
44+
/// Location fields extracted from the source information string.
45+
const std::string name;
46+
const std::string filename;
47+
const int32_t line;
48+
const int32_t column;
49+
50+
std::string initStr(const void *name) {
51+
if (!name)
52+
return ";unknown;unknown;0;0;;";
53+
else
54+
return std::string(reinterpret_cast<const char *>(name));
55+
}
56+
57+
/// Get n-th substring in an expression separated by ;.
58+
std::string getSubstring(const int n) const {
59+
std::size_t begin = sourceStr.find(';');
60+
std::size_t end = sourceStr.find(';', begin + 1);
61+
for (int i = 0; i < n; i++) {
62+
begin = end;
63+
end = sourceStr.find(';', begin + 1);
64+
}
65+
return sourceStr.substr(begin + 1, end - begin - 1);
66+
};
67+
68+
/// Get the filename from a full path.
69+
std::string removePath(const std::string &path) const {
70+
std::size_t pos = (OS_WINDOWS) ? path.rfind('\\') : path.rfind('/');
71+
return path.substr(pos + 1);
72+
};
73+
74+
public:
75+
SourceInfo(const ident_t *loc)
76+
: sourceStr(initStr(loc->psource)), name(getSubstring(1)),
77+
filename(removePath(getSubstring(0))), line(std::stoi(getSubstring(2))),
78+
column(std::stoi(getSubstring(3))) {}
79+
80+
SourceInfo(const map_var_info_t name)
81+
: sourceStr(initStr(name)), name(getSubstring(0)),
82+
filename(removePath(getSubstring(1))), line(std::stoi(getSubstring(2))),
83+
column(std::stoi(getSubstring(3))) {}
84+
85+
const char *getName() const { return name.c_str(); }
86+
const char *getFilename() const { return filename.c_str(); }
87+
int32_t getLine() const { return line; }
88+
int32_t getColumn() const { return column; }
89+
bool isAvailible() const { return (line || column); }
90+
};
91+
92+
/// Standalone function for getting the variable name of a mapping.
93+
static inline std::string getNameFromMapping(const map_var_info_t name) {
94+
if (!name)
95+
return "unknown";
96+
97+
const std::string name_str(reinterpret_cast<const char *>(name));
98+
std::size_t begin = name_str.find(';');
99+
std::size_t end = name_str.find(';', begin + 1);
100+
return name_str.substr(begin + 1, end - begin - 1);
101+
}
102+
103+
#endif

libomptarget/include/omptarget.h

+54-34
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <stdint.h>
1818
#include <stddef.h>
1919

20+
#include <SourceInfo.h>
21+
2022
#define OFFLOAD_SUCCESS (0)
2123
#define OFFLOAD_FAIL (~0)
2224

@@ -50,6 +52,8 @@ enum tgt_map_type {
5052
OMP_TGT_MAPTYPE_CLOSE = 0x400,
5153
// runtime error if not already allocated
5254
OMP_TGT_MAPTYPE_PRESENT = 0x1000,
55+
// descriptor for non-contiguous target-update
56+
OMP_TGT_MAPTYPE_NON_CONTIG = 0x100000000000,
5357
// member of struct, member given by [16 MSBs] - 1
5458
OMP_TGT_MAPTYPE_MEMBER_OF = 0xffff000000000000
5559
};
@@ -121,6 +125,13 @@ struct __tgt_async_info {
121125
void *Queue = nullptr;
122126
};
123127

128+
/// This struct is a record of non-contiguous information
129+
struct __tgt_target_non_contig {
130+
uint64_t Offset;
131+
uint64_t Count;
132+
uint64_t Stride;
133+
};
134+
124135
#ifdef __cplusplus
125136
extern "C" {
126137
#endif
@@ -161,13 +172,16 @@ void __tgt_target_data_begin_nowait(int64_t device_id, int32_t arg_num,
161172
int32_t depNum, void *depList,
162173
int32_t noAliasDepNum,
163174
void *noAliasDepList);
164-
void __tgt_target_data_begin_mapper(int64_t device_id, int32_t arg_num,
165-
void **args_base, void **args,
166-
int64_t *arg_sizes, int64_t *arg_types,
175+
void __tgt_target_data_begin_mapper(ident_t *loc, int64_t device_id,
176+
int32_t arg_num, void **args_base,
177+
void **args, int64_t *arg_sizes,
178+
int64_t *arg_types,
179+
map_var_info_t *arg_names,
167180
void **arg_mappers);
168181
void __tgt_target_data_begin_nowait_mapper(
169-
int64_t device_id, int32_t arg_num, void **args_base, void **args,
170-
int64_t *arg_sizes, int64_t *arg_types, void **arg_mappers, int32_t depNum,
182+
ident_t *loc, int64_t device_id, int32_t arg_num, void **args_base,
183+
void **args, int64_t *arg_sizes, int64_t *arg_types,
184+
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
171185
void *depList, int32_t noAliasDepNum, void *noAliasDepList);
172186

173187
// passes data from the target, release target memory and destroys the
@@ -180,16 +194,16 @@ void __tgt_target_data_end_nowait(int64_t device_id, int32_t arg_num,
180194
int64_t *arg_sizes, int64_t *arg_types,
181195
int32_t depNum, void *depList,
182196
int32_t noAliasDepNum, void *noAliasDepList);
183-
void __tgt_target_data_end_mapper(int64_t device_id, int32_t arg_num,
184-
void **args_base, void **args,
185-
int64_t *arg_sizes, int64_t *arg_types,
197+
void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id,
198+
int32_t arg_num, void **args_base,
199+
void **args, int64_t *arg_sizes,
200+
int64_t *arg_types, map_var_info_t *arg_names,
186201
void **arg_mappers);
187-
void __tgt_target_data_end_nowait_mapper(int64_t device_id, int32_t arg_num,
188-
void **args_base, void **args,
189-
int64_t *arg_sizes, int64_t *arg_types,
190-
void **arg_mappers, int32_t depNum,
191-
void *depList, int32_t noAliasDepNum,
192-
void *noAliasDepList);
202+
void __tgt_target_data_end_nowait_mapper(
203+
ident_t *loc, int64_t device_id, int32_t arg_num, void **args_base,
204+
void **args, int64_t *arg_sizes, int64_t *arg_types,
205+
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
206+
void *depList, int32_t noAliasDepNum, void *noAliasDepList);
193207

194208
/// passes data to/from the target
195209
void __tgt_target_data_update(int64_t device_id, int32_t arg_num,
@@ -201,13 +215,16 @@ void __tgt_target_data_update_nowait(int64_t device_id, int32_t arg_num,
201215
int32_t depNum, void *depList,
202216
int32_t noAliasDepNum,
203217
void *noAliasDepList);
204-
void __tgt_target_data_update_mapper(int64_t device_id, int32_t arg_num,
205-
void **args_base, void **args,
206-
int64_t *arg_sizes, int64_t *arg_types,
218+
void __tgt_target_data_update_mapper(ident_t *loc, int64_t device_id,
219+
int32_t arg_num, void **args_base,
220+
void **args, int64_t *arg_sizes,
221+
int64_t *arg_types,
222+
map_var_info_t *arg_names,
207223
void **arg_mappers);
208224
void __tgt_target_data_update_nowait_mapper(
209-
int64_t device_id, int32_t arg_num, void **args_base, void **args,
210-
int64_t *arg_sizes, int64_t *arg_types, void **arg_mappers, int32_t depNum,
225+
ident_t *loc, int64_t device_id, int32_t arg_num, void **args_base,
226+
void **args, int64_t *arg_sizes, int64_t *arg_types,
227+
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
211228
void *depList, int32_t noAliasDepNum, void *noAliasDepList);
212229

213230
// Performs the same actions as data_begin in case arg_num is non-zero
@@ -223,15 +240,16 @@ int __tgt_target_nowait(int64_t device_id, void *host_ptr, int32_t arg_num,
223240
void **args_base, void **args, int64_t *arg_sizes,
224241
int64_t *arg_types, int32_t depNum, void *depList,
225242
int32_t noAliasDepNum, void *noAliasDepList);
226-
int __tgt_target_mapper(int64_t device_id, void *host_ptr, int32_t arg_num,
227-
void **args_base, void **args, int64_t *arg_sizes,
228-
int64_t *arg_types, void **arg_mappers);
229-
int __tgt_target_nowait_mapper(int64_t device_id, void *host_ptr,
243+
int __tgt_target_mapper(ident_t *loc, int64_t device_id, void *host_ptr,
244+
int32_t arg_num, void **args_base, void **args,
245+
int64_t *arg_sizes, int64_t *arg_types,
246+
map_var_info_t *arg_names, void **arg_mappers);
247+
int __tgt_target_nowait_mapper(ident_t *loc, int64_t device_id, void *host_ptr,
230248
int32_t arg_num, void **args_base, void **args,
231249
int64_t *arg_sizes, int64_t *arg_types,
232-
void **arg_mappers, int32_t depNum,
233-
void *depList, int32_t noAliasDepNum,
234-
void *noAliasDepList);
250+
map_var_info_t *arg_names, void **arg_mappers,
251+
int32_t depNum, void *depList,
252+
int32_t noAliasDepNum, void *noAliasDepList);
235253

236254
int __tgt_target_teams(int64_t device_id, void *host_ptr, int32_t arg_num,
237255
void **args_base, void **args, int64_t *arg_sizes,
@@ -243,18 +261,20 @@ int __tgt_target_teams_nowait(int64_t device_id, void *host_ptr,
243261
int32_t num_teams, int32_t thread_limit,
244262
int32_t depNum, void *depList,
245263
int32_t noAliasDepNum, void *noAliasDepList);
246-
int __tgt_target_teams_mapper(int64_t device_id, void *host_ptr,
264+
int __tgt_target_teams_mapper(ident_t *loc, int64_t device_id, void *host_ptr,
247265
int32_t arg_num, void **args_base, void **args,
248266
int64_t *arg_sizes, int64_t *arg_types,
249-
void **arg_mappers, int32_t num_teams,
250-
int32_t thread_limit);
267+
map_var_info_t *arg_names, void **arg_mappers,
268+
int32_t num_teams, int32_t thread_limit);
251269
int __tgt_target_teams_nowait_mapper(
252-
int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base,
253-
void **args, int64_t *arg_sizes, int64_t *arg_types, void **arg_mappers,
254-
int32_t num_teams, int32_t thread_limit, int32_t depNum, void *depList,
255-
int32_t noAliasDepNum, void *noAliasDepList);
270+
ident_t *loc, int64_t device_id, void *host_ptr, int32_t arg_num,
271+
void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types,
272+
map_var_info_t *arg_names, void **arg_mappers, int32_t num_teams,
273+
int32_t thread_limit, int32_t depNum, void *depList, int32_t noAliasDepNum,
274+
void *noAliasDepList);
256275

257-
void __kmpc_push_target_tripcount(int64_t device_id, uint64_t loop_tripcount);
276+
void __kmpc_push_target_tripcount(ident_t *loc, int64_t device_id,
277+
uint64_t loop_tripcount);
258278

259279
#ifdef __cplusplus
260280
}

0 commit comments

Comments
 (0)