From 30ea62d482b3b5d1d7ca998e7d15240b70c005d3 Mon Sep 17 00:00:00 2001
From: William F Godoy <williamfgc@yahoo.com>
Date: Tue, 27 Jun 2017 16:29:26 -0400
Subject: [PATCH] Enable memory runtime parameters using XML config file

Picking up config.xml from examples/heatTransfer/write/config.xml from
./build/bin/heatTransfer_write_adios2
---
 examples/heatTransfer/write/CMakeLists.txt |  2 ++
 examples/heatTransfer/write/IO_adios2.cpp  | 10 +++++++++-
 examples/heatTransfer/write/config.xml     | 23 +++++++++++++---------
 3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/examples/heatTransfer/write/CMakeLists.txt b/examples/heatTransfer/write/CMakeLists.txt
index 426c51240..b55958482 100644
--- a/examples/heatTransfer/write/CMakeLists.txt
+++ b/examples/heatTransfer/write/CMakeLists.txt
@@ -16,6 +16,8 @@ if(ADIOS2_HAVE_MPI)
     PRIVATE ${MPI_C_INCLUDE_PATH}
   )
   target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES})
+  target_compile_definitions(heatTransfer_write_adios2 PRIVATE
+   -DDEFAULT_CONFIG=${CMAKE_CURRENT_SOURCE_DIR}/config.xml)
 
   if(ADIOS2_HAVE_ADIOS1)
     find_package(ADIOS1 REQUIRED)
diff --git a/examples/heatTransfer/write/IO_adios2.cpp b/examples/heatTransfer/write/IO_adios2.cpp
index 7abf122a2..e795d5976 100644
--- a/examples/heatTransfer/write/IO_adios2.cpp
+++ b/examples/heatTransfer/write/IO_adios2.cpp
@@ -14,6 +14,13 @@
 
 #include <adios2.h>
 
+#define str_helper(X) #X
+#define str(X) str_helper(X)
+#ifndef DEFAULT_CONFIG
+#define DEFAULT_CONFIG config.xml
+#endif
+#define DEFAULT_CONFIG_STR str(DEFAULT_CONFIG)
+
 static int rank_saved;
 adios2::ADIOS *ad = nullptr;
 std::shared_ptr<adios2::Engine> bpWriter;
@@ -24,7 +31,8 @@ IO::IO(const Settings &s, MPI_Comm comm)
 {
     rank_saved = s.rank;
     m_outputfilename = s.outputfile + ".bp";
-    ad = new adios2::ADIOS("config.xml", comm, adios2::DebugON);
+    ad = new adios2::ADIOS(std::string(DEFAULT_CONFIG_STR), comm,
+                           adios2::DebugON);
 
     // Define method for engine creation
 
diff --git a/examples/heatTransfer/write/config.xml b/examples/heatTransfer/write/config.xml
index 2aca2b3fe..7013154c4 100644
--- a/examples/heatTransfer/write/config.xml
+++ b/examples/heatTransfer/write/config.xml
@@ -1,13 +1,14 @@
 <?xml version="1.0"?>
-<!-- Config XML file fo the  heatTransfer_write_adios2 executable from 
-     IO_adios2.cpp -->
+<!-- Config XML file fo the  heatTransfer_write_adios2 executable in .
+     build/bin from IO_adios2.cpp -->
 
 <adios-config>
     <io name="output">
         <engine type="BPFileWriter">
             
-            <!-- for vectorized memory operations --> 
-            <parameter key="Threads" value="1"/>
+            <!-- for vectorized memory operations, make sure your system 
+                 enables threads--> 
+            <parameter key="Threads" value="2"/>
 
             <!-- Microseconds (default), Milliseconds, Seconds, 
                  Minutes, Hours -->
@@ -17,12 +18,15 @@
                 (applications might choose an optimal value) -->
             <!--<parameter key="InitialBufferSize" value="16Kb"/>  -->
             
-            <!-- XXKb, XXMb, or XXXGb supported, default=Unlimited or 
-                 maximum at each time step  
+            <!-- XXKb, XXMb, or XXXGb supported, default=Unlimited (until 
+                 fails), maximum at each time step  
                 (applications might choose an optimal value) -->
-            <!-- <parameter key="MaxBufferSize" value="50Mb"/> -->
+            <!-- <parameter key="MaxBufferSize" value="2Gb"/> -->
 
-            <!-- exponential growth factor > 1, default = 1.05 --> 
+            <!-- exponential growth factor > 1, default = 1.05 
+                 1.05  is good for a few large variables, for many small
+                 variables increase the value to 1.5 to 2 
+                 (optimal value is application dependent)--> 
             <parameter key="BufferGrowthFactor" value="1.05"/>
             
         </engine>
@@ -34,7 +38,8 @@
             
             <!-- For read/write, Microseconds (default), Milliseconds, Seconds, 
                  Minutes, Hours. open/close always in Microseconds -->
-            <parameter key="ProfileUnits" value="Milliseconds"/>
+            <parameter key="ProfileUnits" value="Microseconds"/>
+            
         </transport>
     </io>
 </adios-config>
-- 
GitLab