diff --git a/main.cpp b/main.cpp index 15b3975268f76cccbd87da6cc543f696fd406627..f6e4c40334aa49c4738c082961c859677b829df8 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; }