]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Performance optimization of Epetra_Map -> IndexSet conversion 1215/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 30 Jul 2015 11:54:31 +0000 (13:54 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 30 Jul 2015 12:20:15 +0000 (14:20 +0200)
include/deal.II/base/index_set.h
source/base/index_set.cc

index 6e3560493c454075f8e36475c834c2e7bbbb8372..8543b5ef0003cfe21275e0b6e963e0adbec2ff9d 100644 (file)
@@ -1206,28 +1206,6 @@ IndexSet::IndexSet (const size_type size)
 
 
 
-
-#ifdef DEAL_II_WITH_TRILINOS
-inline
-IndexSet::IndexSet (const Epetra_Map &map)
-  :
-  is_compressed (true),
-  index_space_size (map.NumGlobalElements()),
-  largest_range (numbers::invalid_unsigned_int)
-{
-  const size_type n_indices = map.NumMyElements();
-#ifndef DEAL_II_WITH_64BIT_INDICES
-  unsigned int *indices = (unsigned int *)map.MyGlobalElements();
-#else
-  size_type *indices = (size_type *)map.MyGlobalElements64();
-#endif
-  add_indices(indices, indices+n_indices);
-  compress();
-}
-#endif
-
-
-
 inline
 void
 IndexSet::clear ()
index 92cdab266047f74cd0d649ab3f3af1584493be25..a43e8856a3ade28db6143f6ed724c825a078123b 100644 (file)
@@ -29,6 +29,38 @@ DEAL_II_NAMESPACE_OPEN
 
 
 
+#ifdef DEAL_II_WITH_TRILINOS
+IndexSet::IndexSet (const Epetra_Map &map)
+  :
+  is_compressed (true),
+  index_space_size (map.NumGlobalElements()),
+  largest_range (numbers::invalid_unsigned_int)
+{
+  // For a contiguous map, we do not need to go through the whole data...
+  if (map.LinearMap())
+    {
+#ifndef DEAL_II_WITH_64BIT_INDICES
+      add_range(size_type(map.MinMyGID()), size_type(map.MaxMyGID()+1));
+#else
+      add_range(size_type(map.MinMyGID64()), size_type(map.MaxMyGID64()+1));
+#endif
+    }
+  else
+    {
+      const size_type n_indices = map.NumMyElements();
+#ifndef DEAL_II_WITH_64BIT_INDICES
+      unsigned int *indices = (unsigned int *)map.MyGlobalElements();
+#else
+      size_type *indices = (size_type *)map.MyGlobalElements64();
+#endif
+      add_indices(indices, indices+n_indices);
+    }
+  compress();
+}
+#endif
+
+
+
 void
 IndexSet::add_range (const size_type begin,
                      const size_type end)

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.