Skip to content

Commit 8c7fdc4

Browse files
committed
[OpenMP] Add source location information to the libomptarget profile
In much of the libomptarget interface we have an ident_t object now, if it is not null we can use it to improve the profile output. For now, we simply use the ident_t "source information string" as generated by the FE. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D95282
1 parent bd75628 commit 8c7fdc4

File tree

5 files changed

+143
-111
lines changed

5 files changed

+143
-111
lines changed

openmp/libomptarget/include/SourceInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class SourceInfo {
9191

9292
const char *getName() const { return Name.c_str(); }
9393
const char *getFilename() const { return Filename.c_str(); }
94+
const char *getProfileLocation() const { return SourceStr.data(); }
9495
int32_t getLine() const { return Line; }
9596
int32_t getColumn() const { return Column; }
9697
bool isAvailible() const { return (Line || Column); }

openmp/libomptarget/src/interface.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ EXTERN void __tgt_target_data_begin_mapper(ident_t *loc, int64_t device_id,
132132
int64_t *arg_types,
133133
map_var_info_t *arg_names,
134134
void **arg_mappers) {
135-
TIMESCOPE();
135+
TIMESCOPE_WITH_IDENT(loc);
136136
if (IsOffloadDisabled()) return;
137137

138138
DP("Entering data begin region for device %" PRId64 " with %d mappings\n",
@@ -164,7 +164,7 @@ EXTERN void __tgt_target_data_begin_mapper(ident_t *loc, int64_t device_id,
164164
}
165165
#endif
166166

167-
int rc = targetDataBegin(Device, arg_num, args_base, args, arg_sizes,
167+
int rc = targetDataBegin(loc, Device, arg_num, args_base, args, arg_sizes,
168168
arg_types, arg_names, arg_mappers, nullptr);
169169
HandleTargetOutcome(rc == OFFLOAD_SUCCESS, loc);
170170
}
@@ -174,7 +174,7 @@ EXTERN void __tgt_target_data_begin_nowait_mapper(
174174
void **args, int64_t *arg_sizes, int64_t *arg_types,
175175
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
176176
void *depList, int32_t noAliasDepNum, void *noAliasDepList) {
177-
TIMESCOPE();
177+
TIMESCOPE_WITH_IDENT(loc);
178178
if (depNum + noAliasDepNum > 0)
179179
__kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc));
180180

@@ -210,7 +210,7 @@ EXTERN void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id,
210210
int64_t *arg_types,
211211
map_var_info_t *arg_names,
212212
void **arg_mappers) {
213-
TIMESCOPE();
213+
TIMESCOPE_WITH_IDENT(loc);
214214
if (IsOffloadDisabled()) return;
215215
DP("Entering data end region with %d mappings\n", arg_num);
216216

@@ -247,8 +247,8 @@ EXTERN void __tgt_target_data_end_mapper(ident_t *loc, int64_t device_id,
247247
}
248248
#endif
249249

250-
int rc = targetDataEnd(Device, arg_num, args_base, args, arg_sizes, arg_types,
251-
arg_names, arg_mappers, nullptr);
250+
int rc = targetDataEnd(loc, Device, arg_num, args_base, args, arg_sizes,
251+
arg_types, arg_names, arg_mappers, nullptr);
252252
HandleTargetOutcome(rc == OFFLOAD_SUCCESS, loc);
253253
}
254254

@@ -257,7 +257,7 @@ EXTERN void __tgt_target_data_end_nowait_mapper(
257257
void **args, int64_t *arg_sizes, int64_t *arg_types,
258258
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
259259
void *depList, int32_t noAliasDepNum, void *noAliasDepList) {
260-
TIMESCOPE();
260+
TIMESCOPE_WITH_IDENT(loc);
261261
if (depNum + noAliasDepNum > 0)
262262
__kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc));
263263

@@ -290,7 +290,7 @@ EXTERN void __tgt_target_data_update_mapper(ident_t *loc, int64_t device_id,
290290
int64_t *arg_types,
291291
map_var_info_t *arg_names,
292292
void **arg_mappers) {
293-
TIMESCOPE();
293+
TIMESCOPE_WITH_IDENT(loc);
294294
if (IsOffloadDisabled()) return;
295295
DP("Entering data update with %d mappings\n", arg_num);
296296

@@ -310,7 +310,7 @@ EXTERN void __tgt_target_data_update_mapper(ident_t *loc, int64_t device_id,
310310
arg_names, "Updating OpenMP data");
311311

312312
DeviceTy &Device = PM->Devices[device_id];
313-
int rc = targetDataUpdate(Device, arg_num, args_base, args, arg_sizes,
313+
int rc = targetDataUpdate(loc, Device, arg_num, args_base, args, arg_sizes,
314314
arg_types, arg_names, arg_mappers);
315315
HandleTargetOutcome(rc == OFFLOAD_SUCCESS, loc);
316316
}
@@ -320,7 +320,7 @@ EXTERN void __tgt_target_data_update_nowait_mapper(
320320
void **args, int64_t *arg_sizes, int64_t *arg_types,
321321
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
322322
void *depList, int32_t noAliasDepNum, void *noAliasDepList) {
323-
TIMESCOPE();
323+
TIMESCOPE_WITH_IDENT(loc);
324324
if (depNum + noAliasDepNum > 0)
325325
__kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc));
326326

@@ -351,7 +351,7 @@ EXTERN int __tgt_target_mapper(ident_t *loc, int64_t device_id, void *host_ptr,
351351
int32_t arg_num, void **args_base, void **args,
352352
int64_t *arg_sizes, int64_t *arg_types,
353353
map_var_info_t *arg_names, void **arg_mappers) {
354-
TIMESCOPE();
354+
TIMESCOPE_WITH_IDENT(loc);
355355
if (IsOffloadDisabled()) return OFFLOAD_FAIL;
356356
DP("Entering target region with entry point " DPxMOD " and device Id %"
357357
PRId64 "\n", DPxPTR(host_ptr), device_id);
@@ -378,7 +378,7 @@ EXTERN int __tgt_target_mapper(ident_t *loc, int64_t device_id, void *host_ptr,
378378
}
379379
#endif
380380

381-
int rc = target(device_id, host_ptr, arg_num, args_base, args, arg_sizes,
381+
int rc = target(loc, device_id, host_ptr, arg_num, args_base, args, arg_sizes,
382382
arg_types, arg_names, arg_mappers, 0, 0, false /*team*/);
383383
HandleTargetOutcome(rc == OFFLOAD_SUCCESS, loc);
384384
return rc;
@@ -389,7 +389,7 @@ EXTERN int __tgt_target_nowait_mapper(
389389
void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types,
390390
map_var_info_t *arg_names, void **arg_mappers, int32_t depNum,
391391
void *depList, int32_t noAliasDepNum, void *noAliasDepList) {
392-
TIMESCOPE();
392+
TIMESCOPE_WITH_IDENT(loc);
393393
if (depNum + noAliasDepNum > 0)
394394
__kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc));
395395

@@ -426,7 +426,6 @@ EXTERN int __tgt_target_teams_mapper(ident_t *loc, int64_t device_id,
426426
map_var_info_t *arg_names,
427427
void **arg_mappers, int32_t team_num,
428428
int32_t thread_limit) {
429-
TIMESCOPE();
430429
if (IsOffloadDisabled()) return OFFLOAD_FAIL;
431430
DP("Entering target region with entry point " DPxMOD " and device Id %"
432431
PRId64 "\n", DPxPTR(host_ptr), device_id);
@@ -453,7 +452,7 @@ EXTERN int __tgt_target_teams_mapper(ident_t *loc, int64_t device_id,
453452
}
454453
#endif
455454

456-
int rc = target(device_id, host_ptr, arg_num, args_base, args, arg_sizes,
455+
int rc = target(loc, device_id, host_ptr, arg_num, args_base, args, arg_sizes,
457456
arg_types, arg_names, arg_mappers, team_num, thread_limit,
458457
true /*team*/);
459458
HandleTargetOutcome(rc == OFFLOAD_SUCCESS, loc);
@@ -466,7 +465,7 @@ EXTERN int __tgt_target_teams_nowait_mapper(
466465
map_var_info_t *arg_names, void **arg_mappers, int32_t team_num,
467466
int32_t thread_limit, int32_t depNum, void *depList, int32_t noAliasDepNum,
468467
void *noAliasDepList) {
469-
TIMESCOPE();
468+
TIMESCOPE_WITH_IDENT(loc);
470469
if (depNum + noAliasDepNum > 0)
471470
__kmpc_omp_taskwait(loc, __kmpc_global_thread_num(loc));
472471

@@ -502,7 +501,7 @@ EXTERN void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
502501

503502
EXTERN void __kmpc_push_target_tripcount(ident_t *loc, int64_t device_id,
504503
uint64_t loop_tripcount) {
505-
TIMESCOPE();
504+
TIMESCOPE_WITH_IDENT(loc);
506505
if (IsOffloadDisabled())
507506
return;
508507

0 commit comments

Comments
 (0)