From: Daniel Arndt Date: Fri, 21 Jul 2023 14:35:19 +0000 (-0400) Subject: CudaWrappers::MatrixFree: Only create required host mirrors X-Git-Tag: relicensing~656^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15777%2Fhead;p=dealii.git CudaWrappers::MatrixFree: Only create required host mirrors --- 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 fb8b6b4fdb..465ca9e94f 100644 --- a/include/deal.II/matrix_free/cuda_matrix_free.templates.h +++ b/include/deal.II/matrix_free/cuda_matrix_free.templates.h @@ -200,25 +200,36 @@ namespace CUDAWrappers auto constraint_mask_host = Kokkos::create_mirror_view(data->constraint_mask[color]); + typename std::remove_reference_tq_points[color])>::HostMirror q_points_host; + typename std::remove_reference_tJxW[color])>::HostMirror + JxW_host; + typename std::remove_reference_tinv_jacobian[color])>::HostMirror inv_jacobian_host; #if KOKKOS_VERSION >= 30600 auto local_to_global_host = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, data->local_to_global[color]); - auto q_points_host = - Kokkos::create_mirror_view(Kokkos::WithoutInitializing, - data->q_points[color]); - auto JxW_host = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, - data->JxW[color]); - auto inv_jacobian_host = - Kokkos::create_mirror_view(Kokkos::WithoutInitializing, - data->inv_jacobian[color]); + if (update_flags & update_quadrature_points) + q_points_host = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, + data->q_points[color]); + if (update_flags & update_JxW_values) + JxW_host = Kokkos::create_mirror_view(Kokkos::WithoutInitializing, + data->JxW[color]); + if (update_flags & update_gradients) + inv_jacobian_host = + Kokkos::create_mirror_view(Kokkos::WithoutInitializing, + data->inv_jacobian[color]); #else auto local_to_global_host = Kokkos::create_mirror_view(data->local_to_global[color]); - auto q_points_host = Kokkos::create_mirror_view(data->q_points[color]); - auto JxW_host = Kokkos::create_mirror_view(data->JxW[color]); - auto inv_jacobian_host = - Kokkos::create_mirror_view(data->inv_jacobian[color]); + if (update_flags & update_quadrature_points) + q_points_host = Kokkos::create_mirror_view(data->q_points[color]); + if (update_flags & update_JxW_values) + JxW_host = Kokkos::create_mirror_view(data->JxW[color]); + if (update_flags & update_gradients) + inv_jacobian_host = + Kokkos::create_mirror_view(data->inv_jacobian[color]); #endif auto cell = graph.cbegin(), end_cell = graph.cend(); @@ -277,9 +288,12 @@ namespace CUDAWrappers // Copy the data to the device Kokkos::deep_copy(data->constraint_mask[color], constraint_mask_host); Kokkos::deep_copy(data->local_to_global[color], local_to_global_host); - Kokkos::deep_copy(data->q_points[color], q_points_host); - Kokkos::deep_copy(data->JxW[color], JxW_host); - Kokkos::deep_copy(data->inv_jacobian[color], inv_jacobian_host); + if (update_flags & update_quadrature_points) + Kokkos::deep_copy(data->q_points[color], q_points_host); + if (update_flags & update_JxW_values) + Kokkos::deep_copy(data->JxW[color], JxW_host); + if (update_flags & update_gradients) + Kokkos::deep_copy(data->inv_jacobian[color], inv_jacobian_host); }