]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid using std::memset for device data
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 1 Oct 2019 21:19:13 +0000 (21:19 +0000)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 1 Oct 2019 21:20:54 +0000 (17:20 -0400)
include/deal.II/base/partitioner.templates.h

index da662e10de1eeb3491c67d68b1fb73fe1d47f4cb..1938284a7e5999f277c88daf58a5d5f72b9876aa 100644 (file)
@@ -513,18 +513,30 @@ namespace Utilities
                    "vector_operation argument was passed to "
                    "import_from_ghosted_array_start as is passed "
                    "to import_from_ghosted_array_finish."));
+
+#      if (defined(DEAL_II_COMPILER_CUDA_AWARE))
+          if (std::is_same<MemorySpaceType, MemorySpace::CUDA>::value)
+            {
+              cudaMemset(ghost_array.data(),
+                         0,
+                         sizeof(Number) * ghost_array.size());
+            }
+          else
+#      endif
+            {
 #      ifdef DEAL_II_WITH_CXX17
-          if constexpr (std::is_trivial<Number>::value)
+              if constexpr (std::is_trivial<Number>::value)
 #      else
-          if (std::is_trivial<Number>::value)
+            if (std::is_trivial<Number>::value)
 #      endif
-            std::memset(ghost_array.data(),
-                        0,
-                        sizeof(Number) * ghost_array.size());
-          else
-            std::fill(ghost_array.data(),
-                      ghost_array.data() + ghost_array.size(),
-                      0);
+                std::memset(ghost_array.data(),
+                            0,
+                            sizeof(Number) * ghost_array.size());
+              else
+                std::fill(ghost_array.data(),
+                          ghost_array.data() + ghost_array.size(),
+                          0);
+            }
           return;
         }
 #    endif

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.