17#ifndef dealii_cuda_matrix_free_h
18#define dealii_cuda_matrix_free_h
22#ifdef DEAL_II_COMPILER_CUDA_AWARE
48 namespace MatrixFreeFunctions
60 template <
int dim,
typename Number>
91 template <
int dim,
typename Number =
double>
131# ifndef DEAL_II_MPI_WITH_CUDA_SUPPORT
135 "Overlapping communication and computation requires CUDA-aware MPI."));
141 "Overlapping communication and coloring are incompatible options. Only one of them can be enabled."));
258 template <
typename IteratorFiltersType>
264 const IteratorFiltersType & iterator_filter,
311 template <
typename Functor,
typename VectorType>
314 const VectorType &src,
315 VectorType & dst)
const;
332 template <
typename Functor>
340 template <
typename VectorType>
349 template <
typename VectorType>
373 const std::vector<std::vector<CellFilter>> &
386 const std::shared_ptr<const Utilities::MPI::Partitioner> &
411 template <
typename IteratorFiltersType>
417 const IteratorFiltersType & iterator_filter,
418 std::shared_ptr<const MPI_Comm>
comm,
425 template <
typename Functor,
typename VectorType>
428 const VectorType &src,
429 VectorType & dst)
const;
435 template <
typename Functor>
438 const Functor & func,
447 template <
typename Functor>
450 const Functor & func,
458 template <
typename VectorType>
461 VectorType & dst)
const;
487 template <
typename VectorType>
592 std::vector<Number *>
JxW;
602 std::vector<::internal::MatrixFreeFunctions::ConstraintKinds *>
659 std::vector<std::vector<CellFilter>>
graph;
661 friend class internal::ReinitHelper<dim, Number>;
671 template <
int dim,
typename Number>
681 for (
unsigned int d = 0; d < dim; ++d)
703 __host__ __device__
constexpr unsigned int
730 __device__
inline unsigned int
734 dim == 1 ? threadIdx.x % n_q_points_1d :
735 dim == 2 ? threadIdx.x % n_q_points_1d + n_q_points_1d * threadIdx.y :
736 threadIdx.x % n_q_points_1d +
737 n_q_points_1d * (threadIdx.y + n_q_points_1d * threadIdx.z));
748 template <
int dim,
typename Number>
749 __device__
inline unsigned int
751 const unsigned int cell,
753 const unsigned int n_q_points_1d,
754 const unsigned int n_q_points)
757 q_point_id_in_cell<dim>(n_q_points_1d);
767 template <
int dim,
typename Number>
770 const unsigned int cell,
772 const unsigned int n_q_points_1d)
775 q_point_id_in_cell<dim>(n_q_points_1d));
782 template <
int dim,
typename Number>
829 std::vector<::internal::MatrixFreeFunctions::ConstraintKinds>
847 template <
int dim,
typename Number>
850 const typename ::CUDAWrappers::MatrixFree<dim, Number>::Data &data,
855 data_host.
id = data.id;
856 data_host.
n_cells = data.n_cells;
861 const unsigned int n_elements =
865 data_host.
q_points.resize(n_elements);
882 data_host.
JxW.resize(n_elements);
900 template <
int dim,
typename Number>
904 const unsigned int n_q_points,
905 const unsigned int i)
919 template <
int dim,
typename Number>
923 const unsigned int i)
933 template <
int dim,
typename Number>
934 inline const std::vector<std::vector<
943 template <
int dim,
typename Number>
944 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
952 template <
int dim,
typename Number>
void evaluate_coefficients(Functor func) const
void serial_copy_constrained_values(const VectorType &src, VectorType &dst) const
std::vector< Number * > JxW
const DoFHandler< dim > * dof_handler
void initialize_dof_vector(LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &vec) const
unsigned int q_points_per_cell
Data get_data(unsigned int color) const
unsigned int get_padding_length() const
void initialize_dof_vector(LinearAlgebra::CUDAWrappers::Vector< Number > &vec) const
bool overlap_communication_computation
void serial_set_constrained_values(const Number val, VectorType &dst) const
std::vector< dim3 > block_dim
void reinit(const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
unsigned int cells_per_block
void distributed_copy_constrained_values(const LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &src, LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &dst) const
std::vector< unsigned int > n_cells
ParallelizationScheme parallelization_scheme
unsigned int n_constrained_dofs
void internal_reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, std::shared_ptr< const MPI_Comm > comm, const AdditionalData additional_data)
const DoFHandler< dim > & get_dof_handler() const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner() const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const AdditionalData &additional_data=AdditionalData())
void serial_cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
std::size_t memory_consumption() const
std::vector<::internal::MatrixFreeFunctions::ConstraintKinds * > constraint_mask
std::vector< point_type * > q_points
CUDAWrappers::MatrixFree< dim, Number >::point_type & get_quadrature_point(const unsigned int cell, const typename CUDAWrappers::MatrixFree< dim, Number >::Data *data, const unsigned int n_q_points_1d)
void distributed_set_constrained_values(const Number val, LinearAlgebra::CUDAWrappers::Vector< Number > &dst) const
unsigned int local_q_point_id(const unsigned int cell, const typename CUDAWrappers::MatrixFree< dim, Number >::Data *data, const unsigned int n_q_points_1d, const unsigned int n_q_points)
unsigned int dofs_per_cell
void distributed_set_constrained_values(const Number val, LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &dst) const
Point< dim, Number > get_quadrature_point_host(const unsigned int cell, const DataHost< dim, Number > &data, const unsigned int i)
void distributed_cell_loop(const Functor &func, const LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &src, LinearAlgebra::distributed::Vector< Number, MemorySpace::CUDA > &dst) const
const std::vector< std::vector< CellFilter > > & get_colored_graph() const
std::vector< dim3 > grid_dim
std::vector< types::global_dof_index * > local_to_global
dim3 constraint_block_dim
std::vector< std::vector< CellFilter > > graph
void copy_constrained_values(const VectorType &src, VectorType &dst) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
unsigned int padding_length
unsigned int q_point_id_in_cell(const unsigned int n_q_points_1d)
void distributed_copy_constrained_values(const LinearAlgebra::CUDAWrappers::Vector< Number > &src, LinearAlgebra::CUDAWrappers::Vector< Number > &dst) const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
types::global_dof_index n_dofs
void distributed_cell_loop(const Functor &func, const LinearAlgebra::CUDAWrappers::Vector< Number > &src, LinearAlgebra::CUDAWrappers::Vector< Number > &dst) const
std::vector< unsigned int > row_start
void set_constrained_values(const Number val, VectorType &dst) const
DataHost< dim, Number > copy_mf_data_to_host(const typename::CUDAWrappers::MatrixFree< dim, Number >::Data &data, const UpdateFlags &update_flags)
types::global_dof_index * constrained_dofs
std::vector< Number * > inv_jacobian
unsigned int local_q_point_id_host(const unsigned int cell, const DataHost< dim, Number > &data, const unsigned int n_q_points, const unsigned int i)
void cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
Abstract base class for mapping classes.
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
__host__ constexpr unsigned int cells_per_block_shmem(int dim, int fe_degree)
void copy_to_host(const ArrayView< const T, MemorySpace::CUDA > &in, ArrayView< T, MemorySpace::Host > &out)
std::vector<::internal::MatrixFreeFunctions::ConstraintKinds > constraint_mask
unsigned int padding_length
std::vector< types::global_dof_index > local_to_global
std::vector< Point< dim, Number > > q_points
std::vector< Number > inv_jacobian
std::vector< Number > JxW
AdditionalData(const ParallelizationScheme parallelization_scheme=parallel_in_elem, const UpdateFlags mapping_update_flags=update_gradients|update_JxW_values|update_quadrature_points, const bool use_coloring=false, const bool overlap_communication_computation=false)
ParallelizationScheme parallelization_scheme
UpdateFlags mapping_update_flags
bool overlap_communication_computation
::internal::MatrixFreeFunctions::ConstraintKinds * constraint_mask
types::global_dof_index * local_to_global
unsigned int padding_length
SharedData(Number *vd, Number *gq[dim])