From: Daniel Arndt Date: Mon, 30 Sep 2019 20:10:35 +0000 (-0400) Subject: Fix using MemorySpace::Host with la_parallel_vector.templates.h and CUDA-aware MPI X-Git-Tag: v9.2.0-rc1~999^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8879%2Fhead;p=dealii.git Fix using MemorySpace::Host with la_parallel_vector.templates.h and CUDA-aware MPI --- diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 04c43ee38c..0f465176e8 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -914,30 +914,32 @@ namespace LinearAlgebra { # if defined(DEAL_II_COMPILER_CUDA_AWARE) && \ defined(DEAL_II_MPI_WITH_CUDA_SUPPORT) - Assert( - (std::is_same::value), - ExcMessage( - "Using MemorySpace::CUDA only allowed if the code is compiled with a CUDA compiler!")); - if (import_data.values_dev == nullptr) - import_data.values_dev.reset( - Utilities::CUDA::allocate_device_data( - partitioner->n_import_indices())); -# else -# ifdef DEAL_II_MPI_WITH_CUDA_SUPPORT - static_assert( - std::is_same::value, - "This code path should only be compiled for CUDA-aware-MPI for MemorySpace::Host!"); -# endif - if (import_data.values == nullptr) + if (std::is_same::value) { - Number *new_val; - Utilities::System::posix_memalign( - reinterpret_cast(&new_val), - 64, - sizeof(Number) * partitioner->n_import_indices()); - import_data.values.reset(new_val); + if (import_data.values_dev == nullptr) + import_data.values_dev.reset( + Utilities::CUDA::allocate_device_data( + partitioner->n_import_indices())); } + else +# endif + { +# if !defined(DEAL_II_COMPILER_CUDA_AWARE) && \ + defined(DEAL_II_MPI_WITH_CUDA_SUPPORT) + static_assert( + std::is_same::value, + "This code path should only be compiled for CUDA-aware-MPI for MemorySpace::Host!"); # endif + if (import_data.values == nullptr) + { + Number *new_val; + Utilities::System::posix_memalign( + reinterpret_cast(&new_val), + 64, + sizeof(Number) * partitioner->n_import_indices()); + import_data.values.reset(new_val); + } + } } # if defined DEAL_II_COMPILER_CUDA_AWARE && \