Skip to content

Commit

Permalink
fixes for using vtk-m algorithms
Browse files Browse the repository at this point in the history
ensure that vtk-m handles have the exact size of their arrays
  • Loading branch information
aumuell committed May 21, 2024
1 parent b8a769e commit 91d3121
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/vistle/core/shm_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ class shm_array: public ShmData {
const uint32_t m_type;
size_t m_size = 0;
size_t m_dim[3] = {0, 1, 1};
#ifdef NO_SHMEM
mutable size_t m_capacity = 0;
#else
size_t m_capacity = 0;
#endif
bool m_exact = std::is_integral<T>::value;
value_type m_min = std::numeric_limits<value_type>::max();
value_type m_max = std::numeric_limits<value_type>::lowest();
Expand Down
9 changes: 9 additions & 0 deletions lib/vistle/core/shm_array_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ template<typename T, class allocator>
const vtkm::cont::ArrayHandle<typename shm_array<T, allocator>::handle_type> &shm_array<T, allocator>::handle() const
{
updateFromHandle(); // required in order to be compatible with ArrayHandleBasic
if (m_size != m_capacity) {
// many vtk-m algorithms check that array sizes are exact
m_handle.Allocate(m_size, vtkm::CopyFlag::On);
m_data = reinterpret_cast<T *>(m_handle.GetWritePointer());
m_capacity = m_size;
}
return m_handle;
}
#else
Expand Down Expand Up @@ -268,6 +274,9 @@ void shm_array<T, allocator>::reserve(const size_t new_capacity)
template<typename T, class allocator>
void shm_array<T, allocator>::reserve_or_shrink(const size_t capacity)
{
if (m_capacity == capacity)
return;

PROF_SCOPE("shm_array::reserve_or_shrink()");
#ifdef NO_SHMEM
updateFromHandle(true);
Expand Down

0 comments on commit 91d3121

Please sign in to comment.