From f288bd6f4b89776cab215d5d31ad5e50086e220e Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 18 Oct 2018 22:21:57 +0200 Subject: [PATCH] Use MemorySpace for import_data --- include/deal.II/lac/la_parallel_vector.h | 3 +- .../lac/la_parallel_vector.templates.h | 29 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index af8f759df8..840a5ca031 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1330,7 +1330,8 @@ namespace LinearAlgebra * in @p compress() or sent from this processor in * @p update_ghost_values. */ - mutable std::unique_ptr import_data; + mutable ::dealii::MemorySpace::MemorySpaceData + import_data; /** * Stores whether the vector currently allows for reading ghost elements diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 75863e4f93..d09de8cda3 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -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(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 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(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(data.values.get() + partitioner->local_size(), partitioner->n_ghost_indices()), - ArrayView(import_data.get(), partitioner->n_import_indices()), + ArrayView(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 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(import_data.get(), + ArrayView(import_data.values.get(), partitioner->n_import_indices()), ArrayView(data.values.get(), partitioner->local_size()), ArrayView(data.values.get() + partitioner->local_size(), -- 2.39.5