HMLP: High-performance Machine Learning Primitives
hmlp::DistKernelMatrix< T, TP, Allocator > Class Template Reference

#include <KernelMatrix.hpp>

Inheritance diagram for hmlp::DistKernelMatrix< T, TP, Allocator >:
hmlp::DistVirtualMatrix< T, Allocator > hmlp::ReadWrite hmlp::VirtualMatrix< T, Allocator > hmlp::mpi::MPIObject hmlp::SPDMatrixMPISupport< T >

Public Member Functions

 DistKernelMatrix (size_t m, size_t n, size_t d, DistData< STAR, CBLK, TP > &sources, DistData< STAR, CBLK, TP > &targets, mpi::Comm comm)
 
 DistKernelMatrix (size_t m, size_t n, size_t d, kernel_s< T, TP > &kernel, DistData< STAR, CBLK, TP > &sources, DistData< STAR, CBLK, TP > &targets, mpi::Comm comm)
 
 DistKernelMatrix (size_t n, size_t d, DistData< STAR, CBLK, TP > &sources, mpi::Comm comm)
 
 DistKernelMatrix (size_t n, size_t d, kernel_s< T, TP > &kernel, DistData< STAR, CBLK, TP > &sources, mpi::Comm comm)
 
 DistKernelMatrix (DistData< STAR, CBLK, TP > &sources, mpi::Comm comm)
 
 ~DistKernelMatrix ()
 
virtual T operator() (size_t i, size_t j) override
 
virtual Data< T > operator() (const vector< size_t > &I, const vector< size_t > &J) override
 
virtual Data< T > GeometryDistances (const vector< size_t > &I, const vector< size_t > &J) override
 
Data< T > Diagonal (vector< size_t > &I)
 
pair< T, size_t > ImportantSample (size_t j)
 
void Print ()
 
size_t dim ()
 
double flops (size_t na, size_t nb)
 
void SendIndices (vector< size_t > ids, int dest, mpi::Comm comm)
 
void RecvIndices (int src, mpi::Comm comm, mpi::Status *status)
 
void BcastIndices (vector< size_t > ids, int root, mpi::Comm comm)
 
void RequestIndices (const vector< vector< size_t >> &ids) override
 
- Public Member Functions inherited from hmlp::DistVirtualMatrix< T, Allocator >
 DistVirtualMatrix (size_t m, size_t n, mpi::Comm comm)
 
- Public Member Functions inherited from hmlp::VirtualMatrix< T, Allocator >
 VirtualMatrix (size_t m, size_t n)
 
virtual void resize (size_t m, size_t n)
 
size_t row ()
 
size_t col ()
 
Data< T > KernelDistances (const vector< size_t > &I, const vector< size_t > &J)
 
Data< T > AngleDistances (const vector< size_t > &I, const vector< size_t > &J)
 
virtual Data< T > UserDistances (const vector< size_t > &I, const vector< size_t > &J)
 
Data< T > Distances (DistanceMetric metric, const vector< size_t > &I, const vector< size_t > &J)
 
virtual Data< pair< T, size_t > > NeighborSearch (DistanceMetric metric, size_t kappa, const vector< size_t > &Q, const vector< size_t > &R, pair< T, size_t > init)
 
virtual Data< T > Diagonal (const vector< size_t > &I)
 
virtual pair< T, int > ImportantSample (int j)
 
- Public Member Functions inherited from hmlp::mpi::MPIObject
 MPIObject (mpi::Comm comm)
 
void AssignCommunicator (mpi::Comm &comm)
 
mpi::Comm GetComm ()
 
mpi::Comm GetPrivateComm ()
 
int GetCommSize ()
 
int GetCommRank ()
 
int Comm_size ()
 
int Comm_rank ()
 
int Barrier ()
 
int PrivateBarrier ()
 
- Public Member Functions inherited from hmlp::ReadWrite
 ReadWrite ()
 
void DependencyAnalysis (ReadWriteType type, Task *task)
 This is the key function that encode the dependency. More...
 
void DependencyCleanUp ()
 

Additional Inherited Members

- Public Types inherited from hmlp::VirtualMatrix< T, Allocator >
typedef T T
 
- Public Attributes inherited from hmlp::ReadWrite
deque< Task * > read
 
deque< Task * > write
 

Detailed Description

template<typename T, typename TP, class Allocator = std::allocator<TP>>
class hmlp::DistKernelMatrix< T, TP, Allocator >

end class KernelMatrix

Constructor & Destructor Documentation

template<typename T , typename TP , class Allocator = std::allocator<TP>>
hmlp::DistKernelMatrix< T, TP, Allocator >::DistKernelMatrix ( size_t  m,
size_t  n,
size_t  d,
DistData< STAR, CBLK, TP > &  sources,
DistData< STAR, CBLK, TP > &  targets,
mpi::Comm  comm 
)
inline

(Default) unsymmetric kernel matrix

Parameters
sourcesby default we assume sources are distributed in [STAR, CBLK]
targetsby default we assume targets are distributed in [STAR, CBLK]
template<typename T , typename TP , class Allocator = std::allocator<TP>>
hmlp::DistKernelMatrix< T, TP, Allocator >::DistKernelMatrix ( size_t  m,
size_t  n,
size_t  d,
kernel_s< T, TP > &  kernel,
DistData< STAR, CBLK, TP > &  sources,
DistData< STAR, CBLK, TP > &  targets,
mpi::Comm  comm 
)
inline

Unsymmetric kernel matrix with legacy kernel_s<T>

Parameters
sourcesby default we assume sources are distributed in [STAR, CBLK]
targetsby default we assume targets are distributed in [STAR, CBLK]
template<typename T , typename TP , class Allocator = std::allocator<TP>>
hmlp::DistKernelMatrix< T, TP, Allocator >::DistKernelMatrix ( size_t  n,
size_t  d,
DistData< STAR, CBLK, TP > &  sources,
mpi::Comm  comm 
)
inline

(Default) symmetric kernel matrix

Parameters
sourcesby default we assume sources are distributed in [STAR, CBLK]
template<typename T , typename TP , class Allocator = std::allocator<TP>>
hmlp::DistKernelMatrix< T, TP, Allocator >::DistKernelMatrix ( size_t  n,
size_t  d,
kernel_s< T, TP > &  kernel,
DistData< STAR, CBLK, TP > &  sources,
mpi::Comm  comm 
)
inline

Symmetric kernel matrix with legacy kernel_s<T>

Parameters
sourcesby default we assume sources are distributed in [STAR, CBLK]
template<typename T , typename TP , class Allocator = std::allocator<TP>>
hmlp::DistKernelMatrix< T, TP, Allocator >::~DistKernelMatrix ( )
inline

(Default) destructor

Member Function Documentation

template<typename T , typename TP , class Allocator = std::allocator<TP>>
void hmlp::DistKernelMatrix< T, TP, Allocator >::BcastIndices ( vector< size_t >  ids,
int  root,
mpi::Comm  comm 
)
inlinevirtual

Bcast cids from sender for K( :, cids ) evaluation.

Bcast size of cids from root

Resize to receive cids and parameters

Bcast cids and parameters from root

Insert into hash table

Reimplemented from hmlp::SPDMatrixMPISupport< T >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
Data<T> hmlp::DistKernelMatrix< T, TP, Allocator >::Diagonal ( vector< size_t > &  I)
inline

end GeometryDistances() Get the diagonal of KII, i.e. diag( K( I, I ) ).

MPI

return values

NOTICE: even KIJ can be an 0-by-0 matrix for this MPI rank, yet early return is not allowed. All MPI process must execute all collaborative communication routines to avoid deadlock.

at this moment we already have the corrdinates on this process

template<typename T , typename TP , class Allocator = std::allocator<TP>>
size_t hmlp::DistKernelMatrix< T, TP, Allocator >::dim ( )
inline

end Print() return number of attributes

template<typename T , typename TP , class Allocator = std::allocator<TP>>
double hmlp::DistKernelMatrix< T, TP, Allocator >::flops ( size_t  na,
size_t  nb 
)
inline

flops required for Kab

template<typename T , typename TP , class Allocator = std::allocator<TP>>
virtual Data<T> hmlp::DistKernelMatrix< T, TP, Allocator >::GeometryDistances ( const vector< size_t > &  I,
const vector< size_t > &  J 
)
inlineoverridevirtual

Early return if possible.

Request for coordinates: A (targets), B (sources).

For symmetry matrices, extract from sources.

For non-symmetry matrices, extract from targets and sources.

Compute inner products.

Compute square 2-norms.

end omp parallel for

end omp parallel for

Add square norms to inner products to get square distances.

Return all pair-wise distances.

Reimplemented from hmlp::VirtualMatrix< T, Allocator >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
pair<T, size_t> hmlp::DistKernelMatrix< T, TP, Allocator >::ImportantSample ( size_t  j)
inlinevirtual

end Diagonal() Important sampling

Reimplemented from hmlp::VirtualMatrix< T, Allocator >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
virtual T hmlp::DistKernelMatrix< T, TP, Allocator >::operator() ( size_t  i,
size_t  j 
)
inlineoverridevirtual

(Overwrittable) Request a single Kij

Implements hmlp::VirtualMatrix< T, Allocator >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
virtual Data<T> hmlp::DistKernelMatrix< T, TP, Allocator >::operator() ( const vector< size_t > &  I,
const vector< size_t > &  J 
)
inlineoverridevirtual

end operator () (Overwrittable) ESSENTIAL: return K( I, J )

Early return if possible.

Request for coordinates: A (targets), B (sources).

Reimplemented from hmlp::VirtualMatrix< T, Allocator >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
void hmlp::DistKernelMatrix< T, TP, Allocator >::RecvIndices ( int  src,
mpi::Comm  comm,
mpi::Status status 
)
inlinevirtual

Insert into hash table

Reimplemented from hmlp::SPDMatrixMPISupport< T >.

template<typename T , typename TP , class Allocator = std::allocator<TP>>
void hmlp::DistKernelMatrix< T, TP, Allocator >::RequestIndices ( const vector< vector< size_t >> &  ids)
inlineoverridevirtual

Send out cids request to each rank.

Exchange out parameters.

Reimplemented from hmlp::SPDMatrixMPISupport< T >.


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