diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index 089b640be2..cb966117a1 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -215,6 +215,175 @@ void parse_yaml(std::string& config_file, AppConfig& appConfig) { appConfig.vt_no_sigsegv = signal_handling["vt_no_SIGSEGV"].as(false); appConfig.vt_no_sigbus = signal_handling["vt_no_SIGBUS"].as(false); appConfig.vt_no_terminate = signal_handling["vt_no_terminate"].as(false); + + // Memory Usage Reporting + YAML::Node memory_usage_reporting = yaml_input["Memory Usage Reporting"]; + std::string default_vt_memory_reporters = +# if (vt_feature_mimalloc != 0) + "mimalloc," +# endif + "mstats,machinfo,selfstat,selfstatm,sbrk,mallinfo,getrusage,ps"; + appConfig.vt_memory_reporters = memory_usage_reporting["vt_memory_reporters"].as(default_vt_memory_reporters); + appConfig.vt_print_memory_each_phase = memory_usage_reporting["vt_print_memory_each_phase"].as(false); + appConfig.vt_print_memory_node = memory_usage_reporting["vt_print_memory_node"].as("0"); + appConfig.vt_allow_memory_report_with_ps = memory_usage_reporting["vt_allow_memory_report_with_ps"].as(false); + appConfig.vt_print_memory_at_threshold = memory_usage_reporting["vt_print_memory_at_threshold"].as(false); + appConfig.vt_print_memory_threshold = memory_usage_reporting["vt_print_memory_threshold"].as("1 GiB"); + appConfig.vt_print_memory_sched_poll = memory_usage_reporting["vt_print_memory_sched_poll"].as(100); + appConfig.vt_print_memory_footprint = memory_usage_reporting["vt_print_memory_footprint"].as(false); + + // Dump Stack Backtrace + YAML::Node dump_stack_backtrace = yaml_input["Dump Stack Backtrace"]; + appConfig.vt_no_warn_stack = dump_stack_backtrace["vt_no_warn_stack"].as(false); + appConfig.vt_no_assert_stack = dump_stack_backtrace["vt_no_assert_stack"].as(false); + appConfig.vt_no_abort_stack = dump_stack_backtrace["vt_no_abort_stack"].as(false); + appConfig.vt_no_stack = dump_stack_backtrace["vt_no_stack"].as(false); + appConfig.vt_stack_file = dump_stack_backtrace["vt_stack_file"].as(""); + appConfig.vt_stack_dir = dump_stack_backtrace["vt_stack_dir"].as(""); + appConfig.vt_stack_mod = dump_stack_backtrace["vt_stack_mod"].as(0); + + // Tracing Configuration + YAML::Node tracing_configuration = yaml_input["Tracing Configuration"]; + appConfig.vt_trace = tracing_configuration["vt_trace"].as(false); + appConfig.vt_trace_mpi = tracing_configuration["vt_trace_mpi"].as(false); + appConfig.vt_trace_pmpi = tracing_configuration["vt_trace_pmpi"].as(false); // maybe unncessary + appConfig.vt_trace_file = tracing_configuration["vt_trace_file"].as(""); + appConfig.vt_trace_dir = tracing_configuration["vt_trace_dir"].as(""); + appConfig.vt_trace_mod = tracing_configuration["vt_trace_mod"].as(0); + appConfig.vt_trace_flush_size = tracing_configuration["vt_trace_flush_size"].as(0); + appConfig.vt_trace_gzip_finish_flush = tracing_configuration["vt_trace_gzip_finish_flush"].as(false); + appConfig.vt_trace_sys_all = tracing_configuration["vt_trace_sys_all"].as(false); + appConfig.vt_trace_sys_term = tracing_configuration["vt_trace_sys_term"].as(false); + appConfig.vt_trace_sys_location = tracing_configuration["vt_trace_sys_location"].as(false); + appConfig.vt_trace_sys_collection = tracing_configuration["vt_trace_sys_collection"].as(false); + appConfig.vt_trace_sys_serial_msg = tracing_configuration["vt_trace_sys_serial_msg"].as(false); + appConfig.vt_trace_spec = tracing_configuration["vt_trace_spec"].as(false); + appConfig.vt_trace_spec_file = tracing_configuration["vt_trace_spec_file"].as(""); + appConfig.vt_trace_memory_usage = tracing_configuration["vt_trace_memory_usage"].as(false); + appConfig.vt_trace_event_polling = tracing_configuration["vt_trace_event_polling"].as(false); + appConfig.vt_trace_irecv_polling = tracing_configuration["vt_trace_irecv_polling"].as(false); + + // Debug Print Configuration + YAML::Node debug_print_configuration = yaml_input["Debug Print Configuration"]; + appConfig.vt_debug_level = debug_print_configuration["vt_debug_level"].as("terse"); + appConfig.vt_debug_all = debug_print_configuration["vt_debug_all"].as(false); + appConfig.vt_debug_none = debug_print_configuration["vt_debug_none"].as(false); + appConfig.vt_debug_gen = debug_print_configuration["vt_debug_gen"].as(false); + appConfig.vt_debug_runtime = debug_print_configuration["vt_debug_runtime"].as(false); + appConfig.vt_debug_active = debug_print_configuration["vt_debug_active"].as(false); + appConfig.vt_debug_term = debug_print_configuration["vt_debug_term"].as(false); + appConfig.vt_debug_termds = debug_print_configuration["vt_debug_termds"].as(false); + appConfig.vt_debug_barrier = debug_print_configuration["vt_debug_barrier"].as(false); + appConfig.vt_debug_event = debug_print_configuration["vt_debug_event"].as(false); + appConfig.vt_debug_pipe = debug_print_configuration["vt_debug_pipe"].as(false); + appConfig.vt_debug_pool = debug_print_configuration["vt_debug_pool"].as(false); + appConfig.vt_debug_reduce = debug_print_configuration["vt_debug_reduce"].as(false); + appConfig.vt_debug_rdma = debug_print_configuration["vt_debug_rdma"].as(false); + appConfig.vt_debug_rdma_channel = debug_print_configuration["vt_debug_rdma_channel"].as(false); + appConfig.vt_debug_rdma_state = debug_print_configuration["vt_debug_rdma_state"].as(false); + appConfig.vt_debug_handler = debug_print_configuration["vt_debug_handler"].as(false); + appConfig.vt_debug_hierlb = debug_print_configuration["vt_debug_hierlb"].as(false); + appConfig.vt_debug_temperedlb = debug_print_configuration["vt_debug_temperedlb"].as(false); + appConfig.vt_debug_temperedwmin = debug_print_configuration["vt_debug_temperedwmin"].as(false); + appConfig.vt_debug_scatter = debug_print_configuration["vt_debug_scatter"].as(false); + appConfig.vt_debug_serial_msg = debug_print_configuration["vt_debug_serial_msg"].as(false); + appConfig.vt_debug_trace = debug_print_configuration["vt_debug_trace"].as(false); + appConfig.vt_debug_location = debug_print_configuration["vt_debug_location"].as(false); + appConfig.vt_debug_lb = debug_print_configuration["vt_debug_lb"].as(false); + appConfig.vt_debug_vrt = debug_print_configuration["vt_debug_vrt"].as(false); + appConfig.vt_debug_vrt_coll = debug_print_configuration["vt_debug_vrt_coll"].as(false); + appConfig.vt_debug_worker = debug_print_configuration["vt_debug_worker"].as(false); + appConfig.vt_debug_group = debug_print_configuration["vt_debug_group"].as(false); + appConfig.vt_debug_broadcast = debug_print_configuration["vt_debug_broadcast"].as(false); + appConfig.vt_debug_objgroup = debug_print_configuration["vt_debug_objgroup"].as(false); + appConfig.vt_debug_phase = debug_print_configuration["vt_debug_phase"].as(false); + appConfig.vt_debug_context = debug_print_configuration["vt_debug_context"].as(false); + appConfig.vt_debug_epoch = debug_print_configuration["vt_debug_epoch"].as(false); + // appConfig.vt_debug_replay = debug_print_configuration["vt_debug_replay"].as(false); + appConfig.vt_debug_print_flush = debug_print_configuration["vt_debug_print_flush"].as(false); + + + // Load Balancing + YAML::Node load_balancing = yaml_input["Load Balancing"]; + appConfig.vt_lb = load_balancing["vt_lb"].as(false); + appConfig.vt_lb_quiet = load_balancing["vt_lb_quiet"].as(false); + appConfig.vt_lb_file_name = load_balancing["vt_lb_file_name"].as(""); + appConfig.vt_lb_show_config = load_balancing["vt_lb_show_config"].as(false); + appConfig.vt_lb_name = load_balancing["vt_lb_name"].as("NoLB"); + appConfig.vt_lb_args = load_balancing["vt_lb_args"].as(""); + appConfig.vt_lb_interval = load_balancing["vt_lb_interval"].as(1); + appConfig.vt_lb_keep_last_elm = load_balancing["vt_lb_keep_last_elm"].as(false); + appConfig.vt_lb_data = load_balancing["vt_lb_data"].as(false); + appConfig.vt_lb_data_in = load_balancing["vt_lb_data_in"].as(false); + appConfig.vt_lb_data_compress = load_balancing["vt_lb_data_compress"].as(false); + appConfig.vt_lb_data_dir = load_balancing["vt_lb_data_dir"].as("vt_lb_data"); + appConfig.vt_lb_data_file = load_balancing["vt_lb_data_file"].as("data.%p.json"); + appConfig.vt_lb_data_dir_in = load_balancing["vt_lb_data_dir_in"].as("vt_lb_data_in"); + appConfig.vt_lb_data_file_in = load_balancing["vt_lb_data_file_in"].as("data.%p.json"); + appConfig.vt_lb_statistics = load_balancing["vt_lb_statistics"].as(false); + appConfig.vt_lb_statistics_compress = load_balancing["vt_lb_statistics_compress"].as(false); + appConfig.vt_lb_statistics_file = load_balancing["vt_lb_statistics_file"].as("vt_lb_statistics.%t.json"); + appConfig.vt_lb_statistics_dir = load_balancing["vt_lb_statistics_dir"].as(""); + appConfig.vt_lb_self_migration = load_balancing["vt_lb_self_migration"].as(false); + appConfig.vt_lb_spec = load_balancing["vt_lb_spec"].as(false); + appConfig.vt_lb_spec_file = load_balancing["vt_lb_spec_file"].as(""); + // appConfig.vt_lb_run_lb_first_phase = load_balancing["vt_lb_run_lb_first_phase"].as(false); + + // Diagnostics + YAML::Node diagnostics = yaml_input["Diagnostics"]; + bool default_diag_enable; +#if (vt_diagnostics_runtime != 0) + default_diag_enable = true; +#else + default_diag_enable = false; +#endif + appConfig.vt_diag_print_summary = diagnostics["vt_diag_print_summary"].as(false); + appConfig.vt_diag_summary_file = diagnostics["vt_diag_summary_file"].as(""); + appConfig.vt_diag_summary_csv_file = diagnostics["vt_diag_summary_csv_file"].as("vtdiag.txt"); + appConfig.vt_diag_csv_base_units = diagnostics["vt_diag_csv_base_units"].as(false); + + // Termination + YAML::Node termination = yaml_input["Termination"]; + appConfig.vt_no_detect_hang = termination["vt_no_detect_hang"].as(false); + appConfig.vt_term_rooted_use_ds = termination["vt_term_rooted_use_ds"].as(false); + appConfig.vt_term_rooted_use_wave = termination["vt_term_rooted_use_wave"].as(false); + appConfig.vt_epoch_graph_on_hang = termination["vt_epoch_graph_on_hang"].as(true); + appConfig.vt_epoch_graph_terse = termination["vt_epoch_graph_terse"].as(false); + appConfig.vt_print_no_progress = termination["vt_print_no_progress"].as(true); + appConfig.vt_hang_freq = termination["vt_hang_freq"].as(1024); + + // Debugging/Launch + YAML::Node launch = yaml_input["Launch"]; + appConfig.vt_pause = launch["vt_pause"].as(false); + + // User Options + YAML::Node user_options = yaml_input["User Options"]; + appConfig.vt_user_1 = user_options["vt_user_1"].as(false); + appConfig.vt_user_2 = user_options["vt_user_2"].as(false); + appConfig.vt_user_3 = user_options["vt_user_3"].as(false); + appConfig.vt_user_int_1 = user_options["vt_user_int_1"].as(0); + appConfig.vt_user_int_2 = user_options["vt_user_int_2"].as(0); + appConfig.vt_user_int_3 = user_options["vt_user_int_3"].as(0); + appConfig.vt_user_str_1 = user_options["vt_user_str_1"].as(""); + appConfig.vt_user_str_2 = user_options["vt_user_str_2"].as(""); + appConfig.vt_user_str_3 = user_options["vt_user_str_3"].as(""); + + // Scheduler Configuration + YAML::Node scheduler_configuration = yaml_input["Scheduler Configuration"]; + appConfig.vt_sched_num_progress = scheduler_configuration["vt_sched_num_progress"].as(2); + appConfig.vt_sched_progress_han = scheduler_configuration["vt_sched_progress_han"].as(0); + appConfig.vt_sched_progress_sec = scheduler_configuration["vt_sched_progress_sec"].as(0.0); + + // Configuration File + YAML::Node configuration_file = yaml_input["Configuration File"]; + appConfig.vt_output_config = configuration_file["vt_output_config"].as(false); + appConfig.vt_output_config_file = configuration_file["vt_output_config_file"].as("vt_config.ini"); + + // Runtime + YAML::Node runtime = yaml_input["Runtime"]; + appConfig.vt_max_mpi_send_size = runtime["vt_max_mpi_send_size"].as(1ull << 30); + appConfig.vt_no_assert_fail = runtime["vt_no_assert_fail"].as(false); + appConfig.vt_throw_on_abort = runtime["vt_throw_on_abort"].as(false); } void addColorArgs(CLI::App& app, AppConfig& appConfig) { diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index cdecb2fbfb..1fe1c1af6f 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -164,7 +164,7 @@ TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { EXPECT_EQ(custom_argv[2], nullptr); } -TEST_F(TestInitialization, test_initialize_with_file_and_args) { +TEST_F(TestInitialization, test_initialize_with_toml_file_and_args) { MPI_Comm comm = MPI_COMM_WORLD; static char prog_name[]{"vt_program"}; @@ -210,7 +210,7 @@ TEST_F(TestInitialization, test_initialize_with_file_and_args) { EXPECT_EQ(custom_argv[2], nullptr); } -TEST_F(TestInitialization, test_initialize_with_file_args_and_appconfig) { +TEST_F(TestInitialization, test_initialize_with_toml_file_args_and_appconfig) { MPI_Comm comm = MPI_COMM_WORLD; static char prog_name[]{"vt_program"}; @@ -259,7 +259,7 @@ TEST_F(TestInitialization, test_initialize_with_file_args_and_appconfig) { EXPECT_EQ(custom_argv[2], nullptr); } -TEST_F(TestInitialization, test_preconfigure_and_initialization) { +TEST_F(TestInitialization, test_initialize_with_yaml_file_and_args) { MPI_Comm comm = MPI_COMM_WORLD; static char prog_name[]{"vt_program"}; @@ -267,11 +267,11 @@ TEST_F(TestInitialization, test_preconfigure_and_initialization) { static char vt_no_terminate[]{"--vt_no_terminate"}; static char vt_lb_name[]{"--vt_lb_name=RotateLB"}; - std::string config_file(getUniqueFilenameWithRanks(".toml")); + std::string config_file(getUniqueFilenameWithRanks(".yaml")); std::string config_flag("--vt_input_config="); std::string vt_input_config = config_flag + config_file; - std::vector custom_args; + std::vector custom_args; custom_args.emplace_back(prog_name); custom_args.emplace_back(cli_argument); custom_args.emplace_back(vt_no_terminate); @@ -280,13 +280,10 @@ TEST_F(TestInitialization, test_preconfigure_and_initialization) { custom_args.emplace_back(nullptr); int custom_argc = custom_args.size() - 1; - char** custom_argv = custom_args.data(); + char **custom_argv = custom_args.data(); EXPECT_EQ(custom_argc, 5); - arguments::AppConfig appConfig{}; - appConfig.vt_lb_name = "GreedyLB"; - int this_rank; MPI_Comm_rank(comm, &this_rank); if (this_rank == 0) { @@ -296,28 +293,65 @@ TEST_F(TestInitialization, test_preconfigure_and_initialization) { } MPI_Barrier(comm); - auto vtConfig = vt::preconfigure(custom_argc, custom_argv); + vt::initialize(custom_argc, custom_argv, &comm); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_no_terminate, true); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); EXPECT_EQ(custom_argc, 2); EXPECT_STREQ(custom_argv[0], "vt_program"); EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); EXPECT_EQ(custom_argv[2], nullptr); +} + +TEST_F(TestInitialization, test_initialize_with_yaml_file_args_and_appconfig) { + MPI_Comm comm = MPI_COMM_WORLD; + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + static char vt_lb_name[]{"--vt_lb_name=RotateLB"}; + + std::string config_file(getUniqueFilenameWithRanks(".yaml")); + std::string config_flag("--vt_input_config="); + std::string vt_input_config = config_flag + config_file; + + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(strdup(vt_input_config.c_str())); + custom_args.emplace_back(vt_lb_name); + custom_args.emplace_back(nullptr); - vt::initializePreconfigured(&comm, &appConfig); + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 5); + + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "GreedyLB"; - EXPECT_EQ(theConfig()->prog_name, "vt_unknown"); - EXPECT_EQ(theConfig()->vt_no_terminate, false); - EXPECT_EQ(theConfig()->vt_lb_name, "GreedyLB"); + int this_rank; + MPI_Comm_rank(comm, &this_rank); + if (this_rank == 0) { + std::ofstream cfg_file_{config_file.c_str(), std::ofstream::out | std::ofstream::trunc}; + cfg_file_ << "vt_lb_name = RandomLB\n"; + cfg_file_.close(); + } + MPI_Barrier(comm); - vt::finalize(); - vt::initializePreconfigured(&comm, &appConfig, vtConfig.get()); + vt::initialize(custom_argc, custom_argv, &comm, &appConfig); EXPECT_EQ(theConfig()->prog_name, "vt_program"); EXPECT_EQ(theConfig()->vt_no_terminate, true); EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); - vt::finalize(); - vt::initializePreconfigured(&comm, &appConfig, vtConfig.get()); + EXPECT_EQ(custom_argc, 2); + EXPECT_STREQ(custom_argv[0], "vt_program"); + EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); + EXPECT_EQ(custom_argv[2], nullptr); } }}} // end namespace vt::tests::unit