From ec57499ca89915bd4614d11297da608d3f5106f9 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Thu, 16 Mar 2023 14:11:40 -0400 Subject: [PATCH] Fix a bug when using LA::CUDAWrappers::Vector --- .../matrix_free/cuda_matrix_free.templates.h | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/include/deal.II/matrix_free/cuda_matrix_free.templates.h b/include/deal.II/matrix_free/cuda_matrix_free.templates.h index b3b9b13d2d..9df3cfee63 100644 --- a/include/deal.II/matrix_free/cuda_matrix_free.templates.h +++ b/include/deal.II/matrix_free/cuda_matrix_free.templates.h @@ -576,6 +576,38 @@ namespace CUDAWrappers if (cell < gpu_data.n_cells) func(cell, &gpu_data); } + + + + template + struct VectorLocalSize + { + static unsigned int + get(const VectorType &vec) + { + return vec.locally_owned_size(); + } + }; + + template <> + struct VectorLocalSize> + { + static unsigned int + get(const LinearAlgebra::CUDAWrappers::Vector &vec) + { + return vec.size(); + } + }; + + template <> + struct VectorLocalSize> + { + static unsigned int + get(const LinearAlgebra::CUDAWrappers::Vector &vec) + { + return vec.size(); + } + }; } // namespace internal @@ -738,10 +770,9 @@ namespace CUDAWrappers // FIXME When using C++17, we can use KOKKOS_CLASS_LAMBDA and this // work-around can be removed. types::global_dof_index *constr_dofs = constrained_dofs; - const unsigned int size = - partitioner ? dst.locally_owned_size() : dst.size(); - const Number *src_ptr = src.get_values(); - Number * dst_ptr = dst.get_values(); + const unsigned int size = internal::VectorLocalSize::get(dst); + const Number * src_ptr = src.get_values(); + Number * dst_ptr = dst.get_values(); Kokkos::parallel_for( "copy_constrained_values", Kokkos::RangePolicy( -- 2.39.5