|
SparseLibrary
Version 1.6.0
|
The Beta Hilbert triplet scheme. More...
#include <BetaHilbert.hpp>


Public Member Functions | |
| BetaHilbert (const std::string file, T zero=0, std::vector< unsigned short int > *_p_translate=NULL) | |
| File-based constructor. More... | |
| BetaHilbert (std::vector< Triplet< T > > &input, ULI m, ULI n, T zero=0, std::vector< unsigned short int > *_p_translate=NULL) | |
| COO-based constructor. More... | |
| virtual | ~BetaHilbert () |
| Base deconstructor. More... | |
| void | wait () |
| Callee will Wait for end of SpMV. More... | |
| virtual void | load (std::vector< Triplet< T > > &input, const ULI m, const ULI n, const T zero) |
| Loads from input COO matrix. More... | |
| virtual void | zxa (const T *x, T *z) |
| Computes z=xA in place. More... | |
| virtual void | zxa (const T *x, T *z, const size_t repeat) |
| Computes z=xA in place, a given number of times successively. More... | |
| void | reset () |
| Reset all local output vectors to zero. | |
| virtual T * | mv (const T *x) |
| Overloaded mv call; allocates output vector using numa_interleaved. More... | |
| virtual void | zax (const T *x, T *z) |
| Computes z=Ax in place. More... | |
| virtual void | zax (const T *x, T *z, const size_t repeat, const clockid_t clock_id, double *elapsed_time) |
| Computes z=Ax in place, a given number of times in succession, and measures the time taken. More... | |
| virtual void | getFirstIndexPair (ULI &i, ULI &j) |
| virtual size_t | bytesUsed () |
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 function. More... | |
| static void | synchronise (pthread_mutex_t *mutex, pthread_cond_t *cond, size_t *sync, const size_t P) |
| Thread synchronisation function. More... | |
| static void * | thread (void *data) |
| SPMD code for each thread doing an SpMV. More... | |
| static void | collectY (shared_data< T > *shared) |
| Code that collects a distributed output vector. More... | |
Protected Member Functions | |
| void | set_p_translate (std::vector< unsigned short int > *_p_translate) |
| Sets p_translate to 0..P-1 by default, or equal to the optionally supplied vector. More... | |
Protected Attributes | |
| std::vector< unsigned short int > | p_translate |
| Which processors to pin threads to. | |
| const T * | input |
| Input vector. | |
| T * | output |
| Output vector. | |
| pthread_t * | threads |
| p_threads associated to this data strcuture | |
| 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 clockid_t | global_clock_id = 0 |
| Clock type used for thread-local timing. | |
| static const ULI | max_n = FBICRS< T >::beta_n |
| Given FBICRS, the maximum value for columnwise matrix size. | |
| static const ULI | max_m = FBICRS< T >::beta_m |
| Given FBICRS, the maximum value for the rowwise matrix size, assuming short ints on ICRS at the lower level. | |
Additional Inherited Members | |
Public Attributes inherited from SparseMatrix< T, ULI > | |
| T | zero_element |
| The element considered to be zero. More... | |
The Beta Hilbert triplet scheme.
Full parallel SpMV, based on Blocked Hilbert and PThreads. Inspired by Aydin & Gilbert's CSB, and comments by Patrick Amestoy on the BICRS Hilbert scheme.
|
inline |
File-based constructor.
| file | Filename to read from. |
| zero | Zero element of the sparse matrix. |
| _p_translate | Thread pinning array. |
References SparseMatrix< T, ULI >::loadFromFile(), and BetaHilbert< T >::set_p_translate().
|
inline |
COO-based constructor.
| input | COO matrix. |
| m | The number of rows in the input matrix. |
| n | The number of columns in the input matrix. |
| zero | Zero element of the sparse matrix. |
| _p_translate | Thread pinning array. |
References BetaHilbert< T >::input, BetaHilbert< T >::load(), and BetaHilbert< T >::set_p_translate().
|
inlinevirtual |
Base deconstructor.
References BetaHilbert< T >::cond, BetaHilbert< T >::mutex, BetaHilbert< T >::P, BetaHilbert< T >::thread_data, and BetaHilbert< T >::threads.
|
inlinevirtual |
Implements Matrix< T >.
References BetaHilbert< T >::P, and BetaHilbert< T >::thread_data.
|
inlinestatic |
Code that collects a distributed output vector.
| shared | The local thread data. |
References shared_data< T >::cond, shared_data< T >::id, shared_data< T >::local_y, SparseMatrix< T, ULI >::m(), shared_data< T >::mutex, shared_data< T >::output, shared_data< T >::output_vector_size, shared_data< T >::P, shared_data< T >::sync, and BetaHilbert< T >::synchronise().
Referenced by BetaHilbert< T >::thread().
|
inlinestatic |
End synchronisation function.
| mutex | Which mutex to sync with. |
| cond | Which condition to sync with. |
| sync | Sync counter to be used. |
| P | How many SPMD processes are running. |
Referenced by BetaHilbert< T >::thread().
|
inlinevirtual |
Implements SparseMatrix< T, ULI >.
|
inlinevirtual |
Loads from input COO matrix.
| input | The input COO matrix. |
| m | Input matrix row dimension. |
| n | Input matrix column dimension. |
| zero | Zero element of the input matrix. |
Implements SparseMatrix< T, ULI >.
References BetaHilbert< T >::cond, BetaHilbert< T >::end_cond, BetaHilbert< T >::end_mutex, BetaHilbert< T >::end_sync, BetaHilbert< T >::input, SparseMatrix< T, ULI >::m(), BetaHilbert< T >::mutex, SparseMatrix< T, ULI >::n(), SparseMatrix< T, ULI >::nnz, SparseMatrix< T, ULI >::noc, SparseMatrix< T, ULI >::nor, BetaHilbert< T >::output, BetaHilbert< T >::P, BetaHilbert< T >::p_translate, BetaHilbert< T >::sync, BetaHilbert< T >::thread(), BetaHilbert< T >::thread_data, BetaHilbert< T >::threads, BetaHilbert< T >::wait(), and SparseMatrix< T, ULI >::zero_element.
Referenced by BetaHilbert< T >::BetaHilbert().
|
inlinevirtual |
Overloaded mv call; allocates output vector using numa_interleaved.
| x | The input vector of length n. |
Reimplemented from SparseMatrix< T, ULI >.
References SparseMatrix< T, ULI >::nor, BetaHilbert< T >::reset(), BetaHilbert< T >::zax(), and SparseMatrix< T, ULI >::zero_element.
|
inlineprotected |
Sets p_translate to 0..P-1 by default, or equal to the optionally supplied vector.
References MachineInfo::cores(), MachineInfo::getInstance(), BetaHilbert< T >::P, and BetaHilbert< T >::p_translate.
Referenced by BetaHilbert< T >::BetaHilbert().
|
inlinestatic |
Thread synchronisation function.
| mutex | Mutex used for synchronisation. |
| cond | Condition used for synchronisation. |
| sync | Synchronisation counter. |
| P | The number of SPMD processes running. |
Referenced by BetaHilbert< T >::collectY(), and BetaHilbert< T >::thread().
|
inlinestatic |
SPMD code for each thread doing an SpMV.
| data | Pointer to the thread-local data. |
References shared_data< T >::bytes, FBICRS< _t_value, _i_value, _sub_ds, logBeta >::bytesUsed(), BetaHilbert< T >::collectY(), shared_data< T >::cond, BetaHilbert< T >::cond, BetaHilbert< T >::end(), shared_data< T >::end_cond, shared_data< T >::end_mutex, shared_data< T >::end_sync, BetaHilbert< T >::global_clock_id, Triplet< T >::i(), shared_data< T >::id, shared_data< T >::input, Matrix2HilbertCoordinates::IntegerToHilbert(), shared_data< T >::local_y, SparseMatrix< T, ULI >::m(), BetaHilbert< T >::max_m, BetaHilbert< T >::max_n, shared_data< T >::mode, shared_data< T >::mutex, BetaHilbert< T >::mutex, SparseMatrix< T, ULI >::n(), SparseMatrix< T, ULI >::nnz, shared_data< T >::nzb, shared_data< T >::nzc, shared_data< T >::original, shared_data< T >::output, shared_data< T >::output_vector_size, shared_data< T >::P, BetaHilbert< T >::P, shared_data< T >::repeat, shared_data< T >::sync, BetaHilbert< T >::synchronise(), shared_data< T >::time, FBICRS< _t_value, _i_value, _sub_ds, logBeta >::zax_fb(), and FBICRS< _t_value, _i_value, _sub_ds, logBeta >::zxa_fb().
Referenced by BetaHilbert< T >::load().
|
inline |
Callee will Wait for end of SpMV.
References BetaHilbert< T >::end_cond, and BetaHilbert< T >::end_mutex.
Referenced by BetaHilbert< T >::load(), BetaHilbert< T >::reset(), BetaHilbert< T >::zax(), and BetaHilbert< T >::zxa().
|
inlinevirtual |
Computes z=Ax in place.
| x | The input vector of length n. |
| z | The output vector of length m. |
Referenced by BetaHilbert< T >::mv().
|
inlinevirtual |
Computes z=Ax in place, a given number of times in succession, and measures the time taken.
| x | The input vector of length n. |
| z | The output vector of length m. |
| repeat | The number of times this SpMV will be repeated. |
| clock_id | Which system clock to use for timing. |
| elapsed_time | Where to add the elapsed time to. |
References BetaHilbert< T >::cond, BetaHilbert< T >::end_mutex, BetaHilbert< T >::global_clock_id, BetaHilbert< T >::input, BetaHilbert< T >::mutex, SparseMatrix< T, ULI >::nor, BetaHilbert< T >::output, BetaHilbert< T >::P, BetaHilbert< T >::thread_data, and BetaHilbert< T >::wait().
|
inlinevirtual |
Computes z=xA in place.
| x | The input vector of length m. |
| z | The output vector of length n. |
|
inlinevirtual |
Computes z=xA in place, a given number of times successively.
| x | The input vector of length m. |
| z | The output vector of length n. |
| repeat | The number of times to repeat the in-place SpMV. |
References BetaHilbert< T >::cond, BetaHilbert< T >::end_mutex, BetaHilbert< T >::input, BetaHilbert< T >::mutex, SparseMatrix< T, ULI >::nor, BetaHilbert< T >::output, BetaHilbert< T >::P, BetaHilbert< T >::thread_data, and BetaHilbert< T >::wait().
1.8.7