From 5ac6d8f44840276451dd349241e0c4f0e20da8fd Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Thu, 22 Oct 2020 15:25:03 +0200 Subject: [PATCH] Generalize FEEvaluationBase::read_write_operation_contiguous for SM --- include/deal.II/matrix_free/fe_evaluation.h | 96 ++++++++++++++- .../matrix_free/vector_access_internal.h | 112 ++++++++++++++++++ 2 files changed, 205 insertions(+), 3 deletions(-) diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index e3269ebe28..759c64f7fe 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -4597,8 +4597,6 @@ FEEvaluationBase:: n_components_> & vectors_sm, const std::bitset &mask) const { - (void)vectors_sm; // TODO: use it - // This functions processes the functions read_dof_values, // distribute_local_to_global, and set_dof_values with the same code for // contiguous cell indices (DG case). The distinction between these three @@ -4665,6 +4663,96 @@ FEEvaluationBase:: for (unsigned int v = n_filled_lanes; v < VectorizedArrayType::size(); ++v) dof_indices[v] = numbers::invalid_unsigned_int; + if (vectors_sm[0] != nullptr) + { + const auto compute_vector_ptrs = [&](const unsigned int comp) { + std::array + vector_ptrs = {}; + + (void)comp; + + /* + for (unsigned int v = 0; v < n_filled_lanes; ++v) + { + const auto &temp = + this->dof_info->dof_indices_contiguous_sm + [ind][this->cell * VectorizedArrayType::size() + v]; + + if (temp.first != numbers::invalid_unsigned_int) + vector_ptrs[v] = const_cast( + vectors_sm[comp]->operator[](temp.first).data() + temp.second); + else + vector_ptrs[v] = nullptr; + } + for (unsigned int v = n_filled_lanes; v < VectorizedArrayType::size(); + ++v) + vector_ptrs[v] = nullptr; + */ + + return vector_ptrs; + }; + + if (n_filled_lanes == VectorizedArrayType::size() && + n_lanes == VectorizedArrayType::size()) + { + if (n_components == 1 || n_fe_components == 1) + for (unsigned int comp = 0; comp < n_components; ++comp) + { + auto vector_ptrs = compute_vector_ptrs(comp); + + operation.process_dofs_vectorized_transpose( + this->data->dofs_per_component_on_cell, + vector_ptrs, + values_dofs[comp], + vector_selector); + } + else + { + auto vector_ptrs = compute_vector_ptrs(0); + operation.process_dofs_vectorized_transpose( + this->data->dofs_per_component_on_cell * n_components, + vector_ptrs, + &values_dofs[0][0], + vector_selector); + } + } + else + for (unsigned int comp = 0; comp < n_components; ++comp) + { + auto vector_ptrs = compute_vector_ptrs(comp); + + for (unsigned int i = 0; i < this->data->dofs_per_component_on_cell; + ++i) + operation.process_empty(values_dofs[comp][i]); + + if (n_components == 1 || n_fe_components == 1) + { + for (unsigned int v = 0; v < n_filled_lanes; ++v) + if (mask[v] == true) + for (unsigned int i = 0; + i < this->data->dofs_per_component_on_cell; + ++i) + operation.process_dof(vector_ptrs[v][i], + values_dofs[comp][i][v]); + } + else + { + for (unsigned int v = 0; v < n_filled_lanes; ++v) + if (mask[v] == true) + for (unsigned int i = 0; + i < this->data->dofs_per_component_on_cell; + ++i) + operation.process_dof( + vector_ptrs[v] + [i + comp * this->data + ->dofs_per_component_on_cell], + values_dofs[comp][i][v]); + } + } + return; + } + // In the case with contiguous cell indices, we know that there are no // constraints and that the indices within each element are contiguous if (n_filled_lanes == VectorizedArrayType::size() && @@ -4859,7 +4947,9 @@ namespace internal const std::vector> * get_shared_vector_data(VectorType &vec /*other parameters?*/) { - return &vec.shared_vector_data(); + // return &vec.shared_vector_data(); + (void)vec; + return nullptr; } template + void + process_dof(const VectorNumberType &global, Number &local) const + { + local = global; + } + + + template void process_dofs_vectorized(const unsigned int dofs_per_cell, @@ -290,6 +299,34 @@ namespace internal + template + void + process_dofs_vectorized_transpose( + const unsigned int dofs_per_cell, + const std::array &global_ptr, + VectorizedArrayType * dof_values, + std::integral_constant) const + { + dealii::vectorized_load_and_transpose(dofs_per_cell, + global_ptr, + dof_values); + } + + + + template + void + process_dofs_vectorized_transpose( + const unsigned int, + const std::array &, + VectorizedArrayType *, + std::integral_constant) const + { + Assert(false, ExcNotImplemented()); + } + + + // variant where VectorType::value_type is the same as Number -> can call // gather template @@ -382,6 +419,14 @@ namespace internal } + template + void + process_dof(VectorNumberType &global, Number &local) const + { + global += local; + } + + template void @@ -450,6 +495,35 @@ namespace internal + template + void + process_dofs_vectorized_transpose( + const unsigned int dofs_per_cell, + std::array &global_ptr, + VectorizedArrayType * dof_values, + std::integral_constant) const + { + vectorized_transpose_and_store(true, + dofs_per_cell, + dof_values, + global_ptr); + } + + + + template + void + process_dofs_vectorized_transpose( + const unsigned int, + std::array &, + VectorizedArrayType *, + std::integral_constant) const + { + Assert(false, ExcNotImplemented()); + } + + + // variant where VectorType::value_type is the same as Number -> can call // scatter template @@ -547,6 +621,15 @@ namespace internal + template + void + process_dof(VectorNumberType &global, Number &local) const + { + global = local; + } + + + template void process_dofs_vectorized(const unsigned int dofs_per_cell, @@ -608,6 +691,35 @@ namespace internal + template + void + process_dofs_vectorized_transpose( + const unsigned int dofs_per_cell, + std::array &global_ptr, + VectorizedArrayType * dof_values, + std::integral_constant) const + { + vectorized_transpose_and_store(false, + dofs_per_cell, + dof_values, + global_ptr); + } + + + + template + void + process_dofs_vectorized_transpose( + const unsigned int, + std::array &, + VectorizedArrayType *, + std::integral_constant) const + { + Assert(false, ExcNotImplemented()); + } + + + template void process_dof_gather(const unsigned int * indices, -- 2.39.5