Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalanx: fix exec space instance init for UVM=ON #12054

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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