Skip to content

Commit

Permalink
Merge pull request #15941 from kronbichler/pad_some_arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Aug 30, 2023
2 parents e45b1b2 + 32a2c97 commit 9e4242c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions include/deal.II/matrix_free/fe_evaluation_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace internal
std::string,
<< "You are requesting information from an FEEvaluation/FEFaceEvaluation "
<< "object for which this kind of information has not been computed. What "
<< "information these objects compute is determined by the update_* flags you "
<< "pass to MatrixFree::reinit() via MatrixFree::AdditionalData. Here, "
<< "the operation you are attempting requires the <" << arg1
<< "information these objects compute is determined by the update_* flags "
<< "you pass to MatrixFree::reinit() via MatrixFree::AdditionalData. "
<< "Here, the operation you are attempting requires the <" << arg1
<< "> flag to be set, but it was apparently not specified "
<< "upon initialization.");
} // namespace internal
Expand Down Expand Up @@ -1205,31 +1205,34 @@ FEEvaluationData<dim, Number, is_face>::set_data_pointers(
(n_components * ((dim * (dim + 1)) / 2 + 2 * dim + 2) *
n_quadrature_points);

const unsigned int allocated_size = size_scratch_data + size_data_arrays;
// include 12 extra fields to insert some padding between values, gradients
// and hessians, which helps to reduce the probability of cache conflicts
const unsigned int allocated_size = size_scratch_data + size_data_arrays + 12;
# ifdef DEBUG
scratch_data_array->clear();
scratch_data_array->resize(allocated_size,
Number(numbers::signaling_nan<ScalarNumber>()));
# else
scratch_data_array->resize_fast(allocated_size);
# endif
scratch_data.reinit(scratch_data_array->begin() + size_data_arrays,
scratch_data.reinit(scratch_data_array->begin() + size_data_arrays + 12,
size_scratch_data);

// set the pointers to the correct position in the data array
values_dofs = scratch_data_array->begin();
values_quad = scratch_data_array->begin() + n_components * dofs_per_component;
values_quad =
scratch_data_array->begin() + 4 + n_components * dofs_per_component;
values_from_gradients_quad =
scratch_data_array->begin() +
scratch_data_array->begin() + 6 +
n_components * (dofs_per_component + n_quadrature_points);
gradients_quad =
scratch_data_array->begin() +
scratch_data_array->begin() + 8 +
n_components * (dofs_per_component + 2 * n_quadrature_points);
gradients_from_hessians_quad =
scratch_data_array->begin() +
scratch_data_array->begin() + 12 +
n_components * (dofs_per_component + (dim + 2) * n_quadrature_points);
hessians_quad =
scratch_data_array->begin() +
scratch_data_array->begin() + 12 +
n_components * (dofs_per_component + (2 * dim + 2) * n_quadrature_points);
}

Expand Down

0 comments on commit 9e4242c

Please sign in to comment.