Skip to content

Commit

Permalink
Merge pull request #59 from pkestene/fix/examples
Browse files Browse the repository at this point in the history
Fix examples 02 and 03 for CUDA backend
  • Loading branch information
dalg24 authored Aug 30, 2022
2 parents 003852c + f6de13f commit 23d6aff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions examples/02-axpy-dualview/axpy-dualview-cxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ extern "C" {
y.template sync<typename view_type::execution_space>();
x.template sync<typename view_type::execution_space>();

double d_alpha = *alpha;
Kokkos::parallel_for( "axpy", y.extent(0), KOKKOS_LAMBDA( const size_t idx)
{
y.d_view(idx) += *alpha * x.d_view(idx);
y.d_view(idx) += d_alpha * x.d_view(idx);
});

y.template modify<typename view_type::execution_space>();
x.template modify<typename view_type::execution_space>();
y.template sync<typename view_type::host_mirror_space>();
Expand All @@ -67,4 +68,4 @@ extern "C" {
}


}
}
8 changes: 6 additions & 2 deletions examples/03-axpy-view/axpy-view-cxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ extern "C" {
view_type y = **v_y;
view_type x = **v_x;

double d_alpha = *alpha;
Kokkos::parallel_for( "axpy", y.extent(0), KOKKOS_LAMBDA( const size_t idx)
{
y(idx) += *alpha * x(idx);
y(idx) += d_alpha * x(idx);
});

// make sure data can be reused on host
Kokkos::fence();

return;
}


}
}

0 comments on commit 23d6aff

Please sign in to comment.