Class LArray represents a shallow copy of class DArray. More...
#include <larray.h>
Public Member Functions | |
LArray (msl::DArray< T > &da, Distribution gpu_dist=Distribution::DIST) | |
Constructor. Gathers all pointers (CPU + GPUs) pointing to a local partition of a given DArray. More... | |
virtual void | update () |
Updates the pointer that is accessed within the get function to point to the correct memory. More... | |
MSL_USERFUNC int | getSize () const |
Returns the number of elements. More... | |
MSL_USERFUNC T | operator[] (int index) const |
Returns the element at index index. Uses local indices. Note that 0 <= index < getSize() must hold (not checked for performance reasons). More... | |
MSL_USERFUNC T | get (int index) const |
Returns the element at index index. Uses global indices. More... | |
![]() | |
virtual | ~ArgumentType () |
Virtual destructor. | |
Class LArray represents a shallow copy of class DArray.
Class LArray represents a shallow copy of class DArray. Instantiations of this class can be added as additional arguments to a user functor in terms of data members. It only stores pointers to the local partition (CPU and GPU partitions) but not the data itself. Therefore, copy construction comes at lower costs compared to copy constructing a DArray which would imply copying of (big) data. This is important because when initializing data members, the copy constructor will be called. The L in LArray stands for Local and indicates that the user functor only has access to the local partition of a DArray.
T | The element type. |
msl::LArray< T >::LArray | ( | msl::DArray< T > & | da, |
Distribution | gpu_dist = Distribution::DIST |
||
) |
Constructor. Gathers all pointers (CPU + GPUs) pointing to a local partition of a given DArray.
da | The distributed array whose local partition will be accessed. |
gpu_dist | Specifies the distribution among GPUs. Default is distributed. May also be copy distributed, in this case the local partition of a distributed array is copy distributed among all GPUs. |
MSL_USERFUNC T msl::LArray< T >::get | ( | int | index | ) | const |
Returns the element at index index. Uses global indices.
index | The index of the requested element. |
MSL_USERFUNC int msl::LArray< T >::getSize | ( | ) | const |
Returns the number of elements.
MSL_USERFUNC T msl::LArray< T >::operator[] | ( | int | index | ) | const |
Returns the element at index index. Uses local indices. Note that 0 <= index < getSize() must hold (not checked for performance reasons).
index | The index of the requested element. |
|
virtual |
Updates the pointer that is accessed within the get function to point to the correct memory.
Updates the pointer that is accessed within the get function to point to the correct memory. When accessed by the CPU, the pointer must point to host main memory, when accessed by GPU i, the pointer must point to device main memory of GPU i.
Implements msl::ArgumentType.