]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use MemorySpace for import_data
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 18 Oct 2018 20:21:57 +0000 (22:21 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 4 Jan 2019 13:26:46 +0000 (14:26 +0100)
include/deal.II/lac/la_parallel_vector.h
include/deal.II/lac/la_parallel_vector.templates.h

index af8f759df8fd82b149f5390ac8e6887aa09eb392..840a5ca0311680563fb20f9d87a0bc21c48662bc 100644 (file)
@@ -1330,7 +1330,8 @@ namespace LinearAlgebra
        * in @p compress() or sent from this processor in
        * @p update_ghost_values.
        */
-      mutable std::unique_ptr<Number[]> import_data;
+      mutable ::dealii::MemorySpace::MemorySpaceData<Number, MemorySpace>
+        import_data;
 
       /**
        * Stores whether the vector currently allows for reading ghost elements
index 75863e4f9315c538c925008d64cbbb5e22a6ac3b..d09de8cda326fd8c3cc45382a5c64c835ab254d8 100644 (file)
@@ -421,7 +421,8 @@ namespace LinearAlgebra
       resize_val(size);
 
       // delete previous content in import data
-      import_data.reset();
+      import_data.values.reset();
+      import_data.values_dev.reset();
 
       // set partitioner to serial version
       partitioner = std::make_shared<Utilities::MPI::Partitioner>(size);
@@ -465,7 +466,8 @@ namespace LinearAlgebra
       // is only used as temporary storage for compress() and
       // update_ghost_values, and we might have vectors where we never
       // call these methods and hence do not need to have the storage.
-      import_data.reset();
+      import_data.values.reset();
+      import_data.values_dev.reset();
 
       thread_loop_partitioner = v.thread_loop_partitioner;
     }
@@ -522,7 +524,8 @@ namespace LinearAlgebra
       // is only used as temporary storage for compress() and
       // update_ghost_values, and we might have vectors where we never
       // call these methods and hence do not need to have the storage.
-      import_data.reset();
+      import_data.values.reset();
+      import_data.values_dev.reset();
 
       vector_is_ghosted = false;
     }
@@ -880,9 +883,15 @@ namespace LinearAlgebra
       std::lock_guard<std::mutex> lock(mutex);
 
       // allocate import_data in case it is not set up yet
-      if (import_data == nullptr && partitioner->n_import_indices() > 0)
-        import_data =
-          std_cxx14::make_unique<Number[]>(partitioner->n_import_indices());
+      if (import_data.values == nullptr && partitioner->n_import_indices() > 0)
+        {
+          Number *new_val;
+          Utilities::System::posix_memalign((void **)&new_val,
+                                            64,
+                                            sizeof(Number) *
+                                              partitioner->n_import_indices());
+          import_data.values.reset(new_val);
+        }
 
 #  ifdef DEAL_II_COMPILER_CUDA_AWARE
       // TODO: for now move the data to the host and then move it back to the
@@ -910,7 +919,8 @@ namespace LinearAlgebra
         counter,
         ArrayView<Number>(data.values.get() + partitioner->local_size(),
                           partitioner->n_ghost_indices()),
-        ArrayView<Number>(import_data.get(), partitioner->n_import_indices()),
+        ArrayView<Number>(import_data.values.get(),
+                          partitioner->n_import_indices()),
         compress_requests);
 #endif
     }
@@ -932,11 +942,12 @@ namespace LinearAlgebra
       // make this function thread safe
       std::lock_guard<std::mutex> lock(mutex);
 
-      Assert(partitioner->n_import_indices() == 0 || import_data != nullptr,
+      Assert(partitioner->n_import_indices() == 0 ||
+               import_data.values != nullptr,
              ExcNotInitialized());
       partitioner->import_from_ghosted_array_finish(
         operation,
-        ArrayView<const Number>(import_data.get(),
+        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(),

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.