Template Class MemoryUtils

Class Documentation

template<class Policy>
class MemoryUtils

Provides basic memory allocation, free and copy functions.

This class provides abstractions for memory management functions for different GPU programming models.

Author

Slaven Peles peless@ornl.gov

Template Parameters:

Policy – - Memory management policy (vendor specific)

Public Functions

template<typename I, typename T>
inline int allocateArrayOnHost(T **v, I n)

Methods implemented here are always needed

template<typename I, typename T>
inline int copyArrayHostToHost(T *dst, const T *src, I n)

Copy an array from HOST to HOST.

Trivially copyable types (plain scalars, etc.) are copied with a byte-wise memcpy. Types that are not trivially copyable (e.g. a type owning a heap-allocated data structure) would have that structure corrupted by a byte-wise copy, so those are copied element-by-element using the type’s own copy assignment instead.

template<typename I, typename T>
inline int setZeroArrayOnHost(T *v, I n)

Set an array on HOST to zero.

Trivially copyable types are zeroed with a byte-wise memset. Types that are not trivially copyable would have their internal state corrupted by a byte-wise zeroing, so those are reset to a value-initialized (default-constructed) state element-by-element instead.