SparseLibrary  Version 1.6.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RDScheme< T, DS > Class Template Reference

Full parallel row-distributed SpMV, based on CSB (Morton curve + Cilk) and PThreads. More...

#include <RDScheme.hpp>

Inheritance diagram for RDScheme< T, DS >:
Inheritance graph
[legend]
Collaboration diagram for RDScheme< T, DS >:
Collaboration graph
[legend]

Public Member Functions

 RDScheme (const std::string file, T zero)
 Base constructor. More...
 
 RDScheme (std::vector< Triplet< T > > &input, ULI m, ULI n, T zero)
 Base constructor. More...
 
virtual ~RDScheme ()
 Base deconstructor. More...
 
void wait ()
 Lets the calling thread wait for the end of the SpMV multiply.
 
virtual void load (std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero)
 Loads a sparse matrix from an input set of triplets. More...
 
virtual T * mv (const T *x)
 Overloaded mv call; allocates output vector using numa_interleaved. More...
 
virtual void zxa (const T *x, T *z)
 
virtual void zxa (const T *x, T *z, const unsigned long int repeat)
 
virtual void zax (const T *x, T *z)
 See SparseMatrix::zax.
 
virtual void zax (const T *x, T *z, const unsigned long int repeat, const clockid_t clock_id, double *elapsed_time)
 See SparseMatrix::zax.
 
virtual size_t bytesUsed ()
 
virtual void getFirstIndexPair (ULI &i, ULI &j)
 Function disabled for parallel schemes! More...
 
- Public Member Functions inherited from SparseMatrix< T, ULI >
 SparseMatrix ()
 Base constructor. More...
 
 SparseMatrix (const ULInzs, const ULInr, const ULInc, const T zero)
 Base constructor. More...
 
virtual ~SparseMatrix ()
 Base deconstructor. More...
 
void loadFromFile (const std::string file, const T zero=0)
 Function which loads a matrix from a matrix market file. More...
 
virtual unsigned long int m ()
 Queries the number of rows this matrix contains. More...
 
virtual unsigned long int n ()
 Queries the number of columns this matrix contains. More...
 
virtual unsigned long int nzs ()
 Queries the number of nonzeroes stored in this matrix. More...
 
virtual void zax (const T *__restrict__ x, T *__restrict__ z)=0
 In-place z=Ax function. More...
 
virtual void zxa (const T *__restrict__ x, T *__restrict__ z)=0
 In-place z=xA function. More...
 
- Public Member Functions inherited from Matrix< T >
 Matrix ()
 Base constructor. More...
 
virtual ~Matrix ()
 Base deconstructor. More...
 
virtual void zax (const T *__restrict__ x, T *__restrict__ z, const size_t k, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zax kernel multiple times successively, while timing the duration of the operation. More...
 
template<size_t k>
void ZaX (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
 In-place Z=AX function, where A is m x n, Z = m x k, and X is n x k. More...
 
template<size_t k>
void ZXa (const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
 In-place Z=XA function, where A is m x n, Z = k x n, and X is k x m. More...
 
virtual void zxa (const T *__restrict__ x, T *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL)
 Wrapper function to call the zxa kernel multiple times successively, while timing the operation duration. More...
 

Static Public Member Functions

static void end (pthread_mutex_t *mutex, pthread_cond_t *cond, size_t *sync, const size_t P)
 End synchronisation code. More...
 
static void synchronise (pthread_mutex_t *mutex, pthread_cond_t *cond, size_t *sync, const size_t P)
 Synchronises all threads. More...
 
static void * thread (void *data)
 SPMD code for each thread involved with parallel SpMV multiplication. More...
 
static void collectY (RDScheme_shared_data< T > *shared)
 Reduces a distributed output vector set into a single contiguous output vector at process 0. More...
 

Protected Attributes

pthread_t * threads
 p_threads associated to this data strcuture
 
RDScheme_shared_data< T > * thread_data
 array of initial thread data
 
pthread_mutex_t mutex
 Stop/continue mechanism: mutex.
 
pthread_cond_t cond
 Stop/continue mechanism: condition.
 
pthread_mutex_t end_mutex
 Wait for end mechanism: mutex.
 
pthread_cond_t end_cond
 Wait for end mechanism: condition.
 
size_t sync
 Used for synchronising threads.
 
size_t end_sync
 Used for construction end signal.
 
- Protected Attributes inherited from SparseMatrix< T, ULI >
ULI nor
 Number of rows. More...
 
ULI noc
 Number of columns.
 
ULI nnz
 Number of non-zeros. More...
 

Static Protected Attributes

static size_t P = 0
 Number of threads to fire up.
 
static const T * input = NULL
 Input vector.
 
static T * output = NULL
 Output vector.
 
static clockid_t global_clock_id = 0
 Clock type used for thread-local timing.
 

Additional Inherited Members

- Public Attributes inherited from SparseMatrix< T, ULI >
zero_element
 The element considered to be zero. More...
 

Detailed Description

template<typename T, typename DS>
class RDScheme< T, DS >

Full parallel row-distributed SpMV, based on CSB (Morton curve + Cilk) and PThreads.

Inspired by Aydin & Gilbert's CSB, and comments by Patrick Amestoy on the BICRS Hilbert scheme.

Constructor & Destructor Documentation

template<typename T, typename DS >
RDScheme< T, DS >::RDScheme ( const std::string  file,
zero 
)
inline

Base constructor.

Reads input from file.

References SparseMatrix< T, ULI >::loadFromFile().

template<typename T, typename DS >
RDScheme< T, DS >::RDScheme ( std::vector< Triplet< T > > &  input,
ULI  m,
ULI  n,
zero 
)
inline

Base constructor.

Reads input from a set of triplets.

References RDScheme< T, DS >::input, and RDScheme< T, DS >::load().

template<typename T, typename DS >
virtual RDScheme< T, DS >::~RDScheme ( )
inlinevirtual

Member Function Documentation

template<typename T, typename DS >
virtual size_t RDScheme< T, DS >::bytesUsed ( )
inlinevirtual
Returns
The memory usage of this data structure (summed over all threads).

Implements Matrix< T >.

References RDScheme< T, DS >::P, and RDScheme< T, DS >::thread_data.

template<typename T, typename DS >
static void RDScheme< T, DS >::collectY ( RDScheme_shared_data< T > *  shared)
inlinestatic

Reduces a distributed output vector set into a single contiguous output vector at process 0.

Parameters
sharedWhich set of output vectors to reduce.

References RDScheme_shared_data< T >::id, RDScheme_shared_data< T >::local_y, RDScheme_shared_data< T >::output_vector_offset, and RDScheme_shared_data< T >::output_vector_size.

Referenced by RDScheme< T, DS >::thread().

template<typename T, typename DS >
static void RDScheme< T, DS >::end ( pthread_mutex_t *  mutex,
pthread_cond_t *  cond,
size_t *  sync,
const size_t  P 
)
inlinestatic

End synchronisation code.

Referenced by RDScheme< T, DS >::thread().

template<typename T, typename DS >
virtual void RDScheme< T, DS >::getFirstIndexPair ( ULI &  i,
ULI &  j 
)
inlinevirtual

Function disabled for parallel schemes!

See also
SparseMatrix::getFirstIndexPair

Implements SparseMatrix< T, ULI >.

template<typename T, typename DS >
virtual void RDScheme< T, DS >::load ( std::vector< Triplet< T > > &  input,
const ULI  m,
const ULI  n,
const T  zero 
)
inlinevirtual
template<typename T, typename DS >
virtual T* RDScheme< T, DS >::mv ( const T *  x)
inlinevirtual

Overloaded mv call; allocates output vector using numa_interleaved.

Reimplemented from SparseMatrix< T, ULI >.

References SparseMatrix< T, ULI >::nor, RDScheme< T, DS >::zax(), and SparseMatrix< T, ULI >::zero_element.

template<typename T, typename DS >
static void RDScheme< T, DS >::synchronise ( pthread_mutex_t *  mutex,
pthread_cond_t *  cond,
size_t *  sync,
const size_t  P 
)
inlinestatic

Synchronises all threads.

Referenced by RDScheme< T, DS >::thread().

template<typename T, typename DS >
static void* RDScheme< T, DS >::thread ( void *  data)
inlinestatic
template<typename T, typename DS >
virtual void RDScheme< T, DS >::zxa ( const T *  x,
T *  z 
)
inlinevirtual
template<typename T, typename DS >
virtual void RDScheme< T, DS >::zxa ( const T *  x,
T *  z,
const unsigned long int  repeat 
)
inlinevirtual

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