]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix using MemorySpace::Host with la_parallel_vector.templates.h and CUDA-aware MPI 8879/head
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 30 Sep 2019 20:10:35 +0000 (16:10 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Mon, 30 Sep 2019 20:10:35 +0000 (16:10 -0400)
include/deal.II/lac/la_parallel_vector.templates.h

index 04c43ee38cfdc89d74ea0945822d4b493ab968a5..0f465176e8208eb12edac594638326f066289f15 100644 (file)
@@ -914,30 +914,32 @@ namespace LinearAlgebra
         {
 #  if defined(DEAL_II_COMPILER_CUDA_AWARE) && \
     defined(DEAL_II_MPI_WITH_CUDA_SUPPORT)
-          Assert(
-            (std::is_same<MemorySpaceType, dealii::MemorySpace::CUDA>::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<Number>(
-                partitioner->n_import_indices()));
-#  else
-#    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 == nullptr)
+          if (std::is_same<MemorySpaceType, dealii::MemorySpace::CUDA>::value)
             {
-              Number *new_val;
-              Utilities::System::posix_memalign(
-                reinterpret_cast<void **>(&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<Number>(
+                    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<MemorySpaceType, dealii::MemorySpace::Host>::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<void **>(&new_val),
+                    64,
+                    sizeof(Number) * partitioner->n_import_indices());
+                  import_data.values.reset(new_val);
+                }
+            }
         }
 
 #  if defined DEAL_II_COMPILER_CUDA_AWARE && \

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.