Welcome to BCL’s documentation!

Index

Communication

template<typename T>
struct GlobalPtr

Global pointer class. Provides a way to point to remote memory.

Public Functions

inline reference operator*() const noexcept

Dereference the global pointer, returning a global reference GlobalRef that can be used to read or write to the memory location.

inline bool is_local() const noexcept

Check if GlobalPtr points to memory on the local rank.

inline T *local() const

Return a local pointer of type T* to the location pointed to by the global pointer.

If pointer is pointing to remove memory, returns nullptr.

template<typename T>
inline GlobalPtr<T> BCL::alloc(const size_t size)

Non-collective function. Allocate a block of global memory on the local rank to hold size elements of type T. The total size of the allocation will be sizeof(T) * size. Does not call any constructors.

template<typename T>
inline void BCL::dealloc(GlobalPtr<T> ptr)

Non-collective function. Deallocate the block of memory pointed to by ptr. ptr must point to memory on the local rank.

template<typename T, typename U>
inline GlobalPtr<T> BCL::reinterpret_pointer_cast(GlobalPtr<U> ptr) noexcept

Cast a GlobalPtr to point to memory of another type.

Example

#include <bcl/bcl.hpp>
int main(int argc, char** argv) {
  BCL::init();
  BCL::GlobalPtr<char> cptr = BCL::alloc<char>(100);

  BCL::GlobalPtr<int> iptr = BCL::reinterpret_pointer_cast<int>(cptr);

  BCL::finalize();
  return 0;
}

Data Structures

template<typename T>
class DMatrix : public BCL::DExpr<DMatrix<T>>

Distributed dense matrix data structure storing elements of type T.

Public Functions

template<typename Blocking = BCL::BlockSquare, typename TeamType = BCL::WorldTeam>
inline DMatrix(matrix_dim dim, Blocking &&blocking = Blocking(), TeamType &&team = TeamType())

Construct a distributed dense matrix of dimension dim[0] x dim[1]. The optional argument blocking describes how the matrix should be distributed, and the optional argument team controls on which subset of processes the matrix is stored.

inline GlobalRef<T> operator[](matrix_dim index)

Return a reference to element index[0], index[1] of the matrix.

template<typename MatrixType>
inline auto dot(MatrixType &&other) const

Multiply the matrix by another matrix or symbolic matrix view, returning the result as a new matrix.

template<typename Fn>
inline DMatrix &apply_inplace(Fn &&fn)

Apply the functor fn in place on each element of the matrix.

inline DTransposeView<DMatrix<T>> transpose()

Return a symbolic transpose view of the matrix.

template<typename Fn>
inline DMatrix<T> apply(Fn &&fn) const

Return a new matrix equal to the current matrix with fn applied to each element.

template<typename Fn>
inline DMatrix<T> binary_op(const DMatrix<T> &other, Fn &&fn) const

Create a new matrix equal to the result of the binary operation fn applied element-wise to the elements of the current matrix and matrix other.

template<typename Fn>
inline DMatrix<T> &binary_op_inplace(const DMatrix<T> &other, Fn &&fn)

Apply the binary operation fn elementwise to the current matrix and other, storing the result in the current matrix.

inline matrix_dim shape() const noexcept

Return the shape of the matrix.

inline void print() const

Print the matrix to the terminal.

template<typename T, typename I = int>
class SPMatrix

Distributed sparse matrix data structure storing elements of type T. Indices are stored using integral type I.

Public Functions

template<typename Blocking = BCL::BlockSquare, typename TeamType = BCL::WorldTeam>
inline SPMatrix(std::string fname, Blocking &&blocking = Blocking(), TeamType &&team = BCL::WorldTeam(), FileFormat format = FileFormat::Unknown)

Construct a distributed sparse matrix matching the sparse matrix stored in the file at path fname. The optional arguments blocking and team determine the tile distribution strategy and set of processes among which the matrix is distributed, respectively. The optional argument format describes the storage format of the file.

template<typename Blocking = BCL::BlockSquare, typename TeamType = BCL::WorldTeam>
inline SPMatrix(matrix_dim dim, Blocking &&blocking = Blocking(), TeamType &&team = TeamType())

Constructed a distributed sparse matrix of dimension dim[0] x dim[1]. The optional arguments blocking and team determine the tile distribution strategy and set of processes among which the matrix is distributed, respectively.

inline matrix_dim shape() const noexcept

Return the shape of the sparse matrix.

inline std::size_t nnz() const noexcept

Return the number of nonzero elements stored in the sparse matrix.

template<typename MatrixType>
inline auto dot(MatrixType &&other) const

Multiply the matrix by another matrix or symbolic matrix view, returning the result as a new matrix.

inline void print() const

Print distributed sparse matrix data structure.