From: David Wells Date: Mon, 25 May 2020 16:13:42 +0000 (-0400) Subject: locally_owned_size() in partitioner X-Git-Tag: v9.3.0-rc1~449^2~11 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e7cd9ef002a4926056bb78043f208cda8513d64;p=dealii.git locally_owned_size() in partitioner --- diff --git a/include/deal.II/base/partitioner.h b/include/deal.II/base/partitioner.h index 33717041e4..0d8ffe7124 100644 --- a/include/deal.II/base/partitioner.h +++ b/include/deal.II/base/partitioner.h @@ -123,9 +123,10 @@ namespace Utilities * The partitioner includes a mechanism for converting global to local and * local to global indices. Internally, this class stores vector elements * using the convention as follows: The local range is associated with - * local indices [0,@p local_size), and ghost indices are stored - * consecutively in [@p local_size, @p local_size + @p n_ghost_indices). - * The ghost indices are sorted according to their global index. + * local indices [0, locally_owned_size()), and ghost indices are stored + * consecutively in [locally_owned_size(), locally_owned_size() + + * n_ghost_indices()). The ghost indices are sorted according to their + * global index. * * *

Parallel data exchange

@@ -282,12 +283,23 @@ namespace Utilities size() const; /** - * Return the local size, i.e. local_range().second minus - * local_range().first. + * Return the number of locally owned indices, + * i.e., local_range().second minus local_range().first. + * + * @deprecated Use the more clearly named function locally_owned_size() + * instead. */ + DEAL_II_DEPRECATED unsigned int local_size() const; + /** + * Return the number of locally owned indices, + * i.e., local_range().second minus local_range().first. + */ + unsigned int + locally_owned_size() const; + /** * Return an IndexSet representation of the local range. This class * only supports contiguous local ranges, so the IndexSet actually only @@ -317,10 +329,10 @@ namespace Utilities * the given global index is neither locally owned nor a ghost, an * exception is thrown. * - * Note that the returned local index for locally owned indices - * will be between 0 and - * `local_size()-1`, and the local index for ghosts is between - * `local_size()` and `local_size()+n_ghost_indices()-1`. + * Note that the returned local index for locally owned indices will be + * between 0 and locally_owned_size() - 1, and the local index for + * ghosts is between locally_owned_size() and locally_owned_size() + + * n_ghost_indices() - 1. */ unsigned int global_to_local(const types::global_dof_index global_index) const; @@ -329,8 +341,9 @@ namespace Utilities * Return the global index corresponding to the given local index. * * Note that the local index for locally owned indices must be between 0 - * and `local_size()-1`, and the local index for ghosts must be between - * `local_size()` and `local_size()+n_ghost_indices()-1`. + * and locally_owned_size() - 1, and the local index for ghosts must be + * between locally_owned_size() and locally_owned_size() + + * n_ghost_indices() - 1. */ types::global_dof_index local_to_global(const unsigned int local_index) const; @@ -810,6 +823,14 @@ namespace Utilities inline unsigned int Partitioner::local_size() const + { + return locally_owned_size(); + } + + + + inline unsigned int + Partitioner::locally_owned_size() const { types::global_dof_index size = local_range_data.second - local_range_data.first; @@ -852,7 +873,7 @@ namespace Utilities if (in_local_range(global_index)) return static_cast(global_index - local_range_data.first); else if (is_ghost_entry(global_index)) - return (local_size() + + return (locally_owned_size() + static_cast( ghost_indices_data.index_within_set(global_index))); else @@ -867,11 +888,13 @@ namespace Utilities inline types::global_dof_index Partitioner::local_to_global(const unsigned int local_index) const { - AssertIndexRange(local_index, local_size() + n_ghost_indices_data); - if (local_index < local_size()) + AssertIndexRange(local_index, + locally_owned_size() + n_ghost_indices_data); + if (local_index < locally_owned_size()) return local_range_data.first + types::global_dof_index(local_index); else - return ghost_indices_data.nth_index_in_set(local_index - local_size()); + return ghost_indices_data.nth_index_in_set(local_index - + locally_owned_size()); } diff --git a/include/deal.II/base/partitioner.templates.h b/include/deal.II/base/partitioner.templates.h index dd10f66c3f..4ea19aecc4 100644 --- a/include/deal.II/base/partitioner.templates.h +++ b/include/deal.II/base/partitioner.templates.h @@ -58,7 +58,7 @@ namespace Utilities const unsigned int n_ghost_targets = ghost_targets_data.size(); if (n_import_targets > 0) - AssertDimension(locally_owned_array.size(), local_size()); + AssertDimension(locally_owned_array.size(), locally_owned_size()); Assert(requests.size() == 0, ExcMessage("Another operation seems to still be running. " @@ -576,7 +576,7 @@ namespace Utilities // first wait for the receive to complete if (requests.size() > 0 && n_import_targets > 0) { - AssertDimension(locally_owned_array.size(), local_size()); + AssertDimension(locally_owned_array.size(), locally_owned_size()); const int ierr = MPI_Waitall(n_import_targets, requests.data(), MPI_STATUSES_IGNORE); AssertThrowMPI(ierr); diff --git a/include/deal.II/lac/la_parallel_block_vector.templates.h b/include/deal.II/lac/la_parallel_block_vector.templates.h index 75bb7d2707..bd31e026d8 100644 --- a/include/deal.II/lac/la_parallel_block_vector.templates.h +++ b/include/deal.II/lac/la_parallel_block_vector.templates.h @@ -674,9 +674,9 @@ namespace LinearAlgebra Number local_result = Number(); for (unsigned int i = 0; i < this->n_blocks(); ++i) - local_result += - this->block(i).mean_value_local() * - static_cast(this->block(i).partitioner->local_size()); + local_result += this->block(i).mean_value_local() * + static_cast( + this->block(i).partitioner->locally_owned_size()); if (this->block(0).partitioner->n_mpi_processes() > 1) return Utilities::MPI::sum( diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index 42b1220d04..107b9a2e79 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1534,7 +1534,7 @@ namespace LinearAlgebra inline typename Vector::size_type Vector::locally_owned_size() const { - return partitioner->local_size(); + return partitioner->locally_owned_size(); } @@ -1586,7 +1586,7 @@ namespace LinearAlgebra Vector::end() { return internal::Policy::begin(data) + - partitioner->local_size(); + partitioner->locally_owned_size(); } @@ -1596,7 +1596,7 @@ namespace LinearAlgebra Vector::end() const { return internal::Policy::begin(data) + - partitioner->local_size(); + partitioner->locally_owned_size(); } @@ -1686,7 +1686,7 @@ namespace LinearAlgebra ExcMessage( "This function is only implemented for the Host memory space")); AssertIndexRange(local_index, - partitioner->local_size() + + partitioner->locally_owned_size() + partitioner->n_ghost_indices()); // do not allow reading a vector which is not in ghost mode Assert(local_index < local_size() || vector_is_ghosted == true, @@ -1707,7 +1707,7 @@ namespace LinearAlgebra "This function is only implemented for the Host memory space")); AssertIndexRange(local_index, - partitioner->local_size() + + partitioner->locally_owned_size() + partitioner->n_ghost_indices()); return data.values[local_index]; diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 28c4330265..f41ff44c52 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -591,7 +591,7 @@ namespace LinearAlgebra { partitioner = v.partitioner; const size_type new_allocated_size = - partitioner->local_size() + partitioner->n_ghost_indices(); + partitioner->locally_owned_size() + partitioner->n_ghost_indices(); resize_val(new_allocated_size, this->comm_sm); } @@ -653,7 +653,7 @@ namespace LinearAlgebra // set vector size and allocate memory const size_type new_allocated_size = - partitioner->local_size() + partitioner->n_ghost_indices(); + partitioner->locally_onwed_size() + partitioner->n_ghost_indices(); resize_val(new_allocated_size, comm_sm); // initialize to zero @@ -700,7 +700,10 @@ namespace LinearAlgebra { dealii::internal::VectorOperations:: functions::copy( - thread_loop_partitioner, partitioner->local_size(), v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + v.data, + data); } } @@ -835,7 +838,7 @@ namespace LinearAlgebra thread_loop_partitioner = c.thread_loop_partitioner; - const size_type this_size = partitioner->local_size(); + const size_type this_size = partitioner->locally_owned_size(); if (this_size > 0) { dealii::internal::VectorOperations:: @@ -858,13 +861,14 @@ namespace LinearAlgebra Vector::copy_locally_owned_data_from( const Vector &src) { - AssertDimension(partitioner->local_size(), src.partitioner->local_size()); - if (partitioner->local_size() > 0) + AssertDimension(partitioner->locally_owned_size(), + src.partitioner->locally_owned_size()); + if (partitioner->locally_owned_size() > 0) { dealii::internal::VectorOperations:: functions::copy( thread_loop_partitioner, - partitioner->local_size(), + partitioner->locally_owned_size(), src.data, data); } @@ -927,14 +931,15 @@ namespace LinearAlgebra Vector::zero_out_ghost_values() const { if (data.values != nullptr) - std::fill_n(data.values.get() + partitioner->local_size(), + std::fill_n(data.values.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices(), Number()); #ifdef DEAL_II_COMPILER_CUDA_AWARE if (data.values_dev != nullptr) { const cudaError_t cuda_error_code = - cudaMemset(data.values_dev.get() + partitioner->local_size(), + cudaMemset(data.values_dev.get() + + partitioner->locally_owned_size(), 0, partitioner->n_ghost_indices() * sizeof(Number)); AssertCuda(cuda_error_code); @@ -1025,7 +1030,7 @@ namespace LinearAlgebra operation, communication_channel, ArrayView( - data.values_dev.get() + partitioner->local_size(), + data.values_dev.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), ArrayView( import_data.values_dev.get(), partitioner->n_import_indices()), @@ -1038,7 +1043,7 @@ namespace LinearAlgebra operation, communication_channel, ArrayView( - data.values.get() + partitioner->local_size(), + data.values.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), ArrayView( import_data.values.get(), partitioner->n_import_indices()), @@ -1078,10 +1083,10 @@ namespace LinearAlgebra operation, ArrayView( import_data.values_dev.get(), partitioner->n_import_indices()), - ArrayView(data.values_dev.get(), - partitioner->local_size()), ArrayView( - data.values_dev.get() + partitioner->local_size(), + data.values_dev.get(), partitioner->locally_owned_size()), + ArrayView( + data.values_dev.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), compress_requests); } @@ -1096,10 +1101,10 @@ namespace LinearAlgebra operation, ArrayView( import_data.values.get(), partitioner->n_import_indices()), - ArrayView(data.values.get(), - partitioner->local_size()), ArrayView( - data.values.get() + partitioner->local_size(), + data.values.get(), partitioner->locally_owned_size()), + ArrayView( + data.values.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), compress_requests); } @@ -1197,24 +1202,24 @@ namespace LinearAlgebra defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)) partitioner->export_to_ghosted_array_start( communication_channel, - ArrayView(data.values.get(), - partitioner->local_size()), + ArrayView( + data.values.get(), partitioner->locally_owned_size()), ArrayView(import_data.values.get(), partitioner->n_import_indices()), - ArrayView(data.values.get() + - partitioner->local_size(), - partitioner->n_ghost_indices()), + ArrayView( + data.values.get() + partitioner->locally_owned_size(), + partitioner->n_ghost_indices()), update_ghost_values_requests); # else partitioner->export_to_ghosted_array_start( communication_channel, - ArrayView(data.values_dev.get(), - partitioner->local_size()), + ArrayView( + data.values_dev.get(), partitioner->locally_owned_size()), ArrayView(import_data.values_dev.get(), partitioner->n_import_indices()), - ArrayView(data.values_dev.get() + - partitioner->local_size(), - partitioner->n_ghost_indices()), + ArrayView( + data.values_dev.get() + partitioner->locally_owned_size(), + partitioner->n_ghost_indices()), update_ghost_values_requests); # endif @@ -1244,13 +1249,13 @@ namespace LinearAlgebra defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)) partitioner->export_to_ghosted_array_finish( ArrayView( - data.values.get() + partitioner->local_size(), + data.values.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), update_ghost_values_requests); # else partitioner->export_to_ghosted_array_finish( ArrayView( - data.values_dev.get() + partitioner->local_size(), + data.values_dev.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices()), update_ghost_values_requests); # endif @@ -1263,8 +1268,9 @@ namespace LinearAlgebra if (std::is_same::value) { cudaError_t cuda_error_code = - cudaMemcpy(data.values_dev.get() + partitioner->local_size(), - data.values.get() + partitioner->local_size(), + cudaMemcpy(data.values_dev.get() + + partitioner->locally_owned_size(), + data.values.get() + partitioner->locally_owned_size(), partitioner->n_ghost_indices() * sizeof(Number), cudaMemcpyHostToDevice); AssertCuda(cuda_error_code); @@ -1467,7 +1473,10 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::add_vector( - thread_loop_partitioner, partitioner->local_size(), v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + v.data, + data); if (vector_is_ghosted) update_ghost_values(); @@ -1492,7 +1501,10 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::subtract_vector( - thread_loop_partitioner, partitioner->local_size(), v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + v.data, + data); if (vector_is_ghosted) update_ghost_values(); @@ -1510,7 +1522,7 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::add_factor( - thread_loop_partitioner, partitioner->local_size(), a, data); + thread_loop_partitioner, partitioner->locally_owned_size(), a, data); if (vector_is_ghosted) update_ghost_values(); @@ -1539,7 +1551,11 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::add_av( - thread_loop_partitioner, partitioner->local_size(), a, v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + a, + v.data, + data); } @@ -1582,7 +1598,7 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::add_avpbw( thread_loop_partitioner, - partitioner->local_size(), + partitioner->locally_owned_size(), a, b, v.data, @@ -1619,7 +1635,11 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::sadd_xv( - thread_loop_partitioner, partitioner->local_size(), x, v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + x, + v.data, + data); if (vector_is_ghosted) update_ghost_values(); @@ -1647,7 +1667,7 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::sadd_xav( thread_loop_partitioner, - partitioner->local_size(), + partitioner->locally_owned_size(), x, a, v.data, @@ -1678,7 +1698,10 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::multiply_factor( - thread_loop_partitioner, partitioner->local_size(), factor, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + factor, + data); if (vector_is_ghosted) update_ghost_values(); @@ -1736,7 +1759,11 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::equ_au( - thread_loop_partitioner, partitioner->local_size(), a, v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + a, + v.data, + data); if (vector_is_ghosted) @@ -1763,11 +1790,15 @@ namespace LinearAlgebra if (PointerComparison::equal(this, &v)) return norm_sqr_local(); - AssertDimension(partitioner->local_size(), v.partitioner->local_size()); + AssertDimension(partitioner->locally_owned_size(), + v.partitioner->locally_owned_size()); return dealii::internal::VectorOperations:: functions::dot( - thread_loop_partitioner, partitioner->local_size(), v.data, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + v.data, + data); } @@ -1801,7 +1832,10 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::norm_2( - thread_loop_partitioner, partitioner->local_size(), sum, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + sum, + data); AssertIsFinite(sum); @@ -1816,14 +1850,14 @@ namespace LinearAlgebra { Assert(size() != 0, ExcEmptyObject()); - if (partitioner->local_size() == 0) + if (partitioner->locally_owned_size() == 0) return Number(); Number sum = ::dealii::internal::VectorOperations:: functions::mean_value( - thread_loop_partitioner, partitioner->local_size(), data); + thread_loop_partitioner, partitioner->locally_owned_size(), data); - return sum / real_type(partitioner->local_size()); + return sum / real_type(partitioner->locally_owned_size()); } @@ -1834,8 +1868,9 @@ namespace LinearAlgebra { Number local_result = mean_value_local(); if (partitioner->n_mpi_processes() > 1) - return Utilities::MPI::sum(local_result * static_cast( - partitioner->local_size()), + return Utilities::MPI::sum(local_result * + static_cast( + partitioner->locally_owned_size()), partitioner->get_mpi_communicator()) / static_cast(partitioner->size()); else @@ -1852,7 +1887,10 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::norm_1( - thread_loop_partitioner, partitioner->local_size(), sum, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + sum, + data); return sum; } @@ -1904,7 +1942,11 @@ namespace LinearAlgebra dealii::internal::VectorOperations:: functions::norm_p( - thread_loop_partitioner, partitioner->local_size(), sum, p, data); + thread_loop_partitioner, + partitioner->locally_owned_size(), + sum, + p, + data); return std::pow(sum, 1. / p); } @@ -1933,7 +1975,7 @@ namespace LinearAlgebra { real_type max = 0.; - const size_type local_size = partitioner->local_size(); + const size_type local_size = partitioner->locally_owned_size(); internal::la_parallel_vector_templates_functions< Number, MemorySpaceType>::linfty_norm_local(data, local_size, max); @@ -1964,7 +2006,7 @@ namespace LinearAlgebra const Vector &v, const Vector &w) { - const size_type vec_size = partitioner->local_size(); + const size_type vec_size = partitioner->locally_owned_size(); AssertDimension(vec_size, v.local_size()); AssertDimension(vec_size, w.local_size()); @@ -2085,10 +2127,10 @@ namespace LinearAlgebra << "), global size: " << partitioner->size() << std::endl << "Vector data:" << std::endl; if (across) - for (size_type i = 0; i < partitioner->local_size(); ++i) + for (size_type i = 0; i < partitioner->locally_owned_size(); ++i) out << stored_elements[i] << ' '; else - for (size_type i = 0; i < partitioner->local_size(); ++i) + for (size_type i = 0; i < partitioner->locally_owned_size(); ++i) out << stored_elements[i] << std::endl; out << std::endl; @@ -2098,12 +2140,14 @@ namespace LinearAlgebra if (across) for (size_type i = 0; i < partitioner->n_ghost_indices(); ++i) out << '(' << partitioner->ghost_indices().nth_index_in_set(i) - << '/' << stored_elements[partitioner->local_size() + i] + << '/' + << stored_elements[partitioner->locally_owned_size() + i] << ") "; else for (size_type i = 0; i < partitioner->n_ghost_indices(); ++i) out << '(' << partitioner->ghost_indices().nth_index_in_set(i) - << '/' << stored_elements[partitioner->local_size() + i] + << '/' + << stored_elements[partitioner->locally_owned_size() + i] << ")" << std::endl; out << std::endl; } diff --git a/include/deal.II/lac/read_write_vector.templates.h b/include/deal.II/lac/read_write_vector.templates.h index 639becf5f4..6dcef4b413 100644 --- a/include/deal.II/lac/read_write_vector.templates.h +++ b/include/deal.II/lac/read_write_vector.templates.h @@ -130,7 +130,8 @@ namespace LinearAlgebra distributed::Vector tmp_vector( communication_pattern); - const unsigned int n_elements = communication_pattern->local_size(); + const unsigned int n_elements = + communication_pattern->locally_owned_size(); std::copy(values, values + n_elements, tmp_vector.begin()); tmp_vector.update_ghost_values(); @@ -173,8 +174,9 @@ namespace LinearAlgebra distributed::Vector tmp_vector( communication_pattern); - const unsigned int n_elements = communication_pattern->local_size(); - cudaError_t cuda_error_code = cudaMemcpy(tmp_vector.begin(), + const unsigned int n_elements = + communication_pattern->locally_owned_size(); + cudaError_t cuda_error_code = cudaMemcpy(tmp_vector.begin(), values, n_elements * sizeof(Number), cudaMemcpyDeviceToHost); diff --git a/include/deal.II/matrix_free/dof_info.templates.h b/include/deal.II/matrix_free/dof_info.templates.h index 432f2d505f..59274ade9d 100644 --- a/include/deal.II/matrix_free/dof_info.templates.h +++ b/include/deal.II/matrix_free/dof_info.templates.h @@ -1552,7 +1552,7 @@ namespace internal // touched by a cell AssertDimension(length, vectorization_length); const unsigned int n_components = start_components.back(); - const unsigned int n_dofs = vector_partitioner->local_size() + + const unsigned int n_dofs = vector_partitioner->locally_owned_size() + vector_partitioner->n_ghost_indices(); std::vector touched_first_by( (n_dofs + chunk_size_zero_vector - 1) / chunk_size_zero_vector, @@ -1671,13 +1671,13 @@ namespace internal chunk_must_zero_vector, vector_zero_range_list_index, vector_zero_range_list, - vector_partitioner->local_size()); + vector_partitioner->locally_owned_size()); // the other two operations only work on the local range (without // ghosts), so we skip the latter parts of the vector now - touched_first_by.resize( - (vector_partitioner->local_size() + chunk_size_zero_vector - 1) / - chunk_size_zero_vector); + touched_first_by.resize((vector_partitioner->locally_owned_size() + + chunk_size_zero_vector - 1) / + chunk_size_zero_vector); // set the import indices in the vector partitioner to one index higher // to indicate that we want to process it first. This additional index @@ -1693,11 +1693,11 @@ namespace internal chunk_must_do_pre, cell_loop_pre_list_index, cell_loop_pre_list, - vector_partitioner->local_size()); + vector_partitioner->locally_owned_size()); - touched_last_by.resize( - (vector_partitioner->local_size() + chunk_size_zero_vector - 1) / - chunk_size_zero_vector); + touched_last_by.resize((vector_partitioner->locally_owned_size() + + chunk_size_zero_vector - 1) / + chunk_size_zero_vector); // set the indices which were not touched by the cell loop (i.e., // constrained indices) to the last valid partition index. Since @@ -1720,7 +1720,7 @@ namespace internal chunk_must_do_post, cell_loop_post_list_index, cell_loop_post_list, - vector_partitioner->local_size()); + vector_partitioner->locally_owned_size()); } @@ -1972,9 +1972,10 @@ namespace internal DoFInfo::compute_dof_renumbering( std::vector &renumbering) { - const unsigned int local_size = vector_partitioner->local_size(); + const unsigned int locally_owned_size = + vector_partitioner->locally_owned_size(); renumbering.resize(0); - renumbering.resize(local_size, numbers::invalid_dof_index); + renumbering.resize(locally_owned_size, numbers::invalid_dof_index); types::global_dof_index counter = 0; const unsigned int n_components = start_components.back(); @@ -2004,14 +2005,14 @@ namespace internal for (unsigned int j = 0; j < n_vectorization_lanes_filled[dof_access_cell][cell_no]; ++j) - if (dof_ind[j * ndofs + i] < local_size) + if (dof_ind[j * ndofs + i] < locally_owned_size) if (renumbering[dof_ind[j * ndofs + i]] == numbers::invalid_dof_index) renumbering[dof_ind[j * ndofs + i]] = counter++; } } - AssertIndexRange(counter, local_size + 1); + AssertIndexRange(counter, locally_owned_size + 1); for (types::global_dof_index &dof_index : renumbering) if (dof_index == numbers::invalid_dof_index) dof_index = counter++; diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index 6e407a2053..15aa5ffab1 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -3466,10 +3466,10 @@ namespace internal part.export_to_ghosted_array_start( component_in_block_vector * 2 + channel_shift, - ArrayView(vec.begin(), part.local_size()), + ArrayView(vec.begin(), part.locally_owned_size()), vec.shared_vector_data(), ArrayView(const_cast(vec.begin()) + - part.local_size(), + part.locally_owned_size(), matrix_free.get_dof_info(mf_component) .vector_partitioner->n_ghost_indices()), ArrayView(tmp_data[component_in_block_vector]->begin(), @@ -3550,10 +3550,10 @@ namespace internal part.n_import_sm_procs() != 0) { part.export_to_ghosted_array_finish( - ArrayView(vec.begin(), part.local_size()), + ArrayView(vec.begin(), part.locally_owned_size()), vec.shared_vector_data(), ArrayView(const_cast(vec.begin()) + - part.local_size(), + part.locally_owned_size(), matrix_free.get_dof_info(mf_component) .vector_partitioner->n_ghost_indices()), this->requests[component_in_block_vector]); @@ -3664,12 +3664,10 @@ namespace internal part.import_from_ghosted_array_start( dealii::VectorOperation::add, - component_in_block_vector * 2 + channel_shift, - ArrayView(vec.begin(), part.local_size()), - vec.shared_vector_data(), - ArrayView(vec.begin() + part.local_size(), - matrix_free.get_dof_info(mf_component) - .vector_partitioner->n_ghost_indices()), + component_in_block_vector + channel_shift, + ArrayView(vec.begin() + + vec.get_partitioner()->locally_owned_size(), + vec.get_partitioner()->n_ghost_indices()), ArrayView(tmp_data[component_in_block_vector]->begin(), part.n_import_indices()), this->requests[component_in_block_vector]); @@ -3747,9 +3745,9 @@ namespace internal { part.import_from_ghosted_array_finish( VectorOperation::add, - ArrayView(vec.begin(), part.local_size()), + ArrayView(vec.begin(), part.locally_owned_size()), vec.shared_vector_data(), - ArrayView(vec.begin() + part.local_size(), + ArrayView(vec.begin() + part.locally_owned_size(), matrix_free.get_dof_info(mf_component) .vector_partitioner->n_ghost_indices()), ArrayView( @@ -3830,12 +3828,19 @@ namespace internal if (part.n_ghost_indices() > 0) { - part.reset_ghost_values(ArrayView( - const_cast &>(vec) - .begin() + - part.local_size(), - matrix_free.get_dof_info(mf_component) - .vector_partitioner->n_ghost_indices())); + for (std::vector>:: + const_iterator my_ghosts = + part.ghost_indices_within_larger_ghost_set().begin(); + my_ghosts != + part.ghost_indices_within_larger_ghost_set().end(); + ++my_ghosts) + for (unsigned int j = my_ghosts->first; j < my_ghosts->second; + j++) + { + const_cast &>( + vec) + .local_element(j + part.locally_owned_size()) = 0.; + } } # endif @@ -4742,7 +4747,7 @@ namespace internal // Case with threaded loop -> currently no overlap implemented dealii::parallel::apply_to_subranges( 0U, - dof_info.vector_partitioner->local_size(), + dof_info.vector_partitioner->locally_owned_size(), operation_before_loop, internal::VectorImplementation::minimum_parallel_grain_size); } @@ -4772,7 +4777,7 @@ namespace internal // Case with threaded loop -> currently no overlap implemented dealii::parallel::apply_to_subranges( 0U, - dof_info.vector_partitioner->local_size(), + dof_info.vector_partitioner->locally_owned_size(), operation_after_loop, internal::VectorImplementation::minimum_parallel_grain_size); } diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 6b2945e16e..c72d24d994 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -1375,11 +1375,14 @@ namespace MatrixFreeOperators // If not, assert that the local ranges are the same and reset to the // current partitioner - Assert( - BlockHelper::subblock(src, i).get_partitioner()->local_size() == - data->get_dof_info(mf_component).vector_partitioner->local_size(), - ExcMessage("The vector passed to the vmult() function does not have " - "the correct size for compatibility with MatrixFree.")); + Assert(BlockHelper::subblock(src, i) + .get_partitioner() + ->locally_owned_size() == + data->get_dof_info(mf_component) + .vector_partitioner->locally_owned_size(), + ExcMessage( + "The vector passed to the vmult() function does not have " + "the correct size for compatibility with MatrixFree.")); // copy the vector content to a temporary vector so that it does not get // lost diff --git a/source/base/partitioner.cc b/source/base/partitioner.cc index b0eee440d6..33acfd77ba 100644 --- a/source/base/partitioner.cc +++ b/source/base/partitioner.cc @@ -227,7 +227,7 @@ namespace Utilities return; } - types::global_dof_index my_size = local_size(); + types::global_dof_index my_size = locally_owned_size(); // Allow non-zero start index for the vector. Part 1: // Assume for now that the index set of rank 0 starts with 0 @@ -258,9 +258,10 @@ namespace Utilities // information. if (local_range_data.first == 0 && my_shift != 0) { - const types::global_dof_index old_local_size = local_size(); - local_range_data.first = my_shift; - local_range_data.second = my_shift + old_local_size; + const types::global_dof_index old_locally_owned_size = + locally_owned_size(); + local_range_data.first = my_shift; + local_range_data.second = my_shift + old_locally_owned_size; } std::vector owning_ranks_of_ghosts(