]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Indentation
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 1 Dec 2022 23:03:49 +0000 (18:03 -0500)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 8 Dec 2022 22:13:15 +0000 (17:13 -0500)
include/deal.II/base/memory_space_data.h
include/deal.II/lac/la_parallel_vector.h
include/deal.II/lac/la_parallel_vector.templates.h
include/deal.II/lac/vector_operations_internal.h
source/base/kokkos.cc

index 77bbc00de271ab7410f1b4042e66607ed1631df2..afe5cbea96b5f9390af0aa6d8b13c90d9f5afb18 100644 (file)
@@ -101,7 +101,7 @@ namespace MemorySpace
   template <typename T, typename MemorySpace>
   MemorySpaceData<T, MemorySpace>::MemorySpaceData()
     : values_host_buffer((dealii::Impl::ensure_kokkos_initialized(),
-              Kokkos::View<T *, Kokkos::HostSpace>("host data", 0)))
+                          Kokkos::View<T *, Kokkos::HostSpace>("host data", 0)))
     , values(Kokkos::View<T *, typename MemorySpace::kokkos_space>(
         "memoryspace data",
         0))
@@ -157,8 +157,8 @@ namespace MemorySpace
   inline void
   swap(MemorySpaceData<T, MemorySpace> &u, MemorySpaceData<T, MemorySpace> &v)
   {
-    std::swap(u.values_host_buffer, v.values_host_buffer);       
-    std::swap(u.values, v.values);       
+    std::swap(u.values_host_buffer, v.values_host_buffer);
+    std::swap(u.values, v.values);
     std::swap(u.values_sm_ptr, v.values_sm_ptr);
   }
 
index ecf934145a2a824ddf1d1b656018e919eeab7109..cca0fe773663752746e7b1bb517b974cec259100 100644 (file)
@@ -1656,7 +1656,7 @@ namespace LinearAlgebra
     inline Number *
     Vector<Number, MemorySpace>::get_values() const
     {
-      return  data.values.data();
+      return data.values.data();
     }
 
 
index 0a08efb5e123062a65a77b7dcef6c457041a8d9a..00cba2c164c93b5edd66e4fa708b24c8b2894012 100644 (file)
@@ -135,7 +135,7 @@ namespace LinearAlgebra
         {
           if (comm_shared == MPI_COMM_SELF)
             {
-             Kokkos::resize(data.values, new_alloc_size);          
+              Kokkos::resize(data.values, new_alloc_size);
 
               allocated_size = new_alloc_size;
 
@@ -343,7 +343,7 @@ namespace LinearAlgebra
                       data.values.size() == 0),
                      ExcInternalError());
 
-             Kokkos::resize(data.values, new_alloc_size);
+              Kokkos::resize(data.values, new_alloc_size);
 
               allocated_size = new_alloc_size;
             }
@@ -931,25 +931,26 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::zero_out_ghost_values() const
     {
       if (data.values.size() != 0)
-      {
-#ifdef DEAL_II_COMPILER_CUDA_AWARE
-        if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>)
         {
-          const cudaError_t cuda_error_code =
-            cudaMemset(data.values.data() +
-                         partitioner->locally_owned_size(),
-                       0,
-                       partitioner->n_ghost_indices() * sizeof(Number));
-          AssertCuda(cuda_error_code);
-        }
-       else
+#ifdef DEAL_II_COMPILER_CUDA_AWARE
+          if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>)
+            {
+              const cudaError_t cuda_error_code =
+                cudaMemset(data.values.data() +
+                             partitioner->locally_owned_size(),
+                           0,
+                           partitioner->n_ghost_indices() * sizeof(Number));
+              AssertCuda(cuda_error_code);
+            }
+          else
 #endif
-       {
-          std::fill_n(data.values.data() + partitioner->locally_owned_size(),
-                    partitioner->n_ghost_indices(),
-                    Number());
+            {
+              std::fill_n(data.values.data() +
+                            partitioner->locally_owned_size(),
+                          partitioner->n_ghost_indices(),
+                          Number());
+            }
         }
-      }
 
       vector_is_ghosted = false;
     }
@@ -978,7 +979,8 @@ namespace LinearAlgebra
           if (std::is_same<MemorySpaceType, dealii::MemorySpace::CUDA>::value)
             {
               if (import_data.values_host_buffer.size() == 0)
-                Kokkos::resize(import_data.values_host_buffer, partitioner->n_import_indices());
+                Kokkos::resize(import_data.values_host_buffer,
+                               partitioner->n_import_indices());
             }
           else
 #  endif
@@ -990,7 +992,8 @@ namespace LinearAlgebra
                 "This code path should only be compiled for CUDA-aware-MPI for MemorySpace::Host!");
 #  endif
               if (import_data.values.size() == 0)
-                Kokkos::resize(import_data.values, partitioner->n_import_indices());
+                Kokkos::resize(import_data.values,
+                               partitioner->n_import_indices());
             }
         }
 
@@ -1002,15 +1005,19 @@ namespace LinearAlgebra
           // device. We use values to store the elements because the function
           // uses a view of the array and thus we need the data on the host to
           // outlive the scope of the function.
-          data.values_host_buffer = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, data.values);
+          data.values_host_buffer =
+            Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
+                                                data.values);
           partitioner->import_from_ghosted_array_start(
             operation,
             communication_channel,
             ArrayView<Number, MemorySpace::Host>(
-              data.values_host_buffer.data() + partitioner->locally_owned_size(),
+              data.values_host_buffer.data() +
+                partitioner->locally_owned_size(),
               partitioner->n_ghost_indices()),
             ArrayView<Number, MemorySpace::Host>(
-              import_data.values_host_buffer.data(), partitioner->n_import_indices()),
+              import_data.values_host_buffer.data(),
+              partitioner->n_import_indices()),
             compress_requests);
         }
       else
@@ -1022,8 +1029,8 @@ namespace LinearAlgebra
             ArrayView<Number, MemorySpaceType>(
               data.values.data() + partitioner->locally_owned_size(),
               partitioner->n_ghost_indices()),
-            ArrayView<Number, MemorySpaceType>(
-              import_data.values.data(), partitioner->n_import_indices()),
+            ArrayView<Number, MemorySpaceType>(import_data.values.data(),
+                                               partitioner->n_import_indices()),
             compress_requests);
         }
 #else
@@ -1059,17 +1066,20 @@ namespace LinearAlgebra
             ->import_from_ghosted_array_finish<Number, MemorySpace::Host>(
               operation,
               ArrayView<const Number, MemorySpace::Host>(
-                import_data.values_host_buffer.data(), partitioner->n_import_indices()),
+                import_data.values_host_buffer.data(),
+                partitioner->n_import_indices()),
               ArrayView<Number, MemorySpace::Host>(
-                data.values_host_buffer.data(), partitioner->locally_owned_size()),
+                data.values_host_buffer.data(),
+                partitioner->locally_owned_size()),
               ArrayView<Number, MemorySpace::Host>(
-                data.values_host_buffer.data() + partitioner->locally_owned_size(),
+                data.values_host_buffer.data() +
+                  partitioner->locally_owned_size(),
                 partitioner->n_ghost_indices()),
               compress_requests);
 
-         // The communication is done on the host, so we need to
+          // The communication is done on the host, so we need to
           // move the data back to the device.
-         cudaError_t cuda_error_code =
+          cudaError_t cuda_error_code =
             cudaMemcpy(data.values.data(),
                        data.values_host_buffer.data(),
                        allocated_size * sizeof(Number),
@@ -1124,56 +1134,66 @@ namespace LinearAlgebra
         {
 #  if defined(DEAL_II_COMPILER_CUDA_AWARE) && \
     !defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)
-                    if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>) {
-          if (import_data.values_host_buffer.size() == 0)
-            Kokkos::resize(import_data.values_host_buffer, partitioner->n_import_indices());
-                    }
-                    else
+          if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>)
+            {
+              if (import_data.values_host_buffer.size() == 0)
+                Kokkos::resize(import_data.values_host_buffer,
+                               partitioner->n_import_indices());
+            }
+          else
 #  endif
-                    {
-#    ifdef DEAL_II_MPI_WITH_CUDA_SUPPORT
-          static_assert(
-            std::is_same<MemorySpaceType, dealii::MemorySpace::Host>::value,
-            "This code path should only be compiled for CUDA-aware-MPI for MemorySpace::Host!");
-#    endif
-          if (import_data.values.size() == 0)
-            Kokkos::resize(import_data.values, partitioner->n_import_indices());
-                    }
+            {
+#  ifdef DEAL_II_MPI_WITH_CUDA_SUPPORT
+              static_assert(
+                std::is_same<MemorySpaceType, dealii::MemorySpace::Host>::value,
+                "This code path should only be compiled for CUDA-aware-MPI for MemorySpace::Host!");
+#  endif
+              if (import_data.values.size() == 0)
+                Kokkos::resize(import_data.values,
+                               partitioner->n_import_indices());
+            }
         }
 
 #  if defined DEAL_II_COMPILER_CUDA_AWARE && \
     !defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)
-     if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>) { 
-       // Move the data to the host and then move it back to the
-       // device. We use values to store the elements because the function
-       // uses a view of the array and thus we need the data on the host to
-       // outlive the scope of the function.
-       data.values_host_buffer = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, data.values);
-       
-       partitioner->export_to_ghosted_array_start<Number, MemorySpace::Host>(
-        communication_channel,
-        ArrayView<const Number, MemorySpace::Host>(
-          data.values_host_buffer.data(), partitioner->locally_owned_size()),
-        ArrayView<Number, MemorySpace::Host>(import_data.values_host_buffer.data(),
-                                             partitioner->n_import_indices()),
-        ArrayView<Number, MemorySpace::Host>(
-          data.values_host_buffer.data() + partitioner->locally_owned_size(),
-          partitioner->n_ghost_indices()),
-        update_ghost_values_requests);
-    } else
-#endif
- {
-      partitioner->export_to_ghosted_array_start<Number, MemorySpaceType>(
-        communication_channel,
-        ArrayView<const Number, MemorySpaceType>(
-          data.values.data(), partitioner->locally_owned_size()),
-        ArrayView<Number, MemorySpaceType>(import_data.values.data(),
-                                             partitioner->n_import_indices()),
-        ArrayView<Number, MemorySpaceType>(
-          data.values.data() + partitioner->locally_owned_size(),
-          partitioner->n_ghost_indices()),
-        update_ghost_values_requests);
- }
+      if (std::is_same_v<MemorySpaceType, MemorySpace::CUDA>)
+        {
+          // Move the data to the host and then move it back to the
+          // device. We use values to store the elements because the function
+          // uses a view of the array and thus we need the data on the host to
+          // outlive the scope of the function.
+          data.values_host_buffer =
+            Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
+                                                data.values);
+
+          partitioner->export_to_ghosted_array_start<Number, MemorySpace::Host>(
+            communication_channel,
+            ArrayView<const Number, MemorySpace::Host>(
+              data.values_host_buffer.data(),
+              partitioner->locally_owned_size()),
+            ArrayView<Number, MemorySpace::Host>(
+              import_data.values_host_buffer.data(),
+              partitioner->n_import_indices()),
+            ArrayView<Number, MemorySpace::Host>(
+              data.values_host_buffer.data() +
+                partitioner->locally_owned_size(),
+              partitioner->n_ghost_indices()),
+            update_ghost_values_requests);
+        }
+      else
+#  endif
+        {
+          partitioner->export_to_ghosted_array_start<Number, MemorySpaceType>(
+            communication_channel,
+            ArrayView<const Number, MemorySpaceType>(
+              data.values.data(), partitioner->locally_owned_size()),
+            ArrayView<Number, MemorySpaceType>(import_data.values.data(),
+                                               partitioner->n_import_indices()),
+            ArrayView<Number, MemorySpaceType>(
+              data.values.data() + partitioner->locally_owned_size(),
+              partitioner->n_ghost_indices()),
+            update_ghost_values_requests);
+        }
 
 #else
       (void)communication_channel;
@@ -1198,35 +1218,38 @@ namespace LinearAlgebra
           std::lock_guard<std::mutex> lock(mutex);
 
 #  if defined(DEAL_II_COMPILER_CUDA_AWARE) && \
-        !defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)
-               if (std::is_same<MemorySpaceType, MemorySpace::CUDA>::value)
-               {
-          partitioner->export_to_ghosted_array_finish(
-            ArrayView<Number, MemorySpace::Host>(
-              data.values_host_buffer.data() + partitioner->locally_owned_size(),
-              partitioner->n_ghost_indices()),
-            update_ghost_values_requests);
-
-// The communication is done on the host, so we need to
-      // move the data back to the device.
- cudaError_t cuda_error_code =
-            cudaMemcpy(data.values.data() +
-                         partitioner->locally_owned_size(),
-                       data.values_host_buffer.data() + partitioner->locally_owned_size(),
-                       partitioner->n_ghost_indices() * sizeof(Number),
-                       cudaMemcpyHostToDevice);
-          AssertCuda(cuda_error_code);
-
-          Kokkos::resize(data.values_host_buffer, 0);     
-               } else
-#endif
-               {
-          partitioner->export_to_ghosted_array_finish(
-            ArrayView<Number, MemorySpaceType>(
-              data.values.data() + partitioner->locally_owned_size(),
-              partitioner->n_ghost_indices()),
-            update_ghost_values_requests);
-               }
+    !defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)
+          if (std::is_same<MemorySpaceType, MemorySpace::CUDA>::value)
+            {
+              partitioner->export_to_ghosted_array_finish(
+                ArrayView<Number, MemorySpace::Host>(
+                  data.values_host_buffer.data() +
+                    partitioner->locally_owned_size(),
+                  partitioner->n_ghost_indices()),
+                update_ghost_values_requests);
+
+              // The communication is done on the host, so we need to
+              // move the data back to the device.
+              cudaError_t cuda_error_code =
+                cudaMemcpy(data.values.data() +
+                             partitioner->locally_owned_size(),
+                           data.values_host_buffer.data() +
+                             partitioner->locally_owned_size(),
+                           partitioner->n_ghost_indices() * sizeof(Number),
+                           cudaMemcpyHostToDevice);
+              AssertCuda(cuda_error_code);
+
+              Kokkos::resize(data.values_host_buffer, 0);
+            }
+          else
+#  endif
+            {
+              partitioner->export_to_ghosted_array_finish(
+                ArrayView<Number, MemorySpaceType>(
+                  data.values.data() + partitioner->locally_owned_size(),
+                  partitioner->n_ghost_indices()),
+                update_ghost_values_requests);
+            }
         }
 
 #endif
@@ -2033,7 +2056,8 @@ namespace LinearAlgebra
       if (partitioner.use_count() > 0)
         memory +=
           partitioner->memory_consumption() / partitioner.use_count() + 1;
-      if (import_data.values_host_buffer.size() != 0 || import_data.values.size() != 0)
+      if (import_data.values_host_buffer.size() != 0 ||
+          import_data.values.size() != 0)
         memory += (static_cast<std::size_t>(partitioner->n_import_indices()) *
                    sizeof(Number));
       return memory;
index cde2c0b491c01af1f7cbf780c8125ead49853540..21d08f4413eaa8790c16a07c52840a31121ea33d 100644 (file)
@@ -1889,8 +1889,12 @@ namespace internal
                                                ::dealii::MemorySpace::Host>
           &data)
       {
-        Vectorization_sadd_xavbw<Number> vector_sadd(
-          data.values.data(), v_data.values.data(), w_data.values.data(), x, a, b);
+        Vectorization_sadd_xavbw<Number> vector_sadd(data.values.data(),
+                                                     v_data.values.data(),
+                                                     w_data.values.data(),
+                                                     x,
+                                                     a,
+                                                     b);
         parallel_for(vector_sadd, 0, size, thread_loop_partitioner);
       }
 
@@ -1904,8 +1908,8 @@ namespace internal
                                                ::dealii::MemorySpace::Host>
           &data)
       {
-        Vectorization_multiply_factor<Number> vector_multiply(data.values.data(),
-                                                              factor);
+        Vectorization_multiply_factor<Number> vector_multiply(
+          data.values.data(), factor);
         parallel_for(vector_multiply, 0, size, thread_loop_partitioner);
       }
 
index 77321393bd4b514da0880638da412cc69610ab38..343929746de8e9ee83ca03602b2fc703bb0e2fb1 100644 (file)
@@ -28,34 +28,34 @@ namespace Impl
   ensure_kokkos_initialized()
   {
     if (!Kokkos::is_initialized())
-    {
-           GrowingVectorMemory<
-        LinearAlgebra::distributed::Vector<double, MemorySpace::Host>>{};
-    GrowingVectorMemory<
-      LinearAlgebra::distributed::Vector<float, MemorySpace::Host>>{};
-    GrowingVectorMemory<
-      LinearAlgebra::distributed::Vector<double, MemorySpace::Device>>{};
-    GrowingVectorMemory<
-      LinearAlgebra::distributed::Vector<float, MemorySpace::Device>>{};
-    Kokkos::push_finalize_hook(
-      GrowingVectorMemory<
-        LinearAlgebra::distributed::Vector<double, MemorySpace::Host>>::
-        release_unused_memory);
-    Kokkos::push_finalize_hook(
-      GrowingVectorMemory<
-        LinearAlgebra::distributed::Vector<float, MemorySpace::Host>>::
-        release_unused_memory);
-    Kokkos::push_finalize_hook(
-      GrowingVectorMemory<
-        LinearAlgebra::distributed::Vector<double, MemorySpace::Device>>::
-        release_unused_memory);
-    Kokkos::push_finalize_hook(
-      GrowingVectorMemory<
-        LinearAlgebra::distributed::Vector<float, MemorySpace::Device>>::
-        release_unused_memory);
-    Kokkos::initialize();
-    std::atexit(Kokkos::finalize);
-  }
+      {
+        GrowingVectorMemory<
+          LinearAlgebra::distributed::Vector<double, MemorySpace::Host>>{};
+        GrowingVectorMemory<
+          LinearAlgebra::distributed::Vector<float, MemorySpace::Host>>{};
+        GrowingVectorMemory<
+          LinearAlgebra::distributed::Vector<double, MemorySpace::Device>>{};
+        GrowingVectorMemory<
+          LinearAlgebra::distributed::Vector<float, MemorySpace::Device>>{};
+        Kokkos::push_finalize_hook(
+          GrowingVectorMemory<
+            LinearAlgebra::distributed::Vector<double, MemorySpace::Host>>::
+            release_unused_memory);
+        Kokkos::push_finalize_hook(
+          GrowingVectorMemory<
+            LinearAlgebra::distributed::Vector<float, MemorySpace::Host>>::
+            release_unused_memory);
+        Kokkos::push_finalize_hook(
+          GrowingVectorMemory<
+            LinearAlgebra::distributed::Vector<double, MemorySpace::Device>>::
+            release_unused_memory);
+        Kokkos::push_finalize_hook(
+          GrowingVectorMemory<
+            LinearAlgebra::distributed::Vector<float, MemorySpace::Device>>::
+            release_unused_memory);
+        Kokkos::initialize();
+        std::atexit(Kokkos::finalize);
+      }
   }
 } // namespace Impl
 DEAL_II_NAMESPACE_CLOSE

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.