Skip to content

Commit 6579021

Browse files
committed
[OpenMP] Fix Slice Duplicate in Profiler
Using LIBOMPTARGET_PROFILER, duplicates are created from timing both Kernel functions and Data update functions. I commented out the duplicate timescope and left them in the targetkernel and the targetdataupdate functions. This way the timescope calls will be closer to the launching of the kernel and the data moving. Reviewed By: jdoerfert, tianshilei1992 Differential Revision: https://reviews.llvm.org/D157725
1 parent b59cf21 commit 6579021

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

openmp/libomptarget/src/interface.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ targetDataMapper(ident_t *Loc, int64_t DeviceId, int32_t ArgNum,
8282
static_assert(std::is_convertible_v<TargetAsyncInfoTy, AsyncInfoTy>,
8383
"TargetAsyncInfoTy must be convertible to AsyncInfoTy.");
8484

85-
TIMESCOPE_WITH_IDENT(Loc);
85+
TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, Loc);
8686

8787
DP("Entering data %s region for device %" PRId64 " with %d mappings\n",
8888
RegionName, DeviceId, ArgNum);
@@ -143,21 +143,21 @@ EXTERN void __tgt_target_data_begin_mapper(ident_t *Loc, int64_t DeviceId,
143143
int64_t *ArgTypes,
144144
map_var_info_t *ArgNames,
145145
void **ArgMappers) {
146-
TIMESCOPE_WITH_IDENT(Loc);
146+
147147
targetDataMapper<AsyncInfoTy>(Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes,
148148
ArgTypes, ArgNames, ArgMappers, targetDataBegin,
149-
"Entering OpenMP data region", "begin");
149+
"Entering OpenMP data region with being_mapper", "begin");
150150
}
151151

152152
EXTERN void __tgt_target_data_begin_nowait_mapper(
153153
ident_t *Loc, int64_t DeviceId, int32_t ArgNum, void **ArgsBase,
154154
void **Args, int64_t *ArgSizes, int64_t *ArgTypes, map_var_info_t *ArgNames,
155155
void **ArgMappers, int32_t DepNum, void *DepList, int32_t NoAliasDepNum,
156156
void *NoAliasDepList) {
157-
TIMESCOPE_WITH_IDENT(Loc);
157+
158158
targetDataMapper<TaskAsyncInfoWrapperTy>(
159159
Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames,
160-
ArgMappers, targetDataBegin, "Entering OpenMP data region", "begin");
160+
ArgMappers, targetDataBegin, "Entering OpenMP data region with being_nowait_mapper", "begin");
161161
}
162162

163163
/// passes data from the target, releases target memory and destroys
@@ -169,44 +169,42 @@ EXTERN void __tgt_target_data_end_mapper(ident_t *Loc, int64_t DeviceId,
169169
int64_t *ArgTypes,
170170
map_var_info_t *ArgNames,
171171
void **ArgMappers) {
172-
TIMESCOPE_WITH_IDENT(Loc);
172+
173173
targetDataMapper<AsyncInfoTy>(Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes,
174174
ArgTypes, ArgNames, ArgMappers, targetDataEnd,
175-
"Exiting OpenMP data region", "end");
175+
"Exiting OpenMP data region with end_mapper", "end");
176176
}
177177

178178
EXTERN void __tgt_target_data_end_nowait_mapper(
179179
ident_t *Loc, int64_t DeviceId, int32_t ArgNum, void **ArgsBase,
180180
void **Args, int64_t *ArgSizes, int64_t *ArgTypes, map_var_info_t *ArgNames,
181181
void **ArgMappers, int32_t DepNum, void *DepList, int32_t NoAliasDepNum,
182182
void *NoAliasDepList) {
183-
TIMESCOPE_WITH_IDENT(Loc);
183+
184184
targetDataMapper<TaskAsyncInfoWrapperTy>(
185185
Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames,
186-
ArgMappers, targetDataEnd, "Exiting OpenMP data region", "end");
186+
ArgMappers, targetDataEnd, "Exiting OpenMP data region with end_nowait_mapper", "end");
187187
}
188188

189189
EXTERN void __tgt_target_data_update_mapper(ident_t *Loc, int64_t DeviceId,
190190
int32_t ArgNum, void **ArgsBase,
191191
void **Args, int64_t *ArgSizes,
192192
int64_t *ArgTypes,
193193
map_var_info_t *ArgNames,
194-
void **ArgMappers) {
195-
TIMESCOPE_WITH_IDENT(Loc);
194+
196195
targetDataMapper<AsyncInfoTy>(
197196
Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames,
198-
ArgMappers, targetDataUpdate, "Updating OpenMP data", "update");
197+
ArgMappers, targetDataUpdate, "Updating data within the OpenMP data region with update_mapper", "update");
199198
}
200199

201200
EXTERN void __tgt_target_data_update_nowait_mapper(
202201
ident_t *Loc, int64_t DeviceId, int32_t ArgNum, void **ArgsBase,
203202
void **Args, int64_t *ArgSizes, int64_t *ArgTypes, map_var_info_t *ArgNames,
204203
void **ArgMappers, int32_t DepNum, void *DepList, int32_t NoAliasDepNum,
205204
void *NoAliasDepList) {
206-
TIMESCOPE_WITH_IDENT(Loc);
207205
targetDataMapper<TaskAsyncInfoWrapperTy>(
208206
Loc, DeviceId, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames,
209-
ArgMappers, targetDataUpdate, "Updating OpenMP data", "update");
207+
ArgMappers, targetDataUpdate, "Updating data within the OpenMP data region with update_nowait_mapper", "update");
210208
}
211209

212210
static KernelArgsTy *upgradeKernelArgs(KernelArgsTy *KernelArgs,
@@ -323,7 +321,6 @@ static inline int targetKernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams,
323321
EXTERN int __tgt_target_kernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams,
324322
int32_t ThreadLimit, void *HostPtr,
325323
KernelArgsTy *KernelArgs) {
326-
TIMESCOPE_WITH_IDENT(Loc);
327324
if (KernelArgs->Flags.NoWait)
328325
return targetKernel<TaskAsyncInfoWrapperTy>(
329326
Loc, DeviceId, NumTeams, ThreadLimit, HostPtr, KernelArgs);

openmp/libomptarget/src/omptarget.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ int targetDataMapper(ident_t *Loc, DeviceTy &Device, void *ArgBase, void *Arg,
531531
int64_t ArgSize, int64_t ArgType, map_var_info_t ArgNames,
532532
void *ArgMapper, AsyncInfoTy &AsyncInfo,
533533
TargetDataFuncPtrTy TargetDataFunction) {
534-
TIMESCOPE_WITH_IDENT(Loc);
535534
DP("Calling the mapper function " DPxMOD "\n", DPxPTR(ArgMapper));
536535

537536
// The mapper function fills up Components.
@@ -573,6 +572,7 @@ int targetDataBegin(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
573572
int64_t *ArgTypes, map_var_info_t *ArgNames,
574573
void **ArgMappers, AsyncInfoTy &AsyncInfo,
575574
bool FromMapper) {
575+
TIMESCOPE_WITH_IDENT(Loc);
576576
// process each input.
577577
for (int32_t I = 0; I < ArgNum; ++I) {
578578
// Ignore private variables and arrays - there is no mapping for them.
@@ -1002,7 +1002,6 @@ int targetDataEnd(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
10021002
static int targetDataContiguous(ident_t *Loc, DeviceTy &Device, void *ArgsBase,
10031003
void *HstPtrBegin, int64_t ArgSize,
10041004
int64_t ArgType, AsyncInfoTy &AsyncInfo) {
1005-
TIMESCOPE_WITH_IDENT(Loc);
10061005
TargetPointerResultTy TPR =
10071006
Device.getTgtPtrBegin(HstPtrBegin, ArgSize, /*UpdateRefCount=*/false,
10081007
/*UseHoldRefCount=*/false, /*MustContain=*/true);
@@ -1096,7 +1095,6 @@ static int targetDataNonContiguous(ident_t *Loc, DeviceTy &Device,
10961095
uint64_t Size, int64_t ArgType,
10971096
int CurrentDim, int DimSize, uint64_t Offset,
10981097
AsyncInfoTy &AsyncInfo) {
1099-
TIMESCOPE_WITH_IDENT(Loc);
11001098
int Ret = OFFLOAD_SUCCESS;
11011099
if (CurrentDim < DimSize) {
11021100
for (unsigned int I = 0; I < NonContig[CurrentDim].Count; ++I) {

openmp/libomptarget/src/private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,13 @@ class ExponentialBackoff {
429429
#define TIMESCOPE_WITH_NAME_AND_IDENT(NAME, IDENT) \
430430
SourceInfo SI(IDENT); \
431431
llvm::TimeTraceScope TimeScope(NAME, SI.getProfileLocation())
432+
#define TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, IDENT) \
433+
SourceInfo SI(IDENT); \
434+
llvm::TimeTraceScope TimeScope(__FUNCTION__, SI.getProfileLocation() + RegionTypeMsg)
432435
#else
433436
#define TIMESCOPE()
434437
#define TIMESCOPE_WITH_IDENT(IDENT)
435438
#define TIMESCOPE_WITH_NAME_AND_IDENT(NAME, IDENT)
439+
#define TIMESCOPE_WITH_RTM_AND_IDENT(RegionTypeMsg, IDENT) \
436440

437441
#endif

0 commit comments

Comments
 (0)