https://mooseframework.inl.gov
Classes | Public Member Functions | Private Attributes | List of all members
Moose::Kokkos::Vector Class Reference

The Kokkos wrapper class for PETSc vector. More...

#include <KokkosVector.h>

Classes

struct  DeviceAssembly
 Data for direct assembly on device. More...
 
struct  PackBuffer
 Kokkos functions for direct assembly on device. More...
 
struct  UnpackBuffer
 

Public Member Functions

 Vector ()=default
 Default constructor. More...
 
 ~Vector ()
 Destructor. More...
 
void destroy ()
 Free all data and reset. More...
 
bool isAlloc () const
 Get whether the vector was allocated. More...
 
void create (libMesh::NumericVector< PetscScalar > &vector, const System &system, bool assemble)
 Create the vector from a libMesh PetscVector. More...
 
void copyToDevice ()
 Copy from the host libMesh PetscVector. More...
 
void copyToHost ()
 Copy to the host libMesh PetscVector. More...
 
void restore ()
 Restore the underlying PETSc vector. More...
 
void close ()
 Assemble the underlying PETSc vector. More...
 
KOKKOS_FUNCTION PetscScalar & operator() (dof_id_type i) const
 Get an entry with a given index. More...
 
KOKKOS_FUNCTION PetscScalar & operator[] (dof_id_type i) const
 Get an entry with a given index. More...
 
auto & operator= (PetscScalar scalar)
 Assign a scalar value uniformly. More...
 
KOKKOS_FUNCTION void operator() (PackBuffer, const PetscCount tid) const
 
KOKKOS_FUNCTION void operator() (UnpackBuffer, const PetscCount tid) const
 

Private Attributes

PetscScalar * _array = PETSC_NULLPTR
 Raw data of local PETSc vector. More...
 
const System_system
 Pointer to the Kokkos system. More...
 
const libMesh::Parallel::Communicator_comm = nullptr
 Pointer to the libMesh communicator. More...
 
bool _assemble = false
 Flag whether the vector will be assembled. More...
 
bool _is_ghosted = false
 Flag whether the PETSc vector is ghosted. More...
 
bool _is_host = false
 Flag whether the PETSc vector is a host vector. More...
 
bool _is_alloc = false
 Flag whether the vector was allocated. More...
 
DeviceAssembly _send
 
DeviceAssembly _recv
 
unsigned int _current_proc
 
Vec _global_vector = PETSC_NULLPTR
 PETSc vectors. More...
 
Vec _local_vector = PETSC_NULLPTR
 
Array< PetscScalar > _local
 Data vectors on device. More...
 
Array< PetscScalar > _ghost
 

Detailed Description

The Kokkos wrapper class for PETSc vector.

Definition at line 27 of file KokkosVector.h.

Constructor & Destructor Documentation

◆ Vector()

Moose::Kokkos::Vector::Vector ( )
default

Default constructor.

◆ ~Vector()

Moose::Kokkos::Vector::~Vector ( )
inline

Destructor.

Definition at line 37 of file KokkosVector.h.

37 { destroy(); }
void destroy()
Free all data and reset.

Member Function Documentation

◆ close()

void Moose::Kokkos::Vector::close ( )

Assemble the underlying PETSc vector.

◆ copyToDevice()

void Moose::Kokkos::Vector::copyToDevice ( )

Copy from the host libMesh PetscVector.

◆ copyToHost()

void Moose::Kokkos::Vector::copyToHost ( )

Copy to the host libMesh PetscVector.

◆ create()

void Moose::Kokkos::Vector::create ( libMesh::NumericVector< PetscScalar > &  vector,
const System system,
bool  assemble 
)

Create the vector from a libMesh PetscVector.

Parameters
vectorThe libMesh PetscVector
systemThe Kokkos system
assembleWhether the vector will be assembled

◆ destroy()

void Moose::Kokkos::Vector::destroy ( )

Free all data and reset.

Referenced by ~Vector().

◆ isAlloc()

bool Moose::Kokkos::Vector::isAlloc ( ) const
inline

Get whether the vector was allocated.

Returns
Whether the vector was allocated

Definition at line 48 of file KokkosVector.h.

48 { return _is_alloc; }
bool _is_alloc
Flag whether the vector was allocated.
Definition: KokkosVector.h:199

◆ operator()() [1/3]

KOKKOS_FUNCTION PetscScalar& Moose::Kokkos::Vector::operator() ( dof_id_type  i) const
inline

Get an entry with a given index.

Parameters
iThe entry index local to this process
Returns
The reference of the entry

Definition at line 78 of file KokkosVector.h.

79  {
80  return i < _local.size() ? _local[i] : _ghost(i);
81  }
Array< PetscScalar > _local
Data vectors on device.
Definition: KokkosVector.h:181
Array< PetscScalar > _ghost
Definition: KokkosVector.h:182

◆ operator()() [2/3]

KOKKOS_FUNCTION void Moose::Kokkos::Vector::operator() ( PackBuffer  ,
const PetscCount  tid 
) const

◆ operator()() [3/3]

KOKKOS_FUNCTION void Moose::Kokkos::Vector::operator() ( UnpackBuffer  ,
const PetscCount  tid 
) const

◆ operator=()

auto& Moose::Kokkos::Vector::operator= ( PetscScalar  scalar)
inline

Assign a scalar value uniformly.

Parameters
scalarThe scalar value to be assigned

Definition at line 95 of file KokkosVector.h.

96  {
97  _local = scalar;
98  _ghost = scalar;
99 
100  return *this;
101  }
Array< PetscScalar > _local
Data vectors on device.
Definition: KokkosVector.h:181
Array< PetscScalar > _ghost
Definition: KokkosVector.h:182

◆ operator[]()

KOKKOS_FUNCTION PetscScalar& Moose::Kokkos::Vector::operator[] ( dof_id_type  i) const
inline

Get an entry with a given index.

Parameters
iThe entry index local to this process
Returns
The reference of the entry

Definition at line 87 of file KokkosVector.h.

88  {
89  return i < _local.size() ? _local[i] : _ghost(i);
90  }
Array< PetscScalar > _local
Data vectors on device.
Definition: KokkosVector.h:181
Array< PetscScalar > _ghost
Definition: KokkosVector.h:182

◆ restore()

void Moose::Kokkos::Vector::restore ( )

Restore the underlying PETSc vector.

Member Data Documentation

◆ _array

PetscScalar* Moose::Kokkos::Vector::_array = PETSC_NULLPTR
private

Raw data of local PETSc vector.

Definition at line 168 of file KokkosVector.h.

◆ _assemble

bool Moose::Kokkos::Vector::_assemble = false
private

Flag whether the vector will be assembled.

Definition at line 187 of file KokkosVector.h.

◆ _comm

const libMesh::Parallel::Communicator* Moose::Kokkos::Vector::_comm = nullptr
private

Pointer to the libMesh communicator.

Definition at line 176 of file KokkosVector.h.

◆ _current_proc

unsigned int Moose::Kokkos::Vector::_current_proc
private

Definition at line 155 of file KokkosVector.h.

◆ _ghost

Array<PetscScalar> Moose::Kokkos::Vector::_ghost
private

Definition at line 182 of file KokkosVector.h.

Referenced by operator()(), operator=(), and operator[]().

◆ _global_vector

Vec Moose::Kokkos::Vector::_global_vector = PETSC_NULLPTR
private

PETSc vectors.

Definition at line 162 of file KokkosVector.h.

◆ _is_alloc

bool Moose::Kokkos::Vector::_is_alloc = false
private

Flag whether the vector was allocated.

Definition at line 199 of file KokkosVector.h.

Referenced by isAlloc().

◆ _is_ghosted

bool Moose::Kokkos::Vector::_is_ghosted = false
private

Flag whether the PETSc vector is ghosted.

Definition at line 191 of file KokkosVector.h.

◆ _is_host

bool Moose::Kokkos::Vector::_is_host = false
private

Flag whether the PETSc vector is a host vector.

Definition at line 195 of file KokkosVector.h.

◆ _local

Array<PetscScalar> Moose::Kokkos::Vector::_local
private

Data vectors on device.

Definition at line 181 of file KokkosVector.h.

Referenced by operator()(), operator=(), and operator[]().

◆ _local_vector

Vec Moose::Kokkos::Vector::_local_vector = PETSC_NULLPTR
private

Definition at line 163 of file KokkosVector.h.

◆ _recv

DeviceAssembly Moose::Kokkos::Vector::_recv
private

Definition at line 153 of file KokkosVector.h.

◆ _send

DeviceAssembly Moose::Kokkos::Vector::_send
private

Definition at line 152 of file KokkosVector.h.

◆ _system

const System* Moose::Kokkos::Vector::_system
private

Pointer to the Kokkos system.

Definition at line 172 of file KokkosVector.h.


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