]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement .inst splitting in make_instantiations
authorTimo Heister <timo.heister@gmail.com>
Wed, 2 Sep 2015 22:39:37 +0000 (18:39 -0400)
committerTimo Heister <timo.heister@gmail.com>
Sat, 5 Sep 2015 15:35:06 +0000 (11:35 -0400)
cmake/scripts/expand_instantiations.cc

index bb08ddc9f171e4ba31f7ac33a81994d0a5976cda..fdfa9a9520f7e839ea3a08f23936aa57ce82c364 100644 (file)
@@ -376,14 +376,31 @@ void substitute (const std::string &text,
            expansion = expansion_lists[pattern].begin();
            expansion != expansion_lists[pattern].end();
            ++expansion)
-        std::cout << substitute_tokens (text, name, *expansion)
-                  << std::endl;
+        {
+          // surround each block in the for loop with an if-def hack
+          // that allows us to split instantiation files into several
+          // chunks to be used in different .cc files (to reduce
+          // compiler memory usage).
+          // Just define SPLIT_INSTANTIATIONS_COUNT to a positive number (number of sections)
+          // to split the definitions into and SPLIT_INSTANTIATIONS_INDEX as a number
+          // between 0 and SPLIT_INSTANTIATIONS_COUNT-1 to get the instantiations of that
+          // particular chunk.
+          static unsigned int counter = 0;
+          std::cout << "#if !defined(SPLIT_INSTANTIATIONS_COUNT) || ("
+                    << counter++
+                    << " % SPLIT_INSTANTIATIONS_COUNT == SPLIT_INSTANTIATIONS_INDEX)" << std::endl;
+          std::cout << substitute_tokens (text, name, *expansion)
+                    << std::endl;
+          std::cout << "#endif" << std::endl;
+        }
+
     }
   else
     {
       std::cout << text
                 << std::endl;
     }
+
 }
 
 

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.