Skip to content

Commit

Permalink
Add some fixes for host
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich committed Sep 14, 2023
1 parent af017d9 commit f5a954d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions include/ngp_utils/SmartFieldRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,21 @@ class SmartFieldRef<HOST, SCOPE, T>{
is_copy_constructed_(true)
{
if(is_read())
fieldRef_.sync_to_device();
fieldRef_.sync_to_host();
else
fieldRef_.clear_sync_state();
}

// device implementations should only ever execute inside a kokkos::paralle_for
// and hence be captured by a lambda.
// Therefore we only ever need to sync copies that will have been snatched up
// through lambda capture.
// TODO is a copy construction appropriate for host instances?
// ideally we will still be using parallel_for's but there are lots of
// places where we don't yet. It would be nice to make this work with
// the old model as well
//
// maybe something like SPACE=OldHost, change the ctor to take a FieldBase ptr
// AND then remove the copy construction check?
~SmartFieldRef(){
if(is_copy_constructed_ && is_write()){
fieldRef_.modify_on_device();
fieldRef_.modify_on_host();
}
}

Expand Down

0 comments on commit f5a954d

Please sign in to comment.