// TODO this should really be a CUDAWrappers::Point
using point_type = Tensor<1, dim, Number>;
- // Use Number2 so we don't hide the template parameter Number
- template <typename Number2>
- using CUDAVector = ::dealii::LinearAlgebra::CUDAWrappers::Vector<Number2>;
-
/**
* Parallelization scheme used: parallel_in_elem (parallelism at the level
* of degrees of freedom) or parallel_over_elem (parallelism at the level of
* This method runs the loop over all cells and apply the local operation on
* each element in parallel. @p func is a functor which is appplied on each color.
*/
- template <typename functor>
+ template <typename functor, typename VectorType>
void
- cell_loop(const functor & func,
- const CUDAVector<Number> &src,
- CUDAVector<Number> & dst) const;
+ cell_loop(const functor & func,
+ const VectorType &src,
+ VectorType & dst) const;
+ template <typename VectorType>
void
- copy_constrained_values(const CUDAVector<Number> &src,
- CUDAVector<Number> & dst) const;
+ copy_constrained_values(const VectorType &src, VectorType &dst) const;
+ template <typename VectorType>
void
- set_constrained_values(const Number val, CUDAVector<Number> &dst) const;
+ set_constrained_values(const Number val, VectorType &dst) const;
/**
* Free all the memory allocated.
template <int dim, typename Number>
+ template <typename VectorType>
void
- MatrixFree<dim, Number>::copy_constrained_values(
- const CUDAVector<Number> &src,
- CUDAVector<Number> & dst) const
+ MatrixFree<dim, Number>::copy_constrained_values(const VectorType &src,
+ VectorType & dst) const
{
+ static_assert(
+ std::is_same<Number, typename VectorType::value_type>::value,
+ "VectorType::value_type and Number should be of the same type.");
internal::copy_constrained_dofs<Number>
<<<constraint_grid_dim, constraint_block_dim>>>(constrained_dofs,
n_constrained_dofs,
template <int dim, typename Number>
+ template <typename VectorType>
void
- MatrixFree<dim, Number>::set_constrained_values(Number val,
- CUDAVector<Number> &dst) const
+ MatrixFree<dim, Number>::set_constrained_values(Number val,
+ VectorType &dst) const
{
+ static_assert(
+ std::is_same<Number, typename VectorType::value_type>::value,
+ "VectorType::value_type and Number should be of the same type.");
internal::set_constrained_dofs<Number>
<<<constraint_grid_dim, constraint_block_dim>>>(constrained_dofs,
n_constrained_dofs,
template <int dim, typename Number>
- template <typename functor>
+ template <typename functor, typename VectorType>
void
- MatrixFree<dim, Number>::cell_loop(const functor & func,
- const CUDAVector<Number> &src,
- CUDAVector<Number> & dst) const
+ MatrixFree<dim, Number>::cell_loop(const functor & func,
+ const VectorType &src,
+ VectorType & dst) const
{
for (unsigned int i = 0; i < n_colors; ++i)
internal::apply_kernel_shmem<dim, Number, functor>
AffineConstraints<double> constraints;
constraints.close();
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
constraints);
constraints.close();
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
// Skip 2D tests with even fe_degree
if ((dim == 3) || ((fe_degree % 2) == 1))
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
AffineConstraints<double> constraints;
constraints.close();
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
// Skip 2D tests with even fe_degree
if ((dim == 3) || ((fe_degree % 2) == 1))
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
constraints);
constraints.close();
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
constraints);
constraints.close();
- do_test<dim, fe_degree, double, fe_degree + 1>(dof, constraints);
+ do_test<dim,
+ fe_degree,
+ double,
+ LinearAlgebra::CUDAWrappers::Vector<double>,
+ fe_degree + 1>(dof, constraints);
}
#include <deal.II/lac/affine_constraints.h>
#include <deal.II/lac/cuda_vector.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
+#include <deal.II/lac/la_parallel_vector.h>
#include <deal.II/lac/read_write_vector.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/vector.h>
-template <int dim, int fe_degree, typename Number, int n_q_points_1d>
+template <int dim,
+ int fe_degree,
+ typename Number,
+ typename VectorType,
+ int n_q_points_1d>
void
do_test(const DoFHandler<dim> & dof,
const AffineConstraints<double> &constraints)
const QGauss<1> quad(n_q_points_1d);
mf_data.reinit(mapping, dof, constraints, quad, additional_data);
- const unsigned int n_dofs = dof.n_dofs();
- MatrixFreeTest<dim, fe_degree, Number, n_q_points_1d> mf(mf_data);
- Vector<Number> in_host(n_dofs), out_host(n_dofs);
- LinearAlgebra::ReadWriteVector<Number> in(n_dofs), out(n_dofs);
- LinearAlgebra::CUDAWrappers::Vector<Number> in_device(n_dofs);
- LinearAlgebra::CUDAWrappers::Vector<Number> out_device(n_dofs);
+ const unsigned int n_dofs = dof.n_dofs();
+ MatrixFreeTest<dim, fe_degree, Number, VectorType, n_q_points_1d> mf(mf_data);
+ Vector<Number> in_host(n_dofs), out_host(n_dofs);
+ LinearAlgebra::ReadWriteVector<Number> in(n_dofs), out(n_dofs);
+ VectorType in_device(n_dofs);
+ VectorType out_device(n_dofs);
for (unsigned int i = 0; i < n_dofs; ++i)
{
// general, with and without hanging nodes).
#include <deal.II/lac/cuda_vector.h>
+#include <deal.II/lac/la_parallel_vector.h>
#include <deal.II/matrix_free/cuda_fe_evaluation.h>
#include <deal.II/matrix_free/cuda_matrix_free.h>
template <int dim,
int fe_degree,
typename Number,
- int n_q_points_1d = fe_degree + 1>
+ typename VectorType = LinearAlgebra::CUDAWrappers::Vector<Number>,
+ int n_q_points_1d = fe_degree + 1>
class MatrixFreeTest
{
public:
: data(data_in){};
void
- vmult(LinearAlgebra::CUDAWrappers::Vector<Number> & dst,
- const LinearAlgebra::CUDAWrappers::Vector<Number> &src);
+ vmult(VectorType &dst, const VectorType &src);
private:
const CUDAWrappers::MatrixFree<dim, Number> &data;
-template <int dim, int fe_degree, typename Number, int n_q_points_1d>
+template <int dim,
+ int fe_degree,
+ typename Number,
+ typename VectorType,
+ int n_q_points_1d>
void
-MatrixFreeTest<dim, fe_degree, Number, n_q_points_1d>::vmult(
- LinearAlgebra::CUDAWrappers::Vector<Number> & dst,
- const LinearAlgebra::CUDAWrappers::Vector<Number> &src)
+MatrixFreeTest<dim, fe_degree, Number, VectorType, n_q_points_1d>::vmult(
+ VectorType & dst,
+ const VectorType &src)
{
dst = static_cast<Number>(0.);
HelmholtzOperator<dim, fe_degree, Number, n_q_points_1d> helmholtz_operator;