53 const char newLabel[],
54 const size_t tooBigFactor = 2,
55 const bool needFenceBeforeRealloc =
true)
58 typedef Kokkos::DualView<ValueType*, DeviceType> dual_view_type;
59 typedef Kokkos::pair<size_t, size_t> range_type;
65 const size_t curSize =
static_cast<size_t> (dv.extent (0));
66 if (curSize == newSize) {
69 else if (curSize < newSize) {
70 if (needFenceBeforeRealloc) {
73 dv = dual_view_type ();
75 dv = dual_view_type (curSize == 0 ? newLabel : dv.view_device().label (), newSize);
80 if (needFenceBeforeRealloc) {
84 dv = dual_view_type (curSize == 0 ? newLabel : dv.view_device().label (), 0);
90 else if (curSize / newSize >= tooBigFactor) {
93 if (needFenceBeforeRealloc) {
96 dv = dual_view_type ();
98 dv = dual_view_type (curSize == 0 ? newLabel : dv.view_device().label (), newSize);
102 auto d_view = Kokkos::subview (dv.view_device(), range_type (0, newSize));
103 auto h_view = Kokkos::subview (dv.view_host(), range_type (0, newSize));
104 dv = Kokkos::DualView<ValueType*, DeviceType>(d_view, h_view);
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.