From 6b1aee110846503b2a05275470e4b97aa85124d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?=
 <cezary.skrzynski@ng-analytics.com>
Date: Tue, 1 Sep 2020 19:12:55 +0200
Subject: [PATCH] #1009 add serialize method for theConfig component

---
 src/vt/configs/arguments/app_config.h         | 134 +++++++++++++++++-
 src/vt/configs/arguments/args.h               |   5 +
 .../runtime/test_memory_footprint.nompi.cc    |  65 +++++++++
 3 files changed, 203 insertions(+), 1 deletion(-)
 create mode 100644 tests/unit/runtime/test_memory_footprint.nompi.cc

diff --git a/src/vt/configs/arguments/app_config.h b/src/vt/configs/arguments/app_config.h
index 596232cc54..3ebf4c13de 100644
--- a/src/vt/configs/arguments/app_config.h
+++ b/src/vt/configs/arguments/app_config.h
@@ -92,7 +92,7 @@ struct AppConfig {
   bool vt_no_sigsegv   = false;
   bool vt_no_terminate = false;
   std::string vt_memory_reporters =
-# if vt_check_enabled(mimalloc)
+# if (vt_feature_mimalloc != 0)
   "mimalloc,"
 # endif
   "mstats,machinfo,selfstat,selfstatm,sbrk,mallinfo,getrusage,ps";
@@ -215,6 +215,138 @@ struct AppConfig {
   /// Arguments are being ref-returend as the result of parse(..).
   /// Does not include argv[0]. Original char* objects.
   std::vector<char*> passthru_args;
+
+
+  template <typename Serializer>
+  void serialize(Serializer& s) {
+    s | vt_color
+      | vt_no_color
+      | vt_auto_color
+      | vt_quiet
+      | colorize_output
+
+      | vt_sched_num_progress
+      | vt_sched_progress_han
+      | vt_sched_progress_sec
+
+      | vt_no_sigint
+      | vt_no_sigsegv
+      | vt_no_terminate
+
+      | vt_memory_reporters
+      | vt_print_memory_each_phase
+      | vt_print_memory_node
+      | vt_allow_memory_report_with_ps
+      | vt_print_memory_at_threshold
+      | vt_print_memory_threshold
+      | vt_print_memory_sched_poll
+
+      | vt_no_warn_stack
+      | vt_no_assert_stack
+      | vt_no_abort_stack
+      | vt_no_stack
+      | vt_stack_file
+      | vt_stack_dir
+      | vt_stack_mod
+
+      | vt_trace
+      | vt_trace_mpi
+      | vt_trace_pmpi
+      | vt_trace_sys_all
+      | vt_trace_sys_term
+      | vt_trace_sys_location
+      | vt_trace_sys_collection
+      | vt_trace_sys_serial_msg
+      | vt_trace_file
+      | vt_trace_dir
+      | vt_trace_mod
+      | vt_trace_flush_size
+      | vt_trace_spec
+      | vt_trace_spec_file
+      | vt_trace_memory_usage
+      | vt_trace_event_polling
+      | vt_trace_irecv_polling
+
+      | vt_lb
+      | vt_lb_show_spec
+      | vt_lb_quiet
+      | vt_lb_file_name
+      | vt_lb_name
+      | vt_lb_args
+      | vt_lb_interval
+      | vt_lb_stats
+      | vt_lb_stats_dir
+      | vt_lb_stats_file
+      | vt_lb_stats_dir_in
+      | vt_lb_stats_file_in
+
+      | vt_no_detect_hang
+      | vt_print_no_progress
+      | vt_epoch_graph_on_hang
+      | vt_epoch_graph_terse
+      | vt_term_rooted_use_ds
+      | vt_term_rooted_use_wave
+      | vt_hang_freq
+
+      | vt_pause
+
+      | vt_debug_all
+      | vt_debug_verbose
+      | vt_debug_none
+      | vt_debug_gen
+      | vt_debug_runtime
+      | vt_debug_active
+      | vt_debug_term
+      | vt_debug_termds
+      | vt_debug_barrier
+      | vt_debug_event
+      | vt_debug_pipe
+      | vt_debug_pool
+      | vt_debug_reduce
+      | vt_debug_rdma
+      | vt_debug_rdma_channel
+      | vt_debug_rdma_state
+      | vt_debug_param
+      | vt_debug_handler
+      | vt_debug_hierlb
+      | vt_debug_gossiplb
+      | vt_debug_scatter
+      | vt_debug_sequence
+      | vt_debug_sequence_vrt
+      | vt_debug_serial_msg
+      | vt_debug_trace
+      | vt_debug_location
+      | vt_debug_lb
+      | vt_debug_vrt
+      | vt_debug_vrt_coll
+      | vt_debug_worker
+      | vt_debug_group
+      | vt_debug_broadcast
+      | vt_debug_objgroup
+
+      | vt_debug_print_flush
+
+      | vt_user_1
+      | vt_user_2
+      | vt_user_3
+      | vt_user_int_1
+      | vt_user_int_2
+      | vt_user_int_3
+      | vt_user_str_1
+      | vt_user_str_2
+      | vt_user_str_3
+
+      | vt_output_config
+      | vt_output_config_file
+      | vt_output_config_str
+
+      | prog_name
+
+      | argv_prog_name
+
+      | mpi_init_args
+      | passthru_args;
+  }
 };
 
 }} /* end namespace vt::arguments */
diff --git a/src/vt/configs/arguments/args.h b/src/vt/configs/arguments/args.h
index 7d918cd656..a68176699f 100644
--- a/src/vt/configs/arguments/args.h
+++ b/src/vt/configs/arguments/args.h
@@ -80,6 +80,11 @@ struct ArgConfig : runtime::component::Component<ArgConfig> {
 
   std::string name() override { return "ArgConfig"; }
 
+  template <typename Serializer>
+  void serialize(Serializer& s) {
+    s | config_ | parsed_;
+  }
+
   AppConfig config_;
 
 private:
diff --git a/tests/unit/runtime/test_memory_footprint.nompi.cc b/tests/unit/runtime/test_memory_footprint.nompi.cc
new file mode 100644
index 0000000000..c9f1c6ad8d
--- /dev/null
+++ b/tests/unit/runtime/test_memory_footprint.nompi.cc
@@ -0,0 +1,65 @@
+/*
+//@HEADER
+// *****************************************************************************
+//
+//                         test_memory_footprinting.cc
+//                           DARMA Toolkit v. 1.0.0
+//                       DARMA/vt => Virtual Transport
+//
+// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC
+// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
+// Government retains certain rights in this software.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+//   this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// * Neither the name of the copyright holder nor the names of its
+//   contributors may be used to endorse or promote products derived from this
+//   software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+// Questions? Contact darma@sandia.gov
+//
+// *****************************************************************************
+//@HEADER
+*/
+
+#include <gtest/gtest.h>
+
+#include <checkpoint/checkpoint.h>
+#include "vt/configs/arguments/args.h"
+
+#include "test_harness.h"
+
+namespace vt { namespace tests { namespace unit {
+
+using TestMemoryFootprinting = TestHarness;
+
+TEST_F(TestMemoryFootprinting, test_args) {
+  vt::arguments::ArgConfig args;
+
+  fmt::print("sizeof instance: {}\n", sizeof(args));
+
+  auto size = checkpoint::getMemoryFootprint<vt::arguments::ArgConfig>(args);
+  fmt::print("getMemoryFootprint: {}\n", size);
+}
+
+}}} /* end namespace vt::tests::unit */