10 #ifndef TPETRA_DETAILS_REALLOCDUALVIEWIFNEEDED_HPP 
   11 #define TPETRA_DETAILS_REALLOCDUALVIEWIFNEEDED_HPP 
   21 #include "Kokkos_DualView.hpp" 
   49 template <
class ValueType, 
class DeviceType>
 
   52                              const char newLabel[],
 
   53                              const size_t tooBigFactor         = 2,
 
   54                              const bool needFenceBeforeRealloc = 
true) {
 
   55   typedef typename DeviceType::execution_space execution_space;
 
   56   typedef Kokkos::DualView<ValueType*, DeviceType> dual_view_type;
 
   57   typedef Kokkos::pair<size_t, size_t> range_type;
 
   63   const size_t curSize = 
static_cast<size_t>(dv.extent(0));
 
   64   if (curSize == newSize) {
 
   66   } 
else if (curSize < newSize) {  
 
   67     if (needFenceBeforeRealloc) {
 
   68       execution_space().fence();  
 
   70     dv = dual_view_type();  
 
   72     dv = dual_view_type(curSize == 0 ? newLabel : dv.view_device().label(), newSize);
 
   76       if (needFenceBeforeRealloc) {
 
   77         execution_space().fence();  
 
   80       dv = dual_view_type(curSize == 0 ? newLabel : dv.view_device().label(), 0);
 
   86     else if (curSize / newSize >= tooBigFactor) {
 
   89       if (needFenceBeforeRealloc) {
 
   90         execution_space().fence();  
 
   92       dv = dual_view_type();  
 
   94       dv = dual_view_type(curSize == 0 ? newLabel : dv.view_device().label(), newSize);
 
   97       auto d_view = Kokkos::subview(dv.view_device(), range_type(0, newSize));
 
   98       auto h_view = Kokkos::subview(dv.view_host(), range_type(0, newSize));
 
   99       dv          = Kokkos::DualView<ValueType*, DeviceType>(d_view, h_view);
 
  106 template <
class ValueType, 
class DeviceType>
 
  108                              const size_t newSize,
 
  109                              const std::string& newLabel,
 
  110                              const size_t tooBigFactor         = 2,
 
  111                              const bool needFenceBeforeRealloc = 
true) {
 
  112   return reallocDualViewIfNeeded<ValueType, DeviceType>(exports, newSize,
 
  115                                                         needFenceBeforeRealloc);
 
  121 #endif  // TPETRA_DETAILS_REALLOCDUALVIEWIFNEEDED_HPP 
Declaration of Tpetra::Details::Profiling, a scope guard for Kokkos Profiling. 
bool reallocDualViewIfNeeded(Kokkos::DualView< ValueType *, DeviceType > &dv, const size_t newSize, const char newLabel[], const size_t tooBigFactor=2, const bool needFenceBeforeRealloc=true)
Reallocate the DualView in/out argument, if needed.