apply_for_each_quad_point(const Functor &func);
private:
- types::global_dof_index *local_to_global;
- unsigned int n_cells;
- unsigned int padding_length;
- const unsigned int mf_object_id;
+ // FIXME We would like to use
+ // Kokkos::Subview<Kokkos::View<types::global_dof_index **,
+ // MemorySpace::Default::kokkos_space>, int, decltype(Kokkos::ALL)>
+ // but we get error: incomplete type is not allowed. I cannot reproduce
+ // outside of deal.II. Need to investigate more.
+ Kokkos::Subview<Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>,
+ int,
+ Kokkos::pair<int, int>>
+ local_to_global;
+ unsigned int n_cells;
+ unsigned int padding_length;
+ const unsigned int mf_object_id;
const dealii::internal::MatrixFreeFunctions::ConstraintKinds
constraint_mask;
FEEvaluation(const unsigned int cell_id,
const data_type * data,
SharedData<dim, Number> *shdata)
- : n_cells(data->n_cells)
+ : local_to_global(Kokkos::subview(
+ data->local_to_global,
+ cell_id,
+ Kokkos::pair<int, int>(0, Utilities::pow(n_q_points_1d, dim))))
+ , n_cells(data->n_cells)
, padding_length(data->padding_length)
, mf_object_id(data->id)
, constraint_mask(data->constraint_mask[cell_id])
Kokkos::pair<int, int>(0, Utilities::pow(n_q_points_1d, dim))))
, values(shdata->values)
{
- local_to_global = data->local_to_global + padding_length * cell_id;
-
for (unsigned int i = 0; i < dim; ++i)
gradients[i] = shdata->gradients[i];
}
* Map the position in the local vector to the position in the global
* vector.
*/
- types::global_dof_index *local_to_global;
+ Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>
+ local_to_global;
/**
* Kokkos::View of the inverse Jacobian.
* Map the position in the local vector to the position in the global
* vector.
*/
- std::vector<types::global_dof_index *> local_to_global;
+ std::vector<Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>>
+ local_to_global;
/**
* Vector of Kokkos::View of the inverse Jacobian associated to the cells of
* Map the position in the local vector to the position in the global
* vector.
*/
- std::vector<types::global_dof_index> local_to_global;
+ typename Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>::HostMirror
+ local_to_global;
/**
* Kokkos::View of inverse Jacobians on the host.
Kokkos::deep_copy(data_host.q_points, data.q_points);
}
- data_host.local_to_global.resize(n_elements);
- Utilities::CUDA::copy_to_host(data.local_to_global,
- data_host.local_to_global);
+ data_host.local_to_global = Kokkos::create_mirror(data.local_to_global);
+ Kokkos::deep_copy(data_host.local_to_global, data.local_to_global);
if (update_flags & update_gradients)
{
private:
MatrixFree<dim, Number> *data;
- // Host data
- std::vector<types::global_dof_index> local_to_global_host;
+ Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>
+ local_to_global;
Kokkos::View<Point<dim, Number> **, MemorySpace::Default::kokkos_space>
q_points;
Kokkos::View<Number **, MemorySpace::Default::kokkos_space> JxW;
data->block_dim[color] =
dim3(n_dofs_1d * cells_per_block, n_dofs_1d, n_dofs_1d);
- local_to_global_host.resize(n_cells * padding_length);
+
+ local_to_global = Kokkos::View<types::global_dof_index **,
+ MemorySpace::Default::kokkos_space>(
+ Kokkos::view_alloc("local_to_global_" + std::to_string(color),
+ Kokkos::WithoutInitializing),
+ n_cells,
+ dofs_per_cell);
if (update_flags & update_quadrature_points)
q_points = Kokkos::View<Point<dim, Number> **,
lexicographic_dof_indices,
cell_id_view);
- memcpy(&local_to_global_host[cell_id * padding_length],
- lexicographic_dof_indices.data(),
- dofs_per_cell * sizeof(types::global_dof_index));
+ // FIXME too many deep_copy
+ auto local_to_global_host =
+ Kokkos::create_mirror_view_and_copy(MemorySpace::Host::kokkos_space{},
+ local_to_global);
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
+ local_to_global_host(cell_id, i) = lexicographic_dof_indices[i];
+ Kokkos::deep_copy(local_to_global, local_to_global_host);
fe_values.reinit(cell);
const unsigned int n_cells = data->n_cells[color];
// Local-to-global mapping
- alloc_and_copy(
- &data->local_to_global[color],
- ArrayView<const types::global_dof_index>(local_to_global_host.data(),
- local_to_global_host.size()),
- n_cells * padding_length);
+ data->local_to_global[color] = local_to_global;
// Quadrature points
if (update_flags & update_quadrature_points)
void
MatrixFree<dim, Number>::free()
{
- for (auto &local_to_global_color_ptr : local_to_global)
- Utilities::CUDA::free(local_to_global_color_ptr);
- local_to_global.clear();
-
for (auto &constraint_mask_color_ptr : constraint_mask)
Utilities::CUDA::free(constraint_mask_color_ptr);
constraint_mask.clear();