| // Unonptimized, we need 24000000 bytes heap |
| // RUN: %libomptarget-compilexx-generic |
| // RUN: env LIBOMPTARGET_HEAP_SIZE=24000000 \ |
| // RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic |
| // RUN: %libomptarget-compileoptxx-run-and-check-generic |
| 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) { |
| // Demonstration of the RAJA abstraction using lambdas |
| // Requires data mapping onto the target section |
| for (int I = 0; I < N; I++) { |
| #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]; }); |
| for (int I = 0; I < N; I++) { |
| std::cout << "Failed at " << I << " with val " << C[I] << std::endl; |
| std::cout << "Failed" << std::endl; |
| std::cout << "Succeeded" << std::endl; |