Skip to content

Commit

Permalink
Merge Pull Request #12054 from rppawlo/Trilinos/phalanx-fix-uvm-on-fo…
Browse files Browse the repository at this point in the history
…r-exec-space-instance-init

Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Phalanx: fix exec space instance init for UVM=ON
PR Author: rppawlo
  • Loading branch information
trilinos-autotester authored Jul 14, 2023
2 parents 96adca4 + 16cf34c commit 4968200
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/phalanx/src/Phalanx_KokkosViewOfViews.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ namespace PHX {
/// fence. Be sure to manually fence as needed.
template<typename ExecSpace,typename... Extents>
ViewOfViews3(const ExecSpace& exec_space,const std::string name,Extents... extents)
: view_host_(Kokkos::view_alloc(Kokkos::HostSpace(),name),extents...),
: view_host_(Kokkos::view_alloc(typename OuterViewType::HostMirror::execution_space(),name),extents...),
view_device_(Kokkos::view_alloc(exec_space,name),extents...),
device_view_is_synced_(false),
is_initialized_(true),
use_count_(0),
check_use_count_(true)
{
view_host_unmanaged_ = Kokkos::create_mirror_view(Kokkos::HostSpace(),view_device_);
view_host_unmanaged_ = Kokkos::create_mirror_view(Kokkos::view_alloc(typename OuterViewType::HostMirror::execution_space()),view_device_);
use_count_ = view_device_.impl_track().use_count();
}

Expand Down Expand Up @@ -390,9 +390,9 @@ namespace PHX {
template<typename ExecSpace,typename... Extents>
void initialize(const ExecSpace& exec_space,const std::string name,Extents... extents)
{
view_host_ = typename OuterViewType::HostMirror(Kokkos::view_alloc(Kokkos::HostSpace(),name),extents...);
view_host_ = typename OuterViewType::HostMirror(Kokkos::view_alloc(typename OuterViewType::HostMirror::execution_space(),name),extents...);
view_device_ = OuterViewType(Kokkos::view_alloc(exec_space,name),extents...);
view_host_unmanaged_ = Kokkos::create_mirror_view(Kokkos::HostSpace(),view_device_);
view_host_unmanaged_ = Kokkos::create_mirror_view(Kokkos::view_alloc(typename OuterViewType::HostMirror::execution_space()),view_device_);
device_view_is_synced_ = false;
is_initialized_ = true;
use_count_ = view_device_.impl_track().use_count();
Expand Down
12 changes: 12 additions & 0 deletions packages/phalanx/test/ViewOfViews/tPhalanxViewOfViews.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ TEUCHOS_UNIT_TEST(PhalanxViewOfViews,ViewOfView3_UserStreamCtor) {

TEST_ASSERT(v_of_v.isInitialized());

// For UVM=ON builds, need to fence here. The outer views are
// being accessed before the initialization is completed on
// device. The failure only shows up if you overload the cuda card
// with multiple tests to slow down the initialization.
streams[3].fence(); // PHX_UVM_ON_FENCE

v_of_v.addView(a,0,0);
v_of_v.addView(b,0,1);
v_of_v.addView(c,1,0);
Expand Down Expand Up @@ -363,6 +369,12 @@ TEUCHOS_UNIT_TEST(PhalanxViewOfViews,ViewOfView3_UserStreamInitialize) {
v_of_v.initialize(streams[3],"outer host",2,2);
TEST_ASSERT(v_of_v.isInitialized());

// For UVM=ON builds, need to fence here. The outer views are
// being accessed before the initialization is completed on
// device. The failure only shows up if you overload the cuda card
// with multiple tests to slow down the initialization.
streams[3].fence(); // PHX_UVM_ON_FENCE

v_of_v.addView(a,0,0);
v_of_v.addView(b,0,1);
v_of_v.addView(c,1,0);
Expand Down

0 comments on commit 4968200

Please sign in to comment.