]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Let ArrayView have a MemorySpace template parameter
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 2 Nov 2018 19:33:25 +0000 (20:33 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 4 Jan 2019 14:14:38 +0000 (15:14 +0100)
include/deal.II/base/partitioner.h
include/deal.II/base/partitioner.templates.h
include/deal.II/lac/la_parallel_vector.templates.h
source/base/partitioner.cuda.inst.in
source/base/partitioner.inst.in
tests/cuda/parallel_partitioner_06.cu
tests/cuda/parallel_partitioner_07.cu
tests/cuda/parallel_partitioner_08.cu

index ec65709bb5fb92463d46677ec630d607708f4c1b..440ada19413034da8a6d681a06cb3441402c7f9a 100644 (file)
@@ -423,11 +423,11 @@ namespace Utilities
       template <typename Number, typename MemorySpaceType = MemorySpace::Host>
       void
       export_to_ghosted_array_start(
-        const unsigned int             communication_channel,
-        const ArrayView<const Number> &locally_owned_array,
-        const ArrayView<Number> &      temporary_storage,
-        const ArrayView<Number> &      ghost_array,
-        std::vector<MPI_Request> &     requests) const;
+        const unsigned int                              communication_channel,
+        const ArrayView<const Number, MemorySpaceType> &locally_owned_array,
+        const ArrayView<Number, MemorySpaceType> &      temporary_storage,
+        const ArrayView<Number, MemorySpaceType> &      ghost_array,
+        std::vector<MPI_Request> &                      requests) const;
 
       /**
        * Finish the exports of the data in a locally owned array to the range
@@ -448,8 +448,9 @@ namespace Utilities
        */
       template <typename Number, typename MemorySpaceType = MemorySpace::Host>
       void
-      export_to_ghosted_array_finish(const ArrayView<Number> & ghost_array,
-                                     std::vector<MPI_Request> &requests) const;
+      export_to_ghosted_array_finish(
+        const ArrayView<Number, MemorySpaceType> &ghost_array,
+        std::vector<MPI_Request> &                requests) const;
 
       /**
        * Start importing the data on an array indexed by the ghost indices of
@@ -490,11 +491,11 @@ namespace Utilities
       template <typename Number, typename MemorySpaceType = MemorySpace::Host>
       void
       import_from_ghosted_array_start(
-        const VectorOperation::values vector_operation,
-        const unsigned int            communication_channel,
-        const ArrayView<Number> &     ghost_array,
-        const ArrayView<Number> &     temporary_storage,
-        std::vector<MPI_Request> &    requests) const;
+        const VectorOperation::values             vector_operation,
+        const unsigned int                        communication_channel,
+        const ArrayView<Number, MemorySpaceType> &ghost_array,
+        const ArrayView<Number, MemorySpaceType> &temporary_storage,
+        std::vector<MPI_Request> &                requests) const;
 
       /**
        * Finish importing the data from an array indexed by the ghost
@@ -533,11 +534,11 @@ namespace Utilities
       template <typename Number, typename MemorySpaceType = MemorySpace::Host>
       void
       import_from_ghosted_array_finish(
-        const VectorOperation::values  vector_operation,
-        const ArrayView<const Number> &temporary_storage,
-        const ArrayView<Number> &      locally_owned_storage,
-        const ArrayView<Number> &      ghost_array,
-        std::vector<MPI_Request> &     requests) const;
+        const VectorOperation::values                   vector_operation,
+        const ArrayView<const Number, MemorySpaceType> &temporary_storage,
+        const ArrayView<Number, MemorySpaceType> &      locally_owned_storage,
+        const ArrayView<Number, MemorySpaceType> &      ghost_array,
+        std::vector<MPI_Request> &                      requests) const;
 #endif
 
       /**
index 5e9d5cc8e43292e9380847e310176c89dff5860b..f21e4e65c2a622c5572ea10329bab4b8c27e9803 100644 (file)
@@ -40,11 +40,11 @@ namespace Utilities
     template <typename Number, typename MemorySpaceType>
     void
     Partitioner::export_to_ghosted_array_start(
-      const unsigned int             communication_channel,
-      const ArrayView<const Number> &locally_owned_array,
-      const ArrayView<Number> &      temporary_storage,
-      const ArrayView<Number> &      ghost_array,
-      std::vector<MPI_Request> &     requests) const
+      const unsigned int                              communication_channel,
+      const ArrayView<const Number, MemorySpaceType> &locally_owned_array,
+      const ArrayView<Number, MemorySpaceType> &      temporary_storage,
+      const ArrayView<Number, MemorySpaceType> &      ghost_array,
+      std::vector<MPI_Request> &                      requests) const
     {
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
@@ -153,8 +153,8 @@ namespace Utilities
     template <typename Number, typename MemorySpaceType>
     void
     Partitioner::export_to_ghosted_array_finish(
-      const ArrayView<Number> & ghost_array,
-      std::vector<MPI_Request> &requests) const
+      const ArrayView<Number, MemorySpaceType> &ghost_array,
+      std::vector<MPI_Request> &                requests) const
     {
       Assert(ghost_array.size() == n_ghost_indices() ||
                ghost_array.size() == n_ghost_indices_in_larger_set,
@@ -238,11 +238,11 @@ namespace Utilities
     template <typename Number, typename MemorySpaceType>
     void
     Partitioner::import_from_ghosted_array_start(
-      const VectorOperation::values vector_operation,
-      const unsigned int            communication_channel,
-      const ArrayView<Number> &     ghost_array,
-      const ArrayView<Number> &     temporary_storage,
-      std::vector<MPI_Request> &    requests) const
+      const VectorOperation::values             vector_operation,
+      const unsigned int                        communication_channel,
+      const ArrayView<Number, MemorySpaceType> &ghost_array,
+      const ArrayView<Number, MemorySpaceType> &temporary_storage,
+      std::vector<MPI_Request> &                requests) const
     {
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
@@ -464,11 +464,11 @@ namespace Utilities
     template <typename Number, typename MemorySpaceType>
     void
     Partitioner::import_from_ghosted_array_finish(
-      const VectorOperation::values  vector_operation,
-      const ArrayView<const Number> &temporary_storage,
-      const ArrayView<Number> &      locally_owned_array,
-      const ArrayView<Number> &      ghost_array,
-      std::vector<MPI_Request> &     requests) const
+      const VectorOperation::values                   vector_operation,
+      const ArrayView<const Number, MemorySpaceType> &temporary_storage,
+      const ArrayView<Number, MemorySpaceType> &      locally_owned_array,
+      const ArrayView<Number, MemorySpaceType> &      ghost_array,
+      std::vector<MPI_Request> &                      requests) const
     {
       AssertDimension(temporary_storage.size(), n_import_indices());
       Assert(ghost_array.size() == n_ghost_indices() ||
index d6d7295389917ff20d9a57332267c0dc1b43e9ee..84eb0b5f92f881acf06eb9b2bec89f0b3f6a709d 100644 (file)
@@ -944,19 +944,21 @@ namespace LinearAlgebra
       partitioner->import_from_ghosted_array_start(
         operation,
         counter,
-        ArrayView<Number>(data.values.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
-        ArrayView<Number>(import_data.values.get(),
-                          partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::Host>(data.values.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
+        ArrayView<Number, MemorySpace::Host>(import_data.values.get(),
+                                             partitioner->n_import_indices()),
         compress_requests);
 #  else
       partitioner->import_from_ghosted_array_start(
         operation,
         counter,
-        ArrayView<Number>(data.values_dev.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
-        ArrayView<Number>(import_data.values_dev.get(),
-                          partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
+        ArrayView<Number, MemorySpace::CUDA>(import_data.values_dev.get(),
+                                             partitioner->n_import_indices()),
         compress_requests);
 #  endif
 #endif
@@ -985,11 +987,13 @@ namespace LinearAlgebra
              ExcNotInitialized());
       partitioner->import_from_ghosted_array_finish<Number, MemorySpace::Host>(
         operation,
-        ArrayView<const Number>(import_data.values.get(),
-                                partitioner->n_import_indices()),
-        ArrayView<Number>(data.values.get(), partitioner->local_size()),
-        ArrayView<Number>(data.values.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
+        ArrayView<const Number, MemorySpace::Host>(
+          import_data.values.get(), partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::Host>(data.values.get(),
+                                             partitioner->local_size()),
+        ArrayView<Number, MemorySpace::Host>(data.values.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
         compress_requests);
 #  else
       Assert(partitioner->n_import_indices() == 0 ||
@@ -997,11 +1001,13 @@ namespace LinearAlgebra
              ExcNotInitialized());
       partitioner->import_from_ghosted_array_finish<Number, MemorySpace::CUDA>(
         operation,
-        ArrayView<const Number>(import_data.values_dev.get(),
-                                partitioner->n_import_indices()),
-        ArrayView<Number>(data.values_dev.get(), partitioner->local_size()),
-        ArrayView<Number>(data.values_dev.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
+        ArrayView<const Number, MemorySpace::CUDA>(
+          import_data.values_dev.get(), partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get(),
+                                             partitioner->local_size()),
+        ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
         compress_requests);
 #  endif
 
@@ -1095,23 +1101,26 @@ namespace LinearAlgebra
 
 #  if !(defined(DEAL_II_COMPILER_CUDA_AWARE) && \
         defined(DEAL_II_WITH_CUDA_AWARE_MPI))
-      partitioner->export_to_ghosted_array_start<Number, MemorySpaceType>(
+      partitioner->export_to_ghosted_array_start<Number, MemorySpace::Host>(
         counter,
-        ArrayView<const Number>(data.values.get(), partitioner->local_size()),
-        ArrayView<Number>(import_data.values.get(),
-                          partitioner->n_import_indices()),
-        ArrayView<Number>(data.values.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
+        ArrayView<const Number, MemorySpace::Host>(data.values.get(),
+                                                   partitioner->local_size()),
+        ArrayView<Number, MemorySpace::Host>(import_data.values.get(),
+                                             partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::Host>(data.values.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
         update_ghost_values_requests);
 #  else
-      partitioner->export_to_ghosted_array_start<Number, MemorySpaceType>(
+      partitioner->export_to_ghosted_array_start<Number, MemorySpace::CUDA>(
         counter,
-        ArrayView<const Number>(data.values_dev.get(),
-                                partitioner->local_size()),
-        ArrayView<Number>(import_data.values_dev.get(),
-                          partitioner->n_import_indices()),
-        ArrayView<Number>(data.values_dev.get() + partitioner->local_size(),
-                          partitioner->n_ghost_indices()),
+        ArrayView<const Number, MemorySpace::CUDA>(data.values_dev.get(),
+                                                   partitioner->local_size()),
+        ArrayView<Number, MemorySpace::CUDA>(import_data.values_dev.get(),
+                                             partitioner->n_import_indices()),
+        ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get() +
+                                               partitioner->local_size(),
+                                             partitioner->n_ghost_indices()),
         update_ghost_values_requests);
 #  endif
 
@@ -1140,13 +1149,15 @@ namespace LinearAlgebra
 #  if !(defined(DEAL_II_COMPILER_CUDA_AWARE) && \
         defined(DEAL_II_WITH_CUDA_AWARE_MPI))
           partitioner->export_to_ghosted_array_finish(
-            ArrayView<Number>(data.values.get() + partitioner->local_size(),
-                              partitioner->n_ghost_indices()),
+            ArrayView<Number, MemorySpace::Host>(
+              data.values.get() + partitioner->local_size(),
+              partitioner->n_ghost_indices()),
             update_ghost_values_requests);
 #  else
           partitioner->export_to_ghosted_array_finish(
-            ArrayView<Number>(data.values_dev.get() + partitioner->local_size(),
-                              partitioner->n_ghost_indices()),
+            ArrayView<Number, MemorySpace::CUDA>(
+              data.values_dev.get() + partitioner->local_size(),
+              partitioner->n_ghost_indices()),
             update_ghost_values_requests);
 #  endif
         }
index d6b6ab7f6cfceda655e12aee8238db954fce6915..f674beac2b290e09313e822480ad1afa404f09b3 100644 (file)
 for (SCALAR : MPI_SCALARS)
   {
 #ifdef DEAL_II_WITH_MPI
-    template void Utilities::MPI::Partitioner::export_to_ghosted_array_start<
-      SCALAR,
-      dealii::MemorySpace::CUDA>(const unsigned int,
-                                 const ArrayView<const SCALAR> &,
-                                 const ArrayView<SCALAR> &,
-                                 const ArrayView<SCALAR> &,
-                                 std::vector<MPI_Request> &) const;
-
     template void Utilities::MPI::Partitioner::
-      export_to_ghosted_array_finish<SCALAR, MemorySpace::CUDA>(
-        const ArrayView<SCALAR> &, std::vector<MPI_Request> &) const;
+      export_to_ghosted_array_start<SCALAR, dealii::MemorySpace::CUDA>(
+        const unsigned int,
+        const ArrayView<const SCALAR, MemorySpace::CUDA> &,
+        const ArrayView<SCALAR, MemorySpace::CUDA> &,
+        const ArrayView<SCALAR, MemorySpace::CUDA> &,
+        std::vector<MPI_Request> &) const;
+
+    template void Utilities::MPI::Partitioner::export_to_ghosted_array_finish<
+      SCALAR,
+      MemorySpace::CUDA>(const ArrayView<SCALAR, MemorySpace::CUDA> &,
+                         std::vector<MPI_Request> &) const;
 
     template void Utilities::MPI::Partitioner::import_from_ghosted_array_start<
       SCALAR,
       MemorySpace::CUDA>(const VectorOperation::values,
                          const unsigned int,
-                         const ArrayView<SCALAR> &,
-                         const ArrayView<SCALAR> &,
+                         const ArrayView<SCALAR, MemorySpace::CUDA> &,
+                         const ArrayView<SCALAR, MemorySpace::CUDA> &,
                          std::vector<MPI_Request> &) const;
 
     template void Utilities::MPI::Partitioner::import_from_ghosted_array_finish<
       SCALAR,
       MemorySpace::CUDA>(const VectorOperation::values,
-                         const ArrayView<const SCALAR> &,
-                         const ArrayView<SCALAR> &,
-                         const ArrayView<SCALAR> &,
+                         const ArrayView<const SCALAR, MemorySpace::CUDA> &,
+                         const ArrayView<SCALAR, MemorySpace::CUDA> &,
+                         const ArrayView<SCALAR, MemorySpace::CUDA> &,
                          std::vector<MPI_Request> &) const;
 #endif
   }
index c1b1696302c66fdde92c9d023dbea0e76ebd9abf..84bd8252cce6aad086621460ba5c289ad3800160 100644 (file)
@@ -21,26 +21,27 @@ for (SCALAR : MPI_SCALARS)
     template void Utilities::MPI::Partitioner::export_to_ghosted_array_start<
       SCALAR,
       MemorySpace::Host>(const unsigned int,
-                         const ArrayView<const SCALAR> &,
-                         const ArrayView<SCALAR> &,
-                         const ArrayView<SCALAR> &,
+                         const ArrayView<const SCALAR, MemorySpace::Host> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
+                         std::vector<MPI_Request> &) const;
+    template void Utilities::MPI::Partitioner::export_to_ghosted_array_finish<
+      SCALAR,
+      MemorySpace::Host>(const ArrayView<SCALAR, MemorySpace::Host> &,
                          std::vector<MPI_Request> &) const;
-    template void Utilities::MPI::Partitioner::
-      export_to_ghosted_array_finish<SCALAR, MemorySpace::Host>(
-        const ArrayView<SCALAR> &, std::vector<MPI_Request> &) const;
     template void Utilities::MPI::Partitioner::import_from_ghosted_array_start<
       SCALAR,
       MemorySpace::Host>(const VectorOperation::values,
                          const unsigned int,
-                         const ArrayView<SCALAR> &,
-                         const ArrayView<SCALAR> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
                          std::vector<MPI_Request> &) const;
     template void Utilities::MPI::Partitioner::import_from_ghosted_array_finish<
       SCALAR,
       MemorySpace::Host>(const VectorOperation::values,
-                         const ArrayView<const SCALAR> &,
-                         const ArrayView<SCALAR> &,
-                         const ArrayView<SCALAR> &,
+                         const ArrayView<const SCALAR, MemorySpace::Host> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
+                         const ArrayView<SCALAR, MemorySpace::Host> &,
                          std::vector<MPI_Request> &) const;
 #endif
   }
index 14c109634659d825fa26b4263770674c194cb10a..c787091f5793c7ad4d95af6d861c07c3653b1a56 100644 (file)
@@ -28,7 +28,7 @@
 
 template <typename Number>
 void
-print_cuda_view(const ArrayView<Number> cuda_view)
+print_cuda_view(const ArrayView<Number, MemorySpace::CUDA> cuda_view)
 {
   std::vector<Number> cpu_values(cuda_view.size());
   Utilities::CUDA::copy_to_host(cuda_view.data(), cpu_values);
@@ -110,8 +110,8 @@ test()
     nullptr, Utilities::CUDA::delete_device_data<unsigned int>);
   locally_owned_data.reset(
     Utilities::CUDA::allocate_device_data<unsigned int>(local_size));
-  ArrayView<unsigned int> locally_owned_data_view(locally_owned_data.get(),
-                                                  local_size);
+  ArrayView<unsigned int, MemorySpace::CUDA> locally_owned_data_view(
+    locally_owned_data.get(), local_size);
   Utilities::CUDA::copy_to_dev(cpu_locally_owned_data,
                                locally_owned_data.get());
 
@@ -120,14 +120,15 @@ test()
     nullptr, Utilities::CUDA::delete_device_data<unsigned int>);
   ghosts.reset(
     Utilities::CUDA::allocate_device_data<unsigned int>(v.n_ghost_indices()));
-  ArrayView<unsigned int> ghosts_view(ghosts.get(), v.n_ghost_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> ghosts_view(ghosts.get(),
+                                                         v.n_ghost_indices());
 
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> temp_array(
     nullptr, Utilities::CUDA::delete_device_data<unsigned int>);
   temp_array.reset(
     Utilities::CUDA::allocate_device_data<unsigned int>(v.n_import_indices()));
-  ArrayView<unsigned int> temp_array_view(temp_array.get(),
-                                          v.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view(
+    temp_array.get(), v.n_import_indices());
 
   std::vector<MPI_Request> requests;
 
@@ -147,8 +148,8 @@ test()
   AssertCuda(cuda_error);
 
   Assert(temp_array_view.size() >= w.n_import_indices(), ExcInternalError());
-  ArrayView<unsigned int> temp_array_view_w(temp_array_view.data(),
-                                            w.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view_w(
+    temp_array_view.data(), w.n_import_indices());
   w.export_to_ghosted_array_start<unsigned int, MemorySpace::CUDA>(
     3, locally_owned_data_view, temp_array_view_w, ghosts_view, requests);
 
@@ -158,14 +159,15 @@ test()
     nullptr, Utilities::CUDA::delete_device_data<unsigned int>);
   temp_array2.reset(
     Utilities::CUDA::allocate_device_data<unsigned int>(x.n_import_indices()));
-  ArrayView<unsigned int> temp_array2_view(temp_array2.get(),
-                                           x.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array2_view(
+    temp_array2.get(), x.n_import_indices());
 
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> ghosts2(
     nullptr, Utilities::CUDA::delete_device_data<unsigned int>);
   ghosts2.reset(
     Utilities::CUDA::allocate_device_data<unsigned int>(x.n_ghost_indices()));
-  ArrayView<unsigned int> ghosts2_view(ghosts2.get(), x.n_ghost_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> ghosts2_view(ghosts2.get(),
+                                                          x.n_ghost_indices());
 
   std::vector<MPI_Request> requests2;
   x.export_to_ghosted_array_start<unsigned int, MemorySpace::CUDA>(
@@ -182,8 +184,8 @@ test()
   AssertCuda(cuda_error);
 
   Assert(temp_array_view.size() >= x.n_import_indices(), ExcInternalError());
-  ArrayView<unsigned int> temp_array_view_x(temp_array_view.data(),
-                                            x.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view_x(
+    temp_array_view.data(), x.n_import_indices());
   x.export_to_ghosted_array_start<unsigned int, MemorySpace::CUDA>(
     3, locally_owned_data_view, temp_array_view_x, ghosts_view, requests);
   x.export_to_ghosted_array_finish<unsigned int, MemorySpace::CUDA>(ghosts_view,
index 1372d1f4c64e1ea8705bfef75fe798df2c8b0258..b2df4ae43696af012846a0e9b0475d9886a915ae 100644 (file)
@@ -28,7 +28,7 @@
 
 template <typename Number>
 void
-print_cuda_view(const ArrayView<Number> cuda_view)
+print_cuda_view(const ArrayView<Number, MemorySpace::CUDA> cuda_view)
 {
   std::vector<Number> cpu_values(cuda_view.size());
   Utilities::CUDA::copy_to_host(cuda_view.data(), cpu_values);
@@ -104,22 +104,22 @@ test()
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> ghost_array(
     Utilities::CUDA::allocate_device_data<unsigned int>(cpu_ghost_array.size()),
     Utilities::CUDA::delete_device_data<unsigned int>);
-  ArrayView<unsigned int> ghost_array_view(ghost_array.get(),
-                                           cpu_ghost_array.size());
+  ArrayView<unsigned int, MemorySpace::CUDA> ghost_array_view(
+    ghost_array.get(), cpu_ghost_array.size());
   Utilities::CUDA::copy_to_dev(cpu_ghost_array, ghost_array.get());
 
   // set up other arrays
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> locally_owned_array(
     Utilities::CUDA::allocate_device_data<unsigned int>(local_size),
     Utilities::CUDA::delete_device_data<unsigned int>);
-  ArrayView<unsigned int> locally_owned_array_view(locally_owned_array.get(),
-                                                   local_size);
+  ArrayView<unsigned int, MemorySpace::CUDA> locally_owned_array_view(
+    locally_owned_array.get(), local_size);
 
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> temp_array(
     Utilities::CUDA::allocate_device_data<unsigned int>(v.n_import_indices()),
     Utilities::CUDA::delete_device_data<unsigned int>);
-  ArrayView<unsigned int> temp_array_view(temp_array.get(),
-                                          v.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view(
+    temp_array.get(), v.n_import_indices());
 
   std::vector<MPI_Request> requests;
 
@@ -129,8 +129,9 @@ test()
       Utilities::CUDA::allocate_device_data<unsigned int>(
         ghost_array_view.size()),
       Utilities::CUDA::delete_device_data<unsigned int>);
-    ArrayView<unsigned int> ghosts_view(ghosts.get(), ghost_array_view.size());
-    const cudaError_t       cuda_error =
+    ArrayView<unsigned int, MemorySpace::CUDA> ghosts_view(
+      ghosts.get(), ghost_array_view.size());
+    const cudaError_t cuda_error =
       cudaMemcpy(ghosts.get(),
                  ghost_array_view.data(),
                  ghost_array_view.size() * sizeof(unsigned int),
@@ -160,15 +161,16 @@ test()
                locally_owned_array_view.size() * sizeof(unsigned int));
   AssertCuda(cuda_error);
   Assert(temp_array_view.size() >= w.n_import_indices(), ExcInternalError());
-  ArrayView<unsigned int> temp_array_view_w(temp_array_view.data(),
-                                            w.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view_w(
+    temp_array_view.data(), w.n_import_indices());
   {
     std::unique_ptr<unsigned int[], void (*)(unsigned int *)> ghosts(
       Utilities::CUDA::allocate_device_data<unsigned int>(
         ghost_array_view.size()),
       Utilities::CUDA::delete_device_data<unsigned int>);
-    ArrayView<unsigned int> ghosts_view(ghosts.get(), ghost_array_view.size());
-    const cudaError_t       cuda_error =
+    ArrayView<unsigned int, MemorySpace::CUDA> ghosts_view(
+      ghosts.get(), ghost_array_view.size());
+    const cudaError_t cuda_error =
       cudaMemcpy(ghosts.get(),
                  ghost_array_view.data(),
                  ghost_array_view.size() * sizeof(unsigned int),
@@ -199,15 +201,16 @@ test()
                locally_owned_array_view.size() * sizeof(unsigned int));
   AssertCuda(cuda_error);
   Assert(temp_array_view.size() >= x.n_import_indices(), ExcInternalError());
-  ArrayView<unsigned int> temp_array_view_x(temp_array_view.data(),
-                                            x.n_import_indices());
+  ArrayView<unsigned int, MemorySpace::CUDA> temp_array_view_x(
+    temp_array_view.data(), x.n_import_indices());
   {
     std::unique_ptr<unsigned int[], void (*)(unsigned int *)> ghosts(
       Utilities::CUDA::allocate_device_data<unsigned int>(
         ghost_array_view.size()),
       Utilities::CUDA::delete_device_data<unsigned int>);
-    ArrayView<unsigned int> ghosts_view(ghosts.get(), ghost_array_view.size());
-    const cudaError_t       cuda_error =
+    ArrayView<unsigned int, MemorySpace::CUDA> ghosts_view(
+      ghosts.get(), ghost_array_view.size());
+    const cudaError_t cuda_error =
       cudaMemcpy(ghosts.get(),
                  ghost_array_view.data(),
                  ghost_array_view.size() * sizeof(unsigned int),
@@ -236,7 +239,8 @@ test()
   std::unique_ptr<unsigned int[], void (*)(unsigned int *)> ghosts(
     Utilities::CUDA::allocate_device_data<unsigned int>(cpu_ghosts.size()),
     Utilities::CUDA::delete_device_data<unsigned int>);
-  ArrayView<unsigned int> ghosts_view(ghosts.get(), cpu_ghosts.size());
+  ArrayView<unsigned int, MemorySpace::CUDA> ghosts_view(ghosts.get(),
+                                                         cpu_ghosts.size());
   Utilities::CUDA::copy_to_dev(cpu_ghosts, ghosts.get());
 
   x.import_from_ghosted_array_start<unsigned int, MemorySpace::CUDA>(
index 65a0fbd4f21f6d11e0bcd80f1a1889974dbb6f08..a6a84564baf96511239266c21c4d8a0f9612584c 100644 (file)
@@ -25,7 +25,7 @@
 
 template <typename Number>
 void
-print_cuda_view(const ArrayView<Number> cuda_view)
+print_cuda_view(const ArrayView<Number, MemorySpace::CUDA> cuda_view)
 {
   std::vector<Number> cpu_values(cuda_view.size());
   Utilities::CUDA::copy_to_host(cuda_view.data(), cpu_values);
@@ -95,19 +95,21 @@ test()
 
   // create vector
   std::vector<Number> cpu_owned(rank == 0 ? 8 : 0);
-  for (int i = 0; i < cpu_owned.size(); ++i)
+  for (unsigned int i = 0; i < cpu_owned.size(); ++i)
     cpu_owned[i] = i;
   std::unique_ptr<Number[], void (*)(Number *)> owned(
     Utilities::CUDA::allocate_device_data<Number>(cpu_owned.size()),
     Utilities::CUDA::delete_device_data<Number>);
-  ArrayView<Number> owned_view(owned.get(), cpu_owned.size());
+  ArrayView<Number, MemorySpace::CUDA> owned_view(owned.get(),
+                                                  cpu_owned.size());
   Utilities::CUDA::copy_to_dev(cpu_owned, owned.get());
 
   std::vector<Number>                           cpu_ghost(4, 0);
   std::unique_ptr<Number[], void (*)(Number *)> ghost(
     Utilities::CUDA::allocate_device_data<Number>(cpu_ghost.size()),
     Utilities::CUDA::delete_device_data<Number>);
-  ArrayView<Number> ghost_view(ghost.get(), cpu_ghost.size());
+  ArrayView<Number, MemorySpace::CUDA> ghost_view(ghost.get(),
+                                                  cpu_ghost.size());
   Utilities::CUDA::copy_to_dev(cpu_ghost, ghost.get());
 
   // update ghost values
@@ -120,8 +122,8 @@ test()
     Utilities::CUDA::allocate_device_data<Number>(
       tight_partitioner->n_import_indices()),
     Utilities::CUDA::delete_device_data<Number>);
-  ArrayView<Number> tmp_data_view(tmp_data.get(),
-                                  tight_partitioner->n_import_indices());
+  ArrayView<Number, MemorySpace::CUDA> tmp_data_view(
+    tmp_data.get(), tight_partitioner->n_import_indices());
 
   // begin exchange, and ...
   tight_partitioner->export_to_ghosted_array_start<Number, MemorySpace::CUDA>(
@@ -145,8 +147,8 @@ test()
     Utilities::CUDA::allocate_device_data<Number>(
       tight_partitioner->n_import_indices()),
     Utilities::CUDA::delete_device_data<Number>);
-  ArrayView<Number> import_data_view(tmp_data.get(),
-                                     tight_partitioner->n_import_indices());
+  ArrayView<Number, MemorySpace::CUDA> import_data_view(
+    tmp_data.get(), tight_partitioner->n_import_indices());
 
   // now do insert:
   auto compress = [&](VectorOperation::values operation) {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.