VTK-m
2.2
|
A tag specifying client memory allocation. More...
#include <Storage.h>
A tag specifying client memory allocation.
A Storage tag specifies how an ArrayHandle allocates and frees memory. The tag StorageTag___ does not actually exist. Rather, this documentation is provided to describe how array storage objects are specified. Loading the vtkm/cont/Storage.h header will set a default array storage. You can specify the default storage by first setting the VTKM_STORAGE macro. Currently it can only be set to VTKM_STORAGE_BASIC.
User code external to VTK-m is free to make its own StorageTag. This is a good way to get VTK-m to read data directly in and out of arrays from other libraries. However, care should be taken when creating a Storage. One particular problem that is likely is a storage that "constructs" all the items in the array. If done incorrectly, then memory of the array can be incorrectly bound to the wrong processor. If you do provide your own StorageTag, please be diligent in comparing its performance to the StorageTagBasic.
To implement your own StorageTag, you first must create a tag class (an empty struct) defining your tag (i.e. struct VTKM_ALWAYS_EXPORT StorageTagMyAlloc { };). Then provide a partial template specialization of vtkm::cont::internal::Storage for your new tag. Note that because the StorageTag is being used for template specialization, storage tags cannot use inheritance (or, rather, inheritance won't have any effect). You can, however, have a partial template specialization of vtkm::cont::internal::Storage inherit from a different specialization. So, for example, you could not have StorageTagFoo inherit from StorageTagBase, but you could have vtkm::cont::internal::Storage<T, StorageTagFoo> inherit from vtkm::cont::internal::Storage<T, StorageTagBase>.