-
Notifications
You must be signed in to change notification settings - Fork 16.2k
[OpenMP][Offload] Continue to update libomptarget debug messages #170425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f63c8e6
[OFFLOAD][LIBOMPTARGET] Add compatibility support; start to update me…
adurang 1305a3e
minor cleanup
adurang 845c5b2
update namespace name
adurang 636d705
Merge branch 'main' into omp_debug
adurang 35f147a
[OFFLOAD][LIBOMPTARGET] More debug messages updated
adurang 77d8bf8
more messages in omptarget.cpp
adurang ce0bfc8
remove leftover function
adurang 8f5eb8d
refactor LambdaHelper
adurang f15c64c
format
adurang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| #include "Utils/ExponentialBackoff.h" | ||
|
|
||
| #include "llvm/Frontend/OpenMP/OMPConstants.h" | ||
| #include "llvm/Support/Format.h" | ||
|
|
||
| #include <cassert> | ||
| #include <cstdint> | ||
|
|
@@ -35,6 +36,7 @@ | |
| #ifdef OMPT_SUPPORT | ||
| using namespace llvm::omp::target::ompt; | ||
| #endif | ||
| using namespace llvm::omp::target::debug; | ||
|
|
||
| // If offload is enabled, ensure that device DeviceID has been initialized. | ||
| // | ||
|
|
@@ -49,25 +51,25 @@ using namespace llvm::omp::target::ompt; | |
| // This step might be skipped if offload is disabled. | ||
| bool checkDevice(int64_t &DeviceID, ident_t *Loc) { | ||
| if (OffloadPolicy::get(*PM).Kind == OffloadPolicy::DISABLED) { | ||
| DP("Offload is disabled\n"); | ||
| ODBG(ODT_Device) << "Offload is disabled"; | ||
| return true; | ||
| } | ||
|
|
||
| if (DeviceID == OFFLOAD_DEVICE_DEFAULT) { | ||
| DeviceID = omp_get_default_device(); | ||
| DP("Use default device id %" PRId64 "\n", DeviceID); | ||
| ODBG(ODT_Device) << "Use default device id " << DeviceID; | ||
| } | ||
|
|
||
| // Proposed behavior for OpenMP 5.2 in OpenMP spec github issue 2669. | ||
| if (omp_get_num_devices() == 0) { | ||
| DP("omp_get_num_devices() == 0 but offload is manadatory\n"); | ||
| ODBG(ODT_Device) << "omp_get_num_devices() == 0 but offload is manadatory"; | ||
| handleTargetOutcome(false, Loc); | ||
| return true; | ||
| } | ||
|
|
||
| if (DeviceID == omp_get_initial_device()) { | ||
| DP("Device is host (%" PRId64 "), returning as if offload is disabled\n", | ||
| DeviceID); | ||
| ODBG(ODT_Device) << "Device is host (" << DeviceID | ||
| << "), returning as if offload is disabled"; | ||
| return true; | ||
| } | ||
| return false; | ||
|
|
@@ -123,25 +125,25 @@ targetData(ident_t *Loc, int64_t DeviceId, int32_t ArgNum, void **ArgsBase, | |
| TIMESCOPE_WITH_DETAILS_AND_IDENT("Runtime: Data Copy", | ||
| "NumArgs=" + std::to_string(ArgNum), Loc); | ||
|
|
||
| DP("Entering data %s region for device %" PRId64 " with %d mappings\n", | ||
| RegionName, DeviceId, ArgNum); | ||
| ODBG(ODT_Interface) << "Entering data " << RegionName << " region for device " | ||
| << DeviceId << " with " << ArgNum << " mappings"; | ||
|
|
||
| if (checkDevice(DeviceId, Loc)) { | ||
| DP("Not offloading to device %" PRId64 "\n", DeviceId); | ||
| ODBG(ODT_Interface) << "Not offloading to device " << DeviceId; | ||
| return; | ||
| } | ||
|
|
||
| if (getInfoLevel() & OMP_INFOTYPE_KERNEL_ARGS) | ||
| printKernelArguments(Loc, DeviceId, ArgNum, ArgSizes, ArgTypes, ArgNames, | ||
| RegionTypeMsg); | ||
| #ifdef OMPTARGET_DEBUG | ||
| for (int I = 0; I < ArgNum; ++I) { | ||
| DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||
| ", Type=0x%" PRIx64 ", Name=%s\n", | ||
| I, DPxPTR(ArgsBase[I]), DPxPTR(Args[I]), ArgSizes[I], ArgTypes[I], | ||
| (ArgNames) ? getNameFromMapping(ArgNames[I]).c_str() : "unknown"); | ||
| } | ||
| #endif | ||
| ODBG_OS(ODT_Kernel, [&](llvm::raw_ostream &Os) { | ||
| for (int I = 0; I < ArgNum; ++I) { | ||
| Os << "Entry " << llvm::format_decimal(I, 2) << ": Base=" << ArgsBase[I] | ||
| << ", Begin=" << Args[I] << ", Size=" << ArgSizes[I] | ||
| << ", Type=" << llvm::format_hex(ArgTypes[I], 8) << ", Name=" | ||
| << ((ArgNames) ? getNameFromMapping(ArgNames[I]) : "unknown") << "\n"; | ||
| } | ||
| }); | ||
|
|
||
| auto DeviceOrErr = PM->getDevice(DeviceId); | ||
| if (!DeviceOrErr) | ||
|
|
@@ -274,7 +276,7 @@ static KernelArgsTy *upgradeKernelArgs(KernelArgsTy *KernelArgs, | |
| KernelArgsTy &LocalKernelArgs, | ||
| int32_t NumTeams, int32_t ThreadLimit) { | ||
| if (KernelArgs->Version > OMP_KERNEL_ARG_VERSION) | ||
| DP("Unexpected ABI version: %u\n", KernelArgs->Version); | ||
| ODBG(ODT_Interface) << "Unexpected ABI version: " << KernelArgs->Version; | ||
|
|
||
| uint32_t UpgradedVersion = KernelArgs->Version; | ||
| if (KernelArgs->Version < OMP_KERNEL_ARG_VERSION) { | ||
|
|
@@ -326,12 +328,11 @@ static inline int targetKernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams, | |
| assert(PM && "Runtime not initialized"); | ||
| static_assert(std::is_convertible_v<TargetAsyncInfoTy &, AsyncInfoTy &>, | ||
| "Target AsyncInfoTy must be convertible to AsyncInfoTy."); | ||
| DP("Entering target region for device %" PRId64 " with entry point " DPxMOD | ||
| "\n", | ||
| DeviceId, DPxPTR(HostPtr)); | ||
| ODBG(ODT_Interface) << "Entering target region for device " << DeviceId | ||
| << " with entry point " << HostPtr; | ||
|
|
||
| if (checkDevice(DeviceId, Loc)) { | ||
| DP("Not offloading to device %" PRId64 "\n", DeviceId); | ||
| ODBG(ODT_Interface) << "Not offloading to device " << DeviceId; | ||
| return OMP_TGT_FAIL; | ||
| } | ||
|
|
||
|
|
@@ -354,17 +355,21 @@ static inline int targetKernel(ident_t *Loc, int64_t DeviceId, int32_t NumTeams, | |
| printKernelArguments(Loc, DeviceId, KernelArgs->NumArgs, | ||
| KernelArgs->ArgSizes, KernelArgs->ArgTypes, | ||
| KernelArgs->ArgNames, "Entering OpenMP kernel"); | ||
| #ifdef OMPTARGET_DEBUG | ||
| for (uint32_t I = 0; I < KernelArgs->NumArgs; ++I) { | ||
| DP("Entry %2d: Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||
| ", Type=0x%" PRIx64 ", Name=%s\n", | ||
| I, DPxPTR(KernelArgs->ArgBasePtrs[I]), DPxPTR(KernelArgs->ArgPtrs[I]), | ||
| KernelArgs->ArgSizes[I], KernelArgs->ArgTypes[I], | ||
| (KernelArgs->ArgNames) | ||
| ? getNameFromMapping(KernelArgs->ArgNames[I]).c_str() | ||
| : "unknown"); | ||
| } | ||
| #endif | ||
|
|
||
| ODBG_OS(ODT_Kernel, [&](llvm::raw_ostream &Os) { | ||
| for (uint32_t I = 0; I < KernelArgs->NumArgs; ++I) { | ||
| Os << "Entry " << llvm::format_decimal(I, 2) | ||
| << " Base=" << KernelArgs->ArgBasePtrs[I] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing ":" before Base=. It's causing offloading/target_map_for_member_data.cpp to fail.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handled in #172377. |
||
| << ", Begin=" << KernelArgs->ArgPtrs[I] | ||
| << ", Size=" << KernelArgs->ArgSizes[I] | ||
| << ", Type=" << llvm::format_hex(KernelArgs->ArgTypes[I], 8) | ||
| << ", Name=" | ||
| << (KernelArgs->ArgNames | ||
| ? getNameFromMapping(KernelArgs->ArgNames[I]).c_str() | ||
| : "unknown") | ||
| << "\n"; | ||
| } | ||
| }); | ||
|
|
||
| auto DeviceOrErr = PM->getDevice(DeviceId); | ||
| if (!DeviceOrErr) | ||
|
|
@@ -463,7 +468,7 @@ EXTERN int __tgt_target_kernel_replay(ident_t *Loc, int64_t DeviceId, | |
| assert(PM && "Runtime not initialized"); | ||
| OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0))); | ||
| if (checkDevice(DeviceId, Loc)) { | ||
| DP("Not offloading to device %" PRId64 "\n", DeviceId); | ||
| ODBG(ODT_Interface) << "Not offloading to device " << DeviceId; | ||
| return OMP_TGT_FAIL; | ||
| } | ||
| auto DeviceOrErr = PM->getDevice(DeviceId); | ||
|
|
@@ -491,20 +496,20 @@ EXTERN int __tgt_target_kernel_replay(ident_t *Loc, int64_t DeviceId, | |
| EXTERN int64_t __tgt_mapper_num_components(void *RtMapperHandle) { | ||
| auto *MapperComponentsPtr = (struct MapperComponentsTy *)RtMapperHandle; | ||
| int64_t Size = MapperComponentsPtr->Components.size(); | ||
| DP("__tgt_mapper_num_components(Handle=" DPxMOD ") returns %" PRId64 "\n", | ||
| DPxPTR(RtMapperHandle), Size); | ||
| ODBG(ODT_Interface) << "__tgt_mapper_num_components(Handle=" << RtMapperHandle | ||
| << ") returns " << Size; | ||
| return Size; | ||
| } | ||
|
|
||
| // Push back one component for a user-defined mapper. | ||
| EXTERN void __tgt_push_mapper_component(void *RtMapperHandle, void *Base, | ||
| void *Begin, int64_t Size, int64_t Type, | ||
| void *Name) { | ||
| DP("__tgt_push_mapper_component(Handle=" DPxMOD | ||
| ") adds an entry (Base=" DPxMOD ", Begin=" DPxMOD ", Size=%" PRId64 | ||
| ", Type=0x%" PRIx64 ", Name=%s).\n", | ||
| DPxPTR(RtMapperHandle), DPxPTR(Base), DPxPTR(Begin), Size, Type, | ||
| (Name) ? getNameFromMapping(Name).c_str() : "unknown"); | ||
| ODBG(ODT_Interface) << "__tgt_push_mapper_component(Handle=" << RtMapperHandle | ||
| << ") adds an entry (Base=" << Base << ", Begin=" << Begin | ||
| << ", Size=" << Size | ||
| << ", Type=" << llvm::format_hex(Type, 8) << ", Name=" | ||
| << ((Name) ? getNameFromMapping(Name) : "unknown") << ")"; | ||
| auto *MapperComponentsPtr = (struct MapperComponentsTy *)RtMapperHandle; | ||
| MapperComponentsPtr->Components.push_back( | ||
| MapComponentInfoTy(Base, Begin, Size, Type, Name)); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.