[Openmp-commits] [PATCH] D86781: [LIBOMPTARGET]Do not try to optimize bases for the next parameters.
Alexey Bataev via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Aug 28 12:50:49 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6aa7228a629d: [LIBOMPTARGET]Do not try to optimize bases for the next parameters. (authored by ABataev).
Herald added a subscriber: danielkiss.
Changed prior to commit:
https://reviews.llvm.org/D86781?vs=288590&id=288680#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86781/new/
https://reviews.llvm.org/D86781
Files:
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/test/mapping/lambda_mapping.cpp
Index: openmp/libomptarget/test/mapping/lambda_mapping.cpp
===================================================================
--- /dev/null
+++ openmp/libomptarget/test/mapping/lambda_mapping.cpp
@@ -0,0 +1,53 @@
+// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+
+#include <iostream>
+
+template <typename LOOP_BODY>
+inline void forall(int Begin, int End, LOOP_BODY LoopBody) {
+#pragma omp target parallel for schedule(static)
+ for (int I = Begin; I < End; ++I) {
+ LoopBody(I);
+ }
+}
+
+#define N (1000)
+
+//
+// Demonstration of the RAJA abstraction using lambdas
+// Requires data mapping onto the target section
+//
+int main() {
+ double A[N], B[N], C[N];
+
+ for (int I = 0; I < N; I++) {
+ A[I] = I + 1;
+ B[I] = -I;
+ C[I] = -9;
+ }
+
+#pragma omp target data map(tofrom : C [0:N]) map(to : A [0:N], B [0:N])
+ {
+ forall(0, N, [&](int I) { C[I] += A[I] + B[I]; });
+ }
+
+ int Fail = 0;
+ for (int I = 0; I < N; I++) {
+ if (C[I] != -8) {
+ std::cout << "Failed at " << I << " with val " << C[I] << std::endl;
+ Fail = 1;
+ }
+ }
+
+ // CHECK: Succeeded
+ if (Fail) {
+ std::cout << "Failed" << std::endl;
+ } else {
+ std::cout << "Succeeded" << std::endl;
+ }
+
+ return 0;
+}
Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -1062,7 +1062,10 @@
TgtBaseOffset = 0;
} else if (ArgTypes[I] & OMP_TGT_MAPTYPE_PRIVATE) {
TgtBaseOffset = (intptr_t)HstPtrBase - (intptr_t)HstPtrBegin;
- const bool IsFirstPrivate = ArgTypes[I] & OMP_TGT_MAPTYPE_TO;
+ // Can be marked for optimization if the next argument(s) do(es) not
+ // depend on this one.
+ const bool IsFirstPrivate =
+ (I >= ArgNum - 1 || !(ArgTypes[I + 1] & OMP_TGT_MAPTYPE_MEMBER_OF));
Ret = PrivateArgumentManager.addArg(HstPtrBegin, ArgSizes[I],
TgtBaseOffset, IsFirstPrivate,
TgtPtrBegin, TgtArgs.size());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86781.288680.patch
Type: text/x-patch
Size: 2427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200828/dce65f1f/attachment.bin>
More information about the Openmp-commits
mailing list