From 6ecadbbff15dd918147583676a820445fe8c14f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 22 Mar 2018 19:28:57 +0100 Subject: [PATCH] Begining of real 1D test --- main.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 15b397526..f6e4c4033 100644 --- a/main.cpp +++ b/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) // Compute the number of even integers from 0 to n-1, in parallel. long count = 0; - Kokkos::parallel_reduce(n, [=] (const long i, long& lcount) { + Kokkos::parallel_reduce(n, KOKKOS_LAMBDA(const long i, long& lcount) { lcount += (i % 2) == 0; }, count); @@ -71,7 +71,42 @@ int main(int argc, char *argv[]) count_time = timer.seconds(); std::cout << "Sequential: " << seq_count << ' ' << rang::style::bold << count_time << rang::style::reset << '\n'; + + const int nj=n; + + Kokkos::View<double*> xj("xj", nj); + Kokkos::View<double*> rhoj("rhoj", nj); + + Kokkos::View<double*> uj("uj", nj); + + Kokkos::View<double*> Ej("Ej", nj); + Kokkos::View<double*> ej("ej", nj); + Kokkos::View<double*> pj("pj", nj); + Kokkos::View<double*> Vj("Vj", nj); + Kokkos::View<double*> gammaj("gammaj", nj); + Kokkos::View<double*> cj("cj", nj); + Kokkos::View<double*> mj("mj", nj); + + const int nr=nj+1; + + Kokkos::View<double*> xr("xr", nr); + + const double delta_x = 1./nj; + + timer.reset(); + + Kokkos::parallel_for(nr, KOKKOS_LAMBDA(const int& r){ + xr[r] = r*delta_x; + }); + + count_time = timer.seconds(); + std::cout << " Parallel: " << count << " " << rang::style::bold << count_time << rang::style::reset << '\n'; + + for (int r=0; r<nr; ++r) { + std::cout << xr[r] << '\n'; + } + Kokkos::finalize(); - return (count == seq_count) ? 0 : -1; + return 0; } -- GitLab