[Openmp-commits] [llvm] [openmp] [OpenMP] Add OpenMP extension API to dump mapping tables (PR #85381)
via Openmp-commits
openmp-commits at lists.llvm.org
Fri Mar 15 03:53:00 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff d0117b71193787ebfd92d96a4ecc261f0aaeac86 9899af770f4801853a6342fc8cf3a2d4123d2a83 -- openmp/libomptarget/test/api/ompx_dump_mapping_tables.cpp openmp/libomptarget/include/OpenMP/Mapping.h openmp/libomptarget/include/Shared/Debug.h openmp/libomptarget/include/omptarget.h openmp/libomptarget/src/OpenMP/API.cpp openmp/libomptarget/src/OpenMP/Mapping.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/openmp/libomptarget/include/OpenMP/Mapping.h b/openmp/libomptarget/include/OpenMP/Mapping.h
index e77f2bc234..b9f5c16582 100644
--- a/openmp/libomptarget/include/OpenMP/Mapping.h
+++ b/openmp/libomptarget/include/OpenMP/Mapping.h
@@ -424,7 +424,8 @@ typedef int (*TargetDataFuncPtrTy)(ident_t *, DeviceTy &, int32_t, void **,
map_var_info_t *, void **, AsyncInfoTy &,
bool);
-void dumpTargetPointerMappings(const ident_t *Loc, DeviceTy &Device, bool toStdOut = false);
+void dumpTargetPointerMappings(const ident_t *Loc, DeviceTy &Device,
+ bool toStdOut = false);
int targetDataBegin(ident_t *Loc, DeviceTy &Device, int32_t ArgNum,
void **ArgsBase, void **Args, int64_t *ArgSizes,
diff --git a/openmp/libomptarget/include/Shared/Debug.h b/openmp/libomptarget/include/Shared/Debug.h
index ede5f845c2..495f291958 100644
--- a/openmp/libomptarget/include/Shared/Debug.h
+++ b/openmp/libomptarget/include/Shared/Debug.h
@@ -136,13 +136,13 @@ inline uint32_t getDebugLevel() {
} while (0)
/// Print a generic information string used if LIBOMPTARGET_INFO=1
-#define INFO_MESSAGE(_num, ...) INFO_MESSAGE_TO(stderr, _num, __VA_ARGS__)
+#define INFO_MESSAGE(_num, ...) INFO_MESSAGE_TO(stderr, _num, __VA_ARGS__)
-#define INFO_MESSAGE_TO(_stdDst, _num, ...) \
- do { \
- fprintf(_stdDst, GETNAME(TARGET_NAME) " device %d info: ", (int)_num); \
- fprintf(_stdDst, __VA_ARGS__); \
- } while (0)
+#define INFO_MESSAGE_TO(_stdDst, _num, ...) \
+ do { \
+ fprintf(_stdDst, GETNAME(TARGET_NAME) " device %d info: ", (int)_num); \
+ fprintf(_stdDst, __VA_ARGS__); \
+ } while (0)
// Debugging messages
#ifdef OMPTARGET_DEBUG
@@ -198,5 +198,4 @@ inline uint32_t getDebugLevel() {
} \
} while (false)
-
#endif // OMPTARGET_SHARED_DEBUG_H
diff --git a/openmp/libomptarget/src/OpenMP/API.cpp b/openmp/libomptarget/src/OpenMP/API.cpp
index 91104511e1..c85f9868e3 100644
--- a/openmp/libomptarget/src/OpenMP/API.cpp
+++ b/openmp/libomptarget/src/OpenMP/API.cpp
@@ -16,8 +16,8 @@
#include "rtl.h"
#include "OpenMP/InternalTypes.h"
-#include "OpenMP/OMPT/Interface.h"
#include "OpenMP/Mapping.h"
+#include "OpenMP/OMPT/Interface.h"
#include "OpenMP/omp.h"
#include "Shared/Profile.h"
diff --git a/openmp/libomptarget/src/OpenMP/Mapping.cpp b/openmp/libomptarget/src/OpenMP/Mapping.cpp
index 90a914800d..d8ad5d8cac 100644
--- a/openmp/libomptarget/src/OpenMP/Mapping.cpp
+++ b/openmp/libomptarget/src/OpenMP/Mapping.cpp
@@ -16,30 +16,33 @@
#include "device.h"
/// Dump a table of all the host-target pointer pairs on failure
-void dumpTargetPointerMappings(const ident_t *Loc, DeviceTy &Device, bool toStdOut) {
+void dumpTargetPointerMappings(const ident_t *Loc, DeviceTy &Device,
+ bool toStdOut) {
MappingInfoTy::HDTTMapAccessorTy HDTTMap =
Device.getMappingInfo().HostDataToTargetMap.getExclusiveAccessor();
if (HDTTMap->empty()) {
- DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID, "OpenMP Host-Device pointer mappings table empty\n");
+ DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,
+ "OpenMP Host-Device pointer mappings table empty\n");
return;
}
SourceInfo Kernel(Loc);
DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,
- "OpenMP Host-Device pointer mappings after block at %s:%d:%d:\n",
- Kernel.getFilename(), Kernel.getLine(), Kernel.getColumn());
- DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID, "%-18s %-18s %s %s %s %s\n",
- "Host Ptr", "Target Ptr", "Size (B)", "DynRefCount", "HoldRefCount",
- "Declaration");
+ "OpenMP Host-Device pointer mappings after block at %s:%d:%d:\n",
+ Kernel.getFilename(), Kernel.getLine(), Kernel.getColumn());
+ DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,
+ "%-18s %-18s %s %s %s %s\n", "Host Ptr", "Target Ptr", "Size (B)",
+ "DynRefCount", "HoldRefCount", "Declaration");
for (const auto &It : *HDTTMap) {
HostDataToTargetTy &HDTT = *It.HDTT;
SourceInfo Info(HDTT.HstPtrName);
DUMP_INFO(toStdOut, OMP_INFOTYPE_ALL, Device.DeviceID,
- DPxMOD " " DPxMOD " %-8" PRIuPTR " %-11s %-12s %s at %s:%d:%d\n",
- DPxPTR(HDTT.HstPtrBegin), DPxPTR(HDTT.TgtPtrBegin),
- HDTT.HstPtrEnd - HDTT.HstPtrBegin, HDTT.dynRefCountToStr().c_str(),
- HDTT.holdRefCountToStr().c_str(), Info.getName(), Info.getFilename(),
- Info.getLine(), Info.getColumn());
+ DPxMOD " " DPxMOD " %-8" PRIuPTR " %-11s %-12s %s at %s:%d:%d\n",
+ DPxPTR(HDTT.HstPtrBegin), DPxPTR(HDTT.TgtPtrBegin),
+ HDTT.HstPtrEnd - HDTT.HstPtrBegin,
+ HDTT.dynRefCountToStr().c_str(), HDTT.holdRefCountToStr().c_str(),
+ Info.getName(), Info.getFilename(), Info.getLine(),
+ Info.getColumn());
}
}
diff --git a/openmp/libomptarget/test/api/ompx_dump_mapping_tables.cpp b/openmp/libomptarget/test/api/ompx_dump_mapping_tables.cpp
index c24eaf58ac..b8c9cb292a 100644
--- a/openmp/libomptarget/test/api/ompx_dump_mapping_tables.cpp
+++ b/openmp/libomptarget/test/api/ompx_dump_mapping_tables.cpp
@@ -1,4 +1,4 @@
-// RUN: %libomptarget-compilexx-run-and-check-generic
+// RUN: %libomptarget-compilexx-run-and-check-generic
#include <cstdio>
#include <omp.h>
@@ -9,29 +9,31 @@ int main() {
int *a = new int[N]; // mapped and released from device 0
int *b = new int[N]; // mapped to device 2
- // CHECK: Mapping tables after target enter data:
- // CHECK-NEXT: omptarget device 0 info: OpenMP Host-Device pointer mappings after block
- // CHECK-NEXT: omptarget device 0 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
- // CHECK-NEXT: omptarget device 0 info: {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}}
- // CHECK-NEXT: omptarget device 1 info: OpenMP Host-Device pointer mappings table empty
- // CHECK-NEXT: omptarget device 2 info: OpenMP Host-Device pointer mappings after block
- // CHECK-NEXT: omptarget device 2 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
- // CHECK-NEXT: omptarget device 2 info: {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}}
- #pragma omp target enter data device(0) map(to:a[:N])
- #pragma omp target enter data device(2) map(to:b[:N])
+// CHECK: Mapping tables after target enter data:
+// CHECK-NEXT: omptarget device 0 info: OpenMP Host-Device pointer mappings
+// after block CHECK-NEXT: omptarget device 0 info: Host Ptr Target Ptr Size (B)
+// DynRefCount HoldRefCount Declaration CHECK-NEXT: omptarget device 0 info:
+// {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}} CHECK-NEXT: omptarget device 1
+// info: OpenMP Host-Device pointer mappings table empty CHECK-NEXT: omptarget
+// device 2 info: OpenMP Host-Device pointer mappings after block CHECK-NEXT:
+// omptarget device 2 info: Host Ptr Target Ptr Size (B) DynRefCount
+// HoldRefCount Declaration CHECK-NEXT: omptarget device 2 info:
+// {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}}
+#pragma omp target enter data device(0) map(to : a[ : N])
+#pragma omp target enter data device(2) map(to : b[ : N])
printf("Mapping tables after target enter data:\n");
ompx_dump_mapping_tables();
- // CHECK: Mapping tables after target exit data for a:
- // CHECK-NEXT: omptarget device 0 info: OpenMP Host-Device pointer mappings table empty
- // CHECK-NEXT: omptarget device 1 info: OpenMP Host-Device pointer mappings table empty
- // CHECK-NEXT: omptarget device 2 info: OpenMP Host-Device pointer mappings after block
- // CHECK-NEXT: omptarget device 2 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
- // CHECK-NEXT: omptarget device 2 info: {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}}
- #pragma omp target exit data device(0) map(release:a[:N])
+// CHECK: Mapping tables after target exit data for a:
+// CHECK-NEXT: omptarget device 0 info: OpenMP Host-Device pointer mappings
+// table empty CHECK-NEXT: omptarget device 1 info: OpenMP Host-Device pointer
+// mappings table empty CHECK-NEXT: omptarget device 2 info: OpenMP Host-Device
+// pointer mappings after block CHECK-NEXT: omptarget device 2 info: Host Ptr
+// Target Ptr Size (B) DynRefCount HoldRefCount Declaration CHECK-NEXT:
+// omptarget device 2 info: {{(0x[0-9a-f]{16})}} {{(0x[0-9a-f]{16})}}
+#pragma omp target exit data device(0) map(release : a[ : N])
printf("\nMapping tables after target exit data for a:\n");
ompx_dump_mapping_tables();
return 0;
}
-
``````````
</details>
https://github.com/llvm/llvm-project/pull/85381
More information about the Openmp-commits
mailing list