Muesli
 All Classes Namespaces Files Functions Typedefs Enumerations
Public Member Functions | List of all members
msl::LArray< T > Class Template Reference

Class LArray represents a shallow copy of class DArray. More...

#include <larray.h>

Inheritance diagram for msl::LArray< T >:
msl::ArgumentType

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...
 
- Public Member Functions inherited from msl::ArgumentType
virtual ~ArgumentType ()
 Virtual destructor.
 

Detailed Description

template<typename T>
class msl::LArray< T >

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.

Template Parameters
TThe element type.

Constructor & Destructor Documentation

template<typename T>
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.

Parameters
daThe distributed array whose local partition will be accessed.
gpu_distSpecifies 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.

Member Function Documentation

template<typename T>
MSL_USERFUNC T msl::LArray< T >::get ( int  index) const

Returns the element at index index. Uses global indices.

Parameters
indexThe index of the requested element.
Returns
The requested element at index index.
template<typename T>
MSL_USERFUNC int msl::LArray< T >::getSize ( ) const

Returns the number of elements.

Returns
The number of elements.
template<typename T>
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).

Parameters
indexThe index of the requested element.
Returns
The requested element at index index.
template<typename T>
virtual void msl::LArray< T >::update ( )
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.


The documentation for this class was generated from the following file: