diff --git a/.clang-format b/.clang-format index 5e636a0797..6d9adac5a3 100644 --- a/.clang-format +++ b/.clang-format @@ -60,7 +60,7 @@ FixNamespaceComments: true IncludeBlocks: Preserve IndentCaseLabels: false IndentGotoLabels: false -IndentPPDirectives: BeforeHash +IndentPPDirectives: PPDIS_None IndentWidth: 2 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false diff --git a/CMakeLists.txt b/CMakeLists.txt index c597d5b586..04fd094cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.17 FATAL_ERROR) -project(vt VERSION 1.1.0) + +file(READ "VERSION" _vt_version_str) +string(STRIP "${_vt_version_str}" _vt_version_str) +project(vt VERSION ${_vt_version_str}) # To generate output file with compilation errors and warnings # CMake generator needs to be known @@ -64,8 +67,6 @@ include(cmake/link_vt.cmake) # Load packages that are required for core VT build include(cmake/load_packages.cmake) -include(cmake/build_git_info.cmake) - include(cmake/check_compiler.cmake) option(vt_gold_linker_enabled "Build VT using the `gold' linker" ON) diff --git a/cmake-modules/GetGitRevisionDescription.cmake b/cmake-modules/GetGitRevisionDescription.cmake deleted file mode 100644 index 2ebfd40d20..0000000000 --- a/cmake-modules/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,166 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ ...]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# git_local_changes() -# -# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. -# Uses the return code of "git diff-index --quiet HEAD --". -# Does not regard untracked files. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -function(get_git_head_revision _refspecvar _hashvar) - set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories - set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") - get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) - if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) - # We have reached the root directory, we are not in git - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - endwhile() - # check if this is a submodule - if(NOT IS_DIRECTORY ${GIT_DIR}) - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${GIT_DIR}/HEAD") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" - @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) - set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - describe - ${hash} - ${ARGN} - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_local_changes _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - diff-index --quiet HEAD -- - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(res EQUAL 0) - set(${_var} "CLEAN" PARENT_SCOPE) - else() - set(${_var} "DIRTY" PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake-modules/GetGitRevisionDescription.cmake.in b/cmake-modules/GetGitRevisionDescription.cmake.in deleted file mode 100644 index 6d8b708efe..0000000000 --- a/cmake-modules/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,41 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -set(HEAD_HASH) - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - else() - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH) - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index be71af34ff..8d47e28479 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -1,34 +1,46 @@ +find_package(Git REQUIRED) -include(GetGitRevisionDescription) +set(GIT_DIR) +set(HEAD_FILE) +execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir + WORKING_DIRECTORY + "${PROJECT_BASE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + REL_GIT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) +if (NOT res EQUAL 0) + message(STATUS "git invocation failed, git info cannot be obtained") +else() + get_filename_component(GIT_DIR ${REL_GIT_DIR} ABSOLUTE BASE_DIR ${PROJECT_BASE_DIR}) + message(STATUS "Git DIR: ${GIT_DIR}") + if (NOT GIT_DIR) + message(STATUS "no git directory present") + else() + if(NOT EXISTS "${GIT_DIR}/HEAD") + message(STATUS "no such file: \"${GIT_DIR}/HEAD\"") + else() + set(HEAD_FILE "${GIT_DIR}/HEAD") + message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") + endif() + endif() +endif() -get_git_head_revision(GIT_REFSPEC GIT_SHA1) +set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc") +add_custom_command( + OUTPUT ${VT_GIT_CONFIG_FILE} + COMMAND ${CMAKE_COMMAND} + -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in + -DOUT_FILE=${VT_GIT_CONFIG_FILE} + -DGIT_EXECUTABLE=${GIT_EXECUTABLE} + -DGIT_DIR=${GIT_DIR} + -DHEAD_FILE=${HEAD_FILE} + -DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + -DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR} + -DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH} + -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake + DEPENDS ${GIT_DIR} + ) -# set some variables related to GIT state information -get_git_head_revision(GIT_REFSPEC GIT_SHA1) -git_describe(GIT_EXACT_TAG --tags --abbrev=0 --all) -git_describe(GIT_DESCRIPTION --abbrev=10 --always --tags --long --all) -git_local_changes(GIT_CLEAN_STATUS) - -message(STATUS "REF:${GIT_REFSPEC}") -message(STATUS "REF:${GIT_SHA1}") -message(STATUS "REF:${GIT_DESCRIPTION}") -message(STATUS "REF:${GIT_CLEAN_STATUS}") -message(STATUS "REF:${GIT_EXACT_TAG}") - -configure_file( - ${PROJECT_BASE_DIR}/vt_git_revision.cc.in - ${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc - @ONLY -) - -# install( -# FILES "${PROJECT_BINARY_DIR}/${cur_build_type}/cmake_config.h" -# DESTINATION include -# CONFIGURATIONS ${cur_build_type} -# ) - -# configure_file( -# "${PROJECT_SOURCE_DIR}/vt_git_revision.cc.in" -# "${CMAKE_CURRENT_BINARY_DIR}/vt_git_revision.cc" -# @ONLY -# ) +target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) diff --git a/cmake/load_doxygen.cmake b/cmake/load_doxygen.cmake index 81849cd175..616dcdf7cd 100644 --- a/cmake/load_doxygen.cmake +++ b/cmake/load_doxygen.cmake @@ -10,9 +10,9 @@ if (${vt_doxygen_enabled}) set(doxygen_out ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) set(DOXYGEN_PROJECT_NAME "vt") - set(VERSION_MAJOR "1") - set(VERSION_MINOR "0") - set(VERSION_PATCH "0") + set(VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") + set(VERSION_MINOR "${PROJECT_VERSION_MINOR}") + set(VERSION_PATCH "${PROJECT_VERSION_PATCH}") set(DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") set(DOXYGEN_CHECKPOINT_SHARED_DOCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/docs/shared") set(DOXYGEN_CHECKPOINT_EXAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/examples") diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake new file mode 100644 index 0000000000..73c341e0fb --- /dev/null +++ b/cmake/run-git.cmake @@ -0,0 +1,103 @@ +# This file is intented to be run with cmake -P + +# Derived from +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +message(STATUS "Reading head file ${HEAD_FILE}") +message(STATUS "Using git executable at \"${GIT_EXECUTABLE}\"") + +set(ROOT_DIR) +if (GIT_DIR) + get_filename_component(ROOT_DIR ${GIT_DIR} DIRECTORY) +endif() + +set(GIT_SHA1) + +file(READ "${HEAD_FILE}" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" GIT_REFSPEC "${HEAD_CONTENTS}") +endif() + +message(STATUS "GIT_REFSPEC: \"${GIT_REFSPEC}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + rev-parse --verify HEAD + WORKING_DIRECTORY + "${ROOT_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_SHA1 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(STATUS "could not get the git sha1") +endif() + +message(STATUS "GIT_SHA1: \"${GIT_SHA1}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${GIT_SHA1} + --tags --abbrev=0 --all + WORKING_DIRECTORY + "${ROOT_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_EXACT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(STATUS "could not get the exact git tag") +endif() + +message(STATUS "GIT_EXACT_TAG: \"${GIT_EXACT_TAG}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${GIT_SHA1} + --abbrev=10 --always --tags --long --all + WORKING_DIRECTORY + "${ROOT_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_DESCRIPTION + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(STATUS "could not get the description") +endif() + +message(STATUS "GIT_DESCRIPTION: \"${GIT_DESCRIPTION}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + diff-index --quiet HEAD -- + WORKING_DIRECTORY + "${ROOT_DIR}" + RESULT_VARIABLE + res + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(res EQUAL 0) + set(GIT_CLEAN_STATUS "CLEAN") +else() + set(GIT_CLEAN_STATUS "DIRTY") +endif() + +message(STATUS "Git Clean Status: \"${GIT_CLEAN_STATUS}\"") + +message(STATUS "Configuring ${IN_FILE} to generate ${OUT_FILE}.") +configure_file(${IN_FILE} ${OUT_FILE} @ONLY) diff --git a/cmake/trace_only_functions.cmake b/cmake/trace_only_functions.cmake index 0987892c80..700833891b 100644 --- a/cmake/trace_only_functions.cmake +++ b/cmake/trace_only_functions.cmake @@ -30,7 +30,7 @@ function(create_trace_only_target) # vt/configs vt/configs/generated/vt_git_revision.h vt/configs/error/hard_error.h - vt/configs/features/features_enableif.h vt/configs/features/features_featureswitch.h + vt/configs/features/features_featureswitch.h vt/configs/features/features_defines.h vt/configs/types/types_type.h vt/configs/error/pretty_print_message.h vt/configs/debug/debug_masterconfig.h vt/configs/debug/debug_config.h diff --git a/docs/md/tutorial.md b/docs/md/tutorial.md index e0b042a30d..93dbbe71c8 100644 --- a/docs/md/tutorial.md +++ b/docs/md/tutorial.md @@ -30,6 +30,43 @@ int main(int argc, char** argv) { } \endcode +If, for any reason, you want to predefine configuration, you can do it +by creating `AppConfig` object, setting its members as you wish, +and passing it to `vt::initialize`: + +\code{.cpp} +int main(int argc, char** argv) { + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(argc, argv, &appConfig); + // program here + vt::finalize(); +} +\endcode + +You can do also do it if you initialized MPI on your own: + +\code{.cpp} +int main(int argc, char** argv) { + MPI_Init(&argc, &argv); + + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(argc, argv, &MPI_COMM_WORLD, &appConfig); + // program here + vt::finalize(); + MPI_Finalize(); +} +\endcode + +It is worth noting that if you run your application with any of vt's command-line arguments and at the same time you define and pass `AppConfig` to `vt::initialize`, CLI arguments have a higher priority. In other words, if you predefine in source code and give from the command line the same vt's argument, but with a different value, the program will use the CLI one. + +There is also an option to use configuration file. Refer to CLI11 documentation for details https://cliutils.github.io/CLI11/book/chapters/config.html. Important thing to remember - CLI11 processes configuration file before command line arguments, so in the end command line arguments might overwrite values defined in configuration file. + \section tutorial-walkthrough Tutorial Code Snippets This page walks through the tutorial that exists in the source code. See diff --git a/examples/hello_world/objgroup.cc b/examples/hello_world/objgroup.cc index e5e36c1c32..4c07e01d2c 100644 --- a/examples/hello_world/objgroup.cc +++ b/examples/hello_world/objgroup.cc @@ -57,7 +57,7 @@ struct MyObjGroup { }; int main(int argc, char** argv) { - vt::initialize(argc, argv, nullptr); + vt::initialize(argc, argv); vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3f1969656..52fa0bab8c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -204,6 +204,8 @@ add_library( ${HEADER_FILES} ${SOURCE_FILES} ) +include(${CMAKE_CURRENT_LIST_DIR}/../cmake/build_git_info.cmake) + option(vt_no_color_enabled "Build VT with option --vt_no_color set to true by default" OFF) if(vt_no_color_enabled) message(STATUS "Building VT with --vt_no_color set to true by default") diff --git a/src/vt/collective/collective_ops.cc b/src/vt/collective/collective_ops.cc index 8da2080fdd..93a2d2d6c9 100644 --- a/src/vt/collective/collective_ops.cc +++ b/src/vt/collective/collective_ops.cc @@ -42,6 +42,7 @@ */ #include "vt/collective/collective_ops.h" +#include "vt/context/context.h" #include "vt/runtime/runtime.h" #include "vt/scheduler/scheduler.h" #include "vt/runtime/runtime_inst.h" @@ -53,10 +54,166 @@ namespace vt { +namespace { + +#define printIfOverwritten(opt) \ + do { \ + if (cliConfig.opt != appConfig.opt) { \ + ++overwrittens; \ + fmt::print( \ + "{}\t{}--" #opt "{}\n", \ + vt_pre, magenta, reset \ + ); \ + } \ + } while (0) + +void printOverwrittens( + vt::arguments::AppConfig const &cliConfig, + vt::arguments::AppConfig const &appConfig +) { + auto const green = debug::green(); + auto const reset = debug::reset(); + auto const magenta = debug::magenta(); + auto const vt_pre = debug::vtPre(); + + fmt::print( + "{}{}Predefined options overwritten by CLI arguments:{}\n", + vt_pre, green, reset + ); + + int overwrittens = 0; + + printIfOverwritten(vt_color); + printIfOverwritten(vt_no_color); + printIfOverwritten(vt_quiet); + printIfOverwritten(vt_sched_progress_han); + printIfOverwritten(vt_sched_progress_sec); + printIfOverwritten(vt_no_sigint); + printIfOverwritten(vt_no_sigsegv); + printIfOverwritten(vt_no_sigbus); + printIfOverwritten(vt_no_terminate); + printIfOverwritten(vt_memory_reporters); + printIfOverwritten(vt_print_memory_each_phase); + printIfOverwritten(vt_print_memory_node); + printIfOverwritten(vt_allow_memory_report_with_ps); + printIfOverwritten(vt_print_memory_at_threshold); + printIfOverwritten(vt_print_memory_threshold); + printIfOverwritten(vt_print_memory_sched_poll); + printIfOverwritten(vt_print_memory_footprint); + printIfOverwritten(vt_no_warn_stack); + printIfOverwritten(vt_no_assert_stack); + printIfOverwritten(vt_no_abort_stack); + printIfOverwritten(vt_no_stack); + printIfOverwritten(vt_stack_file); + printIfOverwritten(vt_stack_dir); + printIfOverwritten(vt_stack_mod); + printIfOverwritten(vt_trace); + printIfOverwritten(vt_trace_mpi); + printIfOverwritten(vt_trace_pmpi); + printIfOverwritten(vt_trace_sys_all); + printIfOverwritten(vt_trace_sys_term); + printIfOverwritten(vt_trace_sys_location); + printIfOverwritten(vt_trace_sys_collection); + printIfOverwritten(vt_trace_sys_serial_msg); + printIfOverwritten(vt_trace_file); + printIfOverwritten(vt_trace_dir); + printIfOverwritten(vt_trace_mod); + printIfOverwritten(vt_trace_flush_size); + printIfOverwritten(vt_trace_spec); + printIfOverwritten(vt_trace_spec_file); + printIfOverwritten(vt_trace_memory_usage); + printIfOverwritten(vt_trace_event_polling); + printIfOverwritten(vt_trace_irecv_polling); + printIfOverwritten(vt_lb); + printIfOverwritten(vt_lb_show_spec); + printIfOverwritten(vt_lb_quiet); + printIfOverwritten(vt_lb_file_name); + printIfOverwritten(vt_lb_name); + printIfOverwritten(vt_lb_args); + printIfOverwritten(vt_lb_interval); + printIfOverwritten(vt_lb_stats); + printIfOverwritten(vt_lb_stats_compress); + printIfOverwritten(vt_lb_stats_dir); + printIfOverwritten(vt_lb_stats_file); + printIfOverwritten(vt_lb_stats_dir_in); + printIfOverwritten(vt_lb_stats_file_in); + printIfOverwritten(vt_help_lb_args); + printIfOverwritten(vt_no_detect_hang); + printIfOverwritten(vt_print_no_progress); + printIfOverwritten(vt_epoch_graph_on_hang); + printIfOverwritten(vt_epoch_graph_terse); + printIfOverwritten(vt_term_rooted_use_ds); + printIfOverwritten(vt_term_rooted_use_wave); + printIfOverwritten(vt_hang_freq); + printIfOverwritten(vt_diag_enable); + printIfOverwritten(vt_diag_print_summary); + printIfOverwritten(vt_diag_summary_csv_file); + printIfOverwritten(vt_diag_summary_file); + printIfOverwritten(vt_diag_csv_base_units); + printIfOverwritten(vt_pause); + printIfOverwritten(vt_no_assert_fail); + printIfOverwritten(vt_throw_on_abort); + printIfOverwritten(vt_max_mpi_send_size); + printIfOverwritten(vt_debug_level); + printIfOverwritten(vt_debug_all); + printIfOverwritten(vt_debug_none); + printIfOverwritten(vt_debug_gen); + printIfOverwritten(vt_debug_runtime); + printIfOverwritten(vt_debug_active); + printIfOverwritten(vt_debug_term); + printIfOverwritten(vt_debug_termds); + printIfOverwritten(vt_debug_barrier); + printIfOverwritten(vt_debug_event); + printIfOverwritten(vt_debug_pipe); + printIfOverwritten(vt_debug_pool); + printIfOverwritten(vt_debug_reduce); + printIfOverwritten(vt_debug_rdma); + printIfOverwritten(vt_debug_rdma_channel); + printIfOverwritten(vt_debug_rdma_state); + printIfOverwritten(vt_debug_param); + printIfOverwritten(vt_debug_handler); + printIfOverwritten(vt_debug_hierlb); + printIfOverwritten(vt_debug_temperedlb); + printIfOverwritten(vt_debug_scatter); + printIfOverwritten(vt_debug_sequence); + printIfOverwritten(vt_debug_sequence_vrt); + printIfOverwritten(vt_debug_serial_msg); + printIfOverwritten(vt_debug_trace); + printIfOverwritten(vt_debug_location); + printIfOverwritten(vt_debug_lb); + printIfOverwritten(vt_debug_vrt); + printIfOverwritten(vt_debug_vrt_coll); + printIfOverwritten(vt_debug_worker); + printIfOverwritten(vt_debug_group); + printIfOverwritten(vt_debug_broadcast); + printIfOverwritten(vt_debug_objgroup); + printIfOverwritten(vt_debug_phase); + printIfOverwritten(vt_debug_context); + printIfOverwritten(vt_debug_epoch); + printIfOverwritten(vt_debug_print_flush); + printIfOverwritten(vt_user_1); + printIfOverwritten(vt_user_2); + printIfOverwritten(vt_user_3); + printIfOverwritten(vt_user_int_1); + printIfOverwritten(vt_user_int_2); + printIfOverwritten(vt_user_int_3); + printIfOverwritten(vt_user_str_1); + printIfOverwritten(vt_user_str_2); + printIfOverwritten(vt_user_str_3); + printIfOverwritten(vt_output_config); + printIfOverwritten(vt_output_config_file); + + if (overwrittens == 0) { + fmt::print("{}\tNone.\n", vt_pre); + } +} + +} /* end anon namespace */ + template RuntimePtrType CollectiveAnyOps::initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop, MPI_Comm* comm + bool is_interop, MPI_Comm* comm, arguments::AppConfig const* appConfig ) { using vt::runtime::RuntimeInst; using vt::runtime::Runtime; @@ -66,7 +223,8 @@ RuntimePtrType CollectiveAnyOps::initialize( #pragma sst global rt RuntimeInst::rt = std::make_unique( - argc, argv, num_workers, is_interop, resolved_comm + argc, argv, num_workers, is_interop, resolved_comm, + eRuntimeInstance::DefaultInstance, appConfig ); #pragma sst global rt @@ -79,6 +237,12 @@ RuntimePtrType CollectiveAnyOps::initialize( #pragma sst global rt RuntimeInst::rt->initialize(); + // If appConfig is not nullptr, compare CLI arguments with user-defined ones, + // and report overwritten ones. + if (appConfig && theContext()->getNode() == 0) { + printOverwrittens(*rt->getAppConfig(), *appConfig); + } + return runtime::makeRuntimePtr(rt_ptr); } diff --git a/src/vt/collective/collective_ops.h b/src/vt/collective/collective_ops.h index 2fb310e40e..849ac3a6a7 100644 --- a/src/vt/collective/collective_ops.h +++ b/src/vt/collective/collective_ops.h @@ -63,7 +63,8 @@ struct CollectiveAnyOps { // The general methods that interact with the managed runtime holder static RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers = no_workers, - bool is_interop = false, MPI_Comm* comm = nullptr + bool is_interop = false, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr ); static void finalize(RuntimePtrType in_rt = nullptr); static void scheduleThenFinalize( diff --git a/src/vt/collective/reduce/reduce.impl.h b/src/vt/collective/reduce/reduce.impl.h index 566cb33279..6fbc3d7183 100644 --- a/src/vt/collective/reduce/reduce.impl.h +++ b/src/vt/collective/reduce/reduce.impl.h @@ -78,9 +78,10 @@ void Reduce::reduceRootRecv(MsgT* msg) { msg->is_root_ = true; auto const& from_node = theContext()->getFromNodeCurrentTask(); + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; auto m = promoteMsg(msg); - runnable::makeRunnable(m, false, handler, from_node) + runnable::makeRunnable(m, false, handler, from_node, han_type) .withTDEpochFromMsg() .run(); } @@ -258,7 +259,8 @@ void Reduce::startReduce(detail::ReduceStamp id, bool use_num_contrib) { // this needs to run inline.. threaded not allowed for reduction // combination - runnable::makeRunnable(state.msgs[0], false, handler, from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(state.msgs[0], false, handler, from_node, han_type) .withTDEpochFromMsg() .run(); } diff --git a/src/vt/collective/reduce/scoping/strong_types.h b/src/vt/collective/reduce/scoping/strong_types.h index 3e24a4b481..c4e8eeffd8 100644 --- a/src/vt/collective/reduce/scoping/strong_types.h +++ b/src/vt/collective/reduce/scoping/strong_types.h @@ -46,6 +46,7 @@ #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #include "vt/utils/strong/strong_type.h" namespace vt { namespace collective { namespace reduce { namespace detail { diff --git a/src/vt/collective/startup.cc b/src/vt/collective/startup.cc index f6c862ab12..1c01d3d56d 100644 --- a/src/vt/collective/startup.cc +++ b/src/vt/collective/startup.cc @@ -52,14 +52,20 @@ namespace vt { // vt::{initialize,finalize} for main ::vt namespace RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop, MPI_Comm* comm + bool is_interop, MPI_Comm* comm, arguments::AppConfig const* appConfig ) { - return CollectiveOps::initialize(argc,argv,num_workers,is_interop,comm); + return CollectiveOps::initialize( + argc, argv, num_workers, is_interop, comm, appConfig + ); } -RuntimePtrType initialize(int& argc, char**& argv, MPI_Comm* comm) { +RuntimePtrType initialize( + int& argc, char**& argv, MPI_Comm* comm, arguments::AppConfig const* appConfig +) { bool const is_interop = comm != nullptr; - return CollectiveOps::initialize(argc,argv,no_workers,is_interop,comm); + return CollectiveOps::initialize( + argc, argv, no_workers, is_interop, comm, appConfig + ); } RuntimePtrType initialize(MPI_Comm* comm) { @@ -69,6 +75,18 @@ RuntimePtrType initialize(MPI_Comm* comm) { return CollectiveOps::initialize(argc,argv,no_workers,is_interop,comm); } +RuntimePtrType initialize( + int& argc, char**& argv, arguments::AppConfig const* appConfig +) { + return initialize(argc, argv, nullptr, appConfig); +} + +RuntimePtrType initialize(arguments::AppConfig const* appConfig) { + int argc = 0; + char** argv = nullptr; + return initialize(argc, argv, nullptr, appConfig); +} + void finalize(RuntimePtrType in_rt) { if (in_rt) { return CollectiveOps::finalize(std::move(in_rt)); diff --git a/src/vt/collective/startup.h b/src/vt/collective/startup.h index e03a09c36d..2f50850c0c 100644 --- a/src/vt/collective/startup.h +++ b/src/vt/collective/startup.h @@ -51,10 +51,17 @@ namespace vt { RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop = false, MPI_Comm* comm = nullptr + bool is_interop = false, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr +); +RuntimePtrType initialize( + int& argc, char**& argv, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr ); -RuntimePtrType initialize(int& argc, char**& argv, MPI_Comm* comm = nullptr); RuntimePtrType initialize(MPI_Comm* comm = nullptr); +RuntimePtrType initialize( + int& argc, char**& argv, arguments::AppConfig const* appConfig +); void finalize(RuntimePtrType in_rt); void finalize(); diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index 7a8dfc1218..1f3b92a0a7 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -56,21 +56,141 @@ namespace vt { namespace arguments { // Temporary variables used only for parsing artifacts. namespace { + std::vector arg_trace_mpi; -} /* end anon namespace */ -/*static*/ std::unique_ptr -ArgConfig::construct(std::unique_ptr arg) { - return arg; +/** + * \internal + * Application specific cleanup and mapping to actual app args. + */ +void postParseTransform(AppConfig& appConfig) { + auto contains = [](std::vector &v, std::string str){ + return std::find(v.begin(), v.end(), str) not_eq v.end(); + }; + + appConfig.vt_trace_mpi = contains(arg_trace_mpi, "internal"); + appConfig.vt_trace_pmpi = contains(arg_trace_mpi, "external"); + + using config::ModeEnum; + + auto const& level = appConfig.vt_debug_level; + if (level == "terse" or level == "0") { + appConfig.vt_debug_level_val = ModeEnum::terse; + } else if (level == "normal" or level == "1") { + appConfig.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; + } else if (level == "verbose" or level == "2") { + appConfig.vt_debug_level_val = + ModeEnum::terse | ModeEnum::normal | ModeEnum::verbose; + } else { + vtAbort("Invalid value passed to --vt_debug_level"); + } +} + +std::tuple parseArguments( + CLI::App& app, int& argc, char**& argv, AppConfig& appConfig +) { + + std::vector vt_args; + + // Load up vectors (has curious ability to altnerate vt/mpi/passthru) + std::vector* rargs = nullptr; + for (int i = 1; i < argc; i++) { + char* c = argv[i]; + if (0 == strcmp(c, "--vt_args")) { + rargs = &vt_args; + } else if (0 == strcmp(c, "--")) { + rargs = &appConfig.passthru_args; + } else if (rargs) { + rargs->push_back(c); + } else if (0 == strncmp(c, "--vt_", 5)) { + // Implicit start of VT args allows pass-thru 'for compatibility' + // although the recommended calling pattern to always provide VT args first. + rargs = &vt_args; + rargs->push_back(c); + } else { + appConfig.passthru_args.push_back(c); + } + } + + // All must be accounted for + app.allow_extras(false); + + // Build string-vector and reverse order to parse (CLI quirk) + std::vector args_to_parse; + for (auto it = vt_args.crbegin(); it != vt_args.crend(); ++it) { + args_to_parse.push_back(*it); + } + + // Allow a input config file + app.set_config( + "--vt_input_config", + "", // no default file name + "Read in an ini config file for VT", + false // not required + ); + + try { + app.parse(args_to_parse); + } catch (CLI::Error &ex) { + // Return exit code and message, delaying logic processing of such. + // The default exit code for 'help' is 0. + std::stringstream message_stream; + int result = app.exit(ex, message_stream, message_stream); + + return std::make_tuple(result, message_stream.str()); + } + + // If the user specified to output the full configuration, save it in a string + // so node 0 can output in the runtime once MPI is init'ed + if (appConfig.vt_output_config) { + appConfig.vt_output_config_str = app.config_to_str(true, true); + } + + // Get the clean prog name; don't allow path bleed in usages. + // std::filesystem is C++17. + std::string clean_prog_name = argv[0]; + size_t l = clean_prog_name.find_last_of("/\\"); + if (l not_eq std::string::npos and l + 1 < clean_prog_name.size()) { + clean_prog_name = clean_prog_name.substr(l + 1, std::string::npos); + } + + appConfig.prog_name = clean_prog_name; + appConfig.argv_prog_name = argv[0]; + + postParseTransform(appConfig); + + // Rebuild passthru into ref-returned argc/argv + + // It should be possible to modify the original argv as the outgoing + // number of arguments is always less. As currently allocated here, + // ownership of the new object is ill-defined. + int new_argc = appConfig.passthru_args.size() + 1; // does not include argv[0] + + static std::unique_ptr new_argv = nullptr; + + new_argv = std::make_unique(new_argc + 1); + + int i = 0; + new_argv[i++] = appConfig.argv_prog_name; + for (auto&& arg : appConfig.passthru_args) { + new_argv[i++] = arg; + } + new_argv[i++] = nullptr; + + // Set them back with all vt (and MPI) arguments elided + argc = new_argc; + argv = new_argv.get(); + + return std::make_tuple(-1, std::string{}); } -void ArgConfig::addColorArgs(CLI::App& app) { +void addColorArgs(CLI::App& app, AppConfig& appConfig) { auto quiet = "Quiet the output from vt (only errors, warnings)"; auto always = "Colorize output (default)"; auto never = "Do not colorize output (overrides --vt_color)"; - auto a = app.add_flag("--vt_color", config_.vt_color, always); - auto b = app.add_flag("--vt_no_color", config_.vt_no_color, never); - auto a1 = app.add_flag("--vt_quiet", config_.vt_quiet, quiet); + auto a = app.add_flag("--vt_color", appConfig.vt_color, always); + auto b = app.add_flag("--vt_no_color", appConfig.vt_no_color, never); + auto a1 = app.add_flag("--vt_quiet", appConfig.vt_quiet, quiet); auto outputGroup = "Output Control"; a->group(outputGroup); b->group(outputGroup); @@ -81,15 +201,15 @@ void ArgConfig::addColorArgs(CLI::App& app) { // b->excludes(a); } -void ArgConfig::addSignalArgs(CLI::App& app) { +void addSignalArgs(CLI::App& app, AppConfig& appConfig) { auto no_sigint = "Do not register signal handler for SIGINT"; auto no_sigsegv = "Do not register signal handler for SIGSEGV"; auto no_sigbus = "Do not register signal handler for SIGBUS"; auto no_terminate = "Do not register handler for std::terminate"; - auto d = app.add_flag("--vt_no_SIGINT", config_.vt_no_sigint, no_sigint); - auto e = app.add_flag("--vt_no_SIGSEGV", config_.vt_no_sigsegv, no_sigsegv); - auto g = app.add_flag("--vt_no_SIGBUS", config_.vt_no_sigbus, no_sigbus); - auto f = app.add_flag("--vt_no_terminate", config_.vt_no_terminate, no_terminate); + auto d = app.add_flag("--vt_no_SIGINT", appConfig.vt_no_sigint, no_sigint); + auto e = app.add_flag("--vt_no_SIGSEGV", appConfig.vt_no_sigsegv, no_sigsegv); + auto g = app.add_flag("--vt_no_SIGBUS", appConfig.vt_no_sigbus, no_sigbus); + auto f = app.add_flag("--vt_no_terminate", appConfig.vt_no_terminate, no_terminate); auto signalGroup = "Signal Handling"; d->group(signalGroup); e->group(signalGroup); @@ -97,7 +217,7 @@ void ArgConfig::addSignalArgs(CLI::App& app) { g->group(signalGroup); } -void ArgConfig::addMemUsageArgs(CLI::App& app) { +void addMemUsageArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for controlling memory usage reporting */ @@ -109,14 +229,14 @@ void ArgConfig::addMemUsageArgs(CLI::App& app) { auto mem_thresh = "The threshold increments to print memory usage: \" {GiB,MiB,KiB,B}\""; auto mem_sched = "The frequency to query the memory threshold check (some memory reporters might be expensive)"; auto mem_footprint = "Print live components' memory footprint after initialization and before shutdown"; - auto mm = app.add_option("--vt_memory_reporters", config_.vt_memory_reporters, mem_desc, true); - auto mn = app.add_flag("--vt_print_memory_each_phase", config_.vt_print_memory_each_phase, mem_phase); - auto mo = app.add_option("--vt_print_memory_node", config_.vt_print_memory_node, mem_node, true); - auto mp = app.add_flag("--vt_allow_memory_report_with_ps", config_.vt_allow_memory_report_with_ps, mem_ps); - auto mq = app.add_flag("--vt_print_memory_at_threshold", config_.vt_print_memory_at_threshold, mem_at_thresh); - auto mr = app.add_option("--vt_print_memory_threshold", config_.vt_print_memory_threshold, mem_thresh, true); - auto ms = app.add_option("--vt_print_memory_sched_poll", config_.vt_print_memory_sched_poll, mem_sched, true); - auto mf = app.add_flag("--vt_print_memory_footprint", config_.vt_print_memory_footprint, mem_footprint); + auto mm = app.add_option("--vt_memory_reporters", appConfig.vt_memory_reporters, mem_desc, true); + auto mn = app.add_flag("--vt_print_memory_each_phase", appConfig.vt_print_memory_each_phase, mem_phase); + auto mo = app.add_option("--vt_print_memory_node", appConfig.vt_print_memory_node, mem_node, true); + auto mp = app.add_flag("--vt_allow_memory_report_with_ps", appConfig.vt_allow_memory_report_with_ps, mem_ps); + auto mq = app.add_flag("--vt_print_memory_at_threshold", appConfig.vt_print_memory_at_threshold, mem_at_thresh); + auto mr = app.add_option("--vt_print_memory_threshold", appConfig.vt_print_memory_threshold, mem_thresh, true); + auto ms = app.add_option("--vt_print_memory_sched_poll", appConfig.vt_print_memory_sched_poll, mem_sched, true); + auto mf = app.add_flag("--vt_print_memory_footprint", appConfig.vt_print_memory_footprint, mem_footprint); auto memoryGroup = "Memory Usage Reporting"; mm->group(memoryGroup); mn->group(memoryGroup); @@ -128,8 +248,7 @@ void ArgConfig::addMemUsageArgs(CLI::App& app) { mf->group(memoryGroup); } - -void ArgConfig::addStackDumpArgs(CLI::App& app) { +void addStackDumpArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags to control stack dumping */ @@ -140,13 +259,13 @@ void ArgConfig::addStackDumpArgs(CLI::App& app) { auto file = "Dump stack traces to file instead of stdout"; auto dir = "Name of directory to write stack files"; auto mod = "Write stack dump if (node % config_.vt_stack_mod) == 0"; - auto g = app.add_flag("--vt_no_warn_stack", config_.vt_no_warn_stack, warn); - auto h = app.add_flag("--vt_no_assert_stack", config_.vt_no_assert_stack, assert); - auto i = app.add_flag("--vt_no_abort_stack", config_.vt_no_abort_stack, abort); - auto j = app.add_flag("--vt_no_stack", config_.vt_no_stack, stack); - auto k = app.add_option("--vt_stack_file", config_.vt_stack_file, file, ""); - auto l = app.add_option("--vt_stack_dir", config_.vt_stack_dir, dir, ""); - auto m = app.add_option("--vt_stack_mod", config_.vt_stack_mod, mod, 1); + auto g = app.add_flag("--vt_no_warn_stack", appConfig.vt_no_warn_stack, warn); + auto h = app.add_flag("--vt_no_assert_stack", appConfig.vt_no_assert_stack, assert); + auto i = app.add_flag("--vt_no_abort_stack", appConfig.vt_no_abort_stack, abort); + auto j = app.add_flag("--vt_no_stack", appConfig.vt_no_stack, stack); + auto k = app.add_option("--vt_stack_file", appConfig.vt_stack_file, file, ""); + auto l = app.add_option("--vt_stack_dir", appConfig.vt_stack_dir, dir, ""); + auto m = app.add_option("--vt_stack_mod", appConfig.vt_stack_mod, mod, 1); auto stackGroup = "Dump Stack Backtrace"; g->group(stackGroup); h->group(stackGroup); @@ -157,7 +276,7 @@ void ArgConfig::addStackDumpArgs(CLI::App& app) { m->group(stackGroup); } -void ArgConfig::addTraceArgs(CLI::App& app) { +void addTraceArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags to control tracing output */ @@ -179,24 +298,24 @@ void ArgConfig::addTraceArgs(CLI::App& app) { auto tmemusage = "Trace memory usage using first memory reporter"; auto tpolled = "Trace AsyncEvent component polling (inc. MPI_Isend requests)"; auto tirecv = "Trace MPI_Irecv request polling"; - auto n = app.add_flag("--vt_trace", config_.vt_trace, trace); + auto n = app.add_flag("--vt_trace", appConfig.vt_trace, trace); auto nm = app.add_option("--vt_trace_mpi", arg_trace_mpi, trace_mpi) ->check(CLI::IsMember({"internal", "external"})); - auto o = app.add_option("--vt_trace_file", config_.vt_trace_file, tfile, ""); - auto p = app.add_option("--vt_trace_dir", config_.vt_trace_dir, tdir, ""); - auto q = app.add_option("--vt_trace_mod", config_.vt_trace_mod, tmod, 1); - auto qf = app.add_option("--vt_trace_flush_size", config_.vt_trace_flush_size, tflushmod, 0); - auto qg = app.add_flag("--vt_trace_gzip_finish_flush", config_.vt_trace_gzip_finish_flush, zflush); - auto qt = app.add_flag("--vt_trace_sys_all", config_.vt_trace_sys_all, tsysall); - auto qw = app.add_flag("--vt_trace_sys_term", config_.vt_trace_sys_term, tsysTD); - auto qx = app.add_flag("--vt_trace_sys_location", config_.vt_trace_sys_location, tsysloc); - auto qy = app.add_flag("--vt_trace_sys_collection", config_.vt_trace_sys_collection, tsyscoll); - auto qz = app.add_flag("--vt_trace_sys_serial_msg", config_.vt_trace_sys_serial_msg, tsyssmsg); - auto qza = app.add_flag("--vt_trace_spec", config_.vt_trace_spec, tspec); - auto qzb = app.add_option("--vt_trace_spec_file", config_.vt_trace_spec_file, tspecfile, ""); - auto qzc = app.add_flag("--vt_trace_memory_usage", config_.vt_trace_memory_usage, tmemusage); - auto qzd = app.add_flag("--vt_trace_event_polling", config_.vt_trace_event_polling, tpolled); - auto qze = app.add_flag("--vt_trace_irecv_polling", config_.vt_trace_irecv_polling, tirecv); + auto o = app.add_option("--vt_trace_file", appConfig.vt_trace_file, tfile, ""); + auto p = app.add_option("--vt_trace_dir", appConfig.vt_trace_dir, tdir, ""); + auto q = app.add_option("--vt_trace_mod", appConfig.vt_trace_mod, tmod, 1); + auto qf = app.add_option("--vt_trace_flush_size", appConfig.vt_trace_flush_size, tflushmod, 0); + auto qg = app.add_flag("--vt_trace_gzip_finish_flush", appConfig.vt_trace_gzip_finish_flush, zflush); + auto qt = app.add_flag("--vt_trace_sys_all", appConfig.vt_trace_sys_all, tsysall); + auto qw = app.add_flag("--vt_trace_sys_term", appConfig.vt_trace_sys_term, tsysTD); + auto qx = app.add_flag("--vt_trace_sys_location", appConfig.vt_trace_sys_location, tsysloc); + auto qy = app.add_flag("--vt_trace_sys_collection", appConfig.vt_trace_sys_collection, tsyscoll); + auto qz = app.add_flag("--vt_trace_sys_serial_msg", appConfig.vt_trace_sys_serial_msg, tsyssmsg); + auto qza = app.add_flag("--vt_trace_spec", appConfig.vt_trace_spec, tspec); + auto qzb = app.add_option("--vt_trace_spec_file", appConfig.vt_trace_spec_file, tspecfile, ""); + auto qzc = app.add_flag("--vt_trace_memory_usage", appConfig.vt_trace_memory_usage, tmemusage); + auto qzd = app.add_flag("--vt_trace_event_polling", appConfig.vt_trace_event_polling, tpolled); + auto qze = app.add_flag("--vt_trace_irecv_polling", appConfig.vt_trace_irecv_polling, tirecv); auto traceGroup = "Tracing Configuration"; n->group(traceGroup); nm->group(traceGroup); @@ -217,8 +336,8 @@ void ArgConfig::addTraceArgs(CLI::App& app) { qze->group(traceGroup); } -void ArgConfig::addDebugPrintArgs(CLI::App& app) { - #define debug_pp(opt) +std::string(vt::config::PrettyPrintCat::str)+ +void addDebugPrintArgs(CLI::App& app, AppConfig& appConfig) { + #define debug_pp(opt) +std::string(config::PrettyPrintCat::str)+ auto rp = "Enable all debug prints"; auto rq = "Set level for debug prints (0=>terse, 1=>normal, 2=>verbose)"; @@ -257,43 +376,43 @@ void ArgConfig::addDebugPrintArgs(CLI::App& app) { auto ddp = "Enable debug_context = \"" debug_pp(context) "\""; auto dep = "Enable debug_epoch = \"" debug_pp(epoch) "\""; - auto r1 = app.add_option("--vt_debug_level", config_.vt_debug_level, rq); - - auto r = app.add_flag("--vt_debug_all", config_.vt_debug_all, rp); - auto aa = app.add_flag("--vt_debug_none", config_.vt_debug_none, aap); - auto ba = app.add_flag("--vt_debug_gen", config_.vt_debug_gen, bap); - auto ca = app.add_flag("--vt_debug_runtime", config_.vt_debug_runtime, cap); - auto da = app.add_flag("--vt_debug_active", config_.vt_debug_active, dap); - auto ea = app.add_flag("--vt_debug_term", config_.vt_debug_term, eap); - auto fa = app.add_flag("--vt_debug_termds", config_.vt_debug_termds, fap); - auto ga = app.add_flag("--vt_debug_barrier", config_.vt_debug_barrier, gap); - auto ha = app.add_flag("--vt_debug_event", config_.vt_debug_event, hap); - auto ia = app.add_flag("--vt_debug_pipe", config_.vt_debug_pipe, iap); - auto ja = app.add_flag("--vt_debug_pool", config_.vt_debug_pool, jap); - auto ka = app.add_flag("--vt_debug_reduce", config_.vt_debug_reduce, kap); - auto la = app.add_flag("--vt_debug_rdma", config_.vt_debug_rdma, lap); - auto ma = app.add_flag("--vt_debug_rdma_channel", config_.vt_debug_rdma_channel, map); - auto na = app.add_flag("--vt_debug_rdma_state", config_.vt_debug_rdma_state, nap); - auto oa = app.add_flag("--vt_debug_param", config_.vt_debug_param, oap); - auto pa = app.add_flag("--vt_debug_handler", config_.vt_debug_handler, pap); - auto qa = app.add_flag("--vt_debug_hierlb", config_.vt_debug_hierlb, qap); - auto qb = app.add_flag("--vt_debug_temperedlb", config_.vt_debug_temperedlb, qbp); - auto ra = app.add_flag("--vt_debug_scatter", config_.vt_debug_scatter, rap); - auto sa = app.add_flag("--vt_debug_sequence", config_.vt_debug_sequence, sap); - auto ta = app.add_flag("--vt_debug_sequence_vrt", config_.vt_debug_sequence_vrt, tap); - auto ua = app.add_flag("--vt_debug_serial_msg", config_.vt_debug_serial_msg, uap); - auto va = app.add_flag("--vt_debug_trace", config_.vt_debug_trace, vap); - auto wa = app.add_flag("--vt_debug_location", config_.vt_debug_location, wap); - auto xa = app.add_flag("--vt_debug_lb", config_.vt_debug_lb, xap); - auto ya = app.add_flag("--vt_debug_vrt", config_.vt_debug_vrt, yap); - auto za = app.add_flag("--vt_debug_vrt_coll", config_.vt_debug_vrt_coll, zap); - auto ab = app.add_flag("--vt_debug_worker", config_.vt_debug_worker, abp); - auto bb = app.add_flag("--vt_debug_group", config_.vt_debug_group, bbp); - auto cb = app.add_flag("--vt_debug_broadcast", config_.vt_debug_broadcast, cbp); - auto db = app.add_flag("--vt_debug_objgroup", config_.vt_debug_objgroup, dbp); - auto dc = app.add_flag("--vt_debug_phase", config_.vt_debug_phase, dcp); - auto dd = app.add_flag("--vt_debug_context", config_.vt_debug_context, ddp); - auto de = app.add_flag("--vt_debug_epoch", config_.vt_debug_epoch, dep); + auto r1 = app.add_option("--vt_debug_level", appConfig.vt_debug_level, rq); + + auto r = app.add_flag("--vt_debug_all", appConfig.vt_debug_all, rp); + auto aa = app.add_flag("--vt_debug_none", appConfig.vt_debug_none, aap); + auto ba = app.add_flag("--vt_debug_gen", appConfig.vt_debug_gen, bap); + auto ca = app.add_flag("--vt_debug_runtime", appConfig.vt_debug_runtime, cap); + auto da = app.add_flag("--vt_debug_active", appConfig.vt_debug_active, dap); + auto ea = app.add_flag("--vt_debug_term", appConfig.vt_debug_term, eap); + auto fa = app.add_flag("--vt_debug_termds", appConfig.vt_debug_termds, fap); + auto ga = app.add_flag("--vt_debug_barrier", appConfig.vt_debug_barrier, gap); + auto ha = app.add_flag("--vt_debug_event", appConfig.vt_debug_event, hap); + auto ia = app.add_flag("--vt_debug_pipe", appConfig.vt_debug_pipe, iap); + auto ja = app.add_flag("--vt_debug_pool", appConfig.vt_debug_pool, jap); + auto ka = app.add_flag("--vt_debug_reduce", appConfig.vt_debug_reduce, kap); + auto la = app.add_flag("--vt_debug_rdma", appConfig.vt_debug_rdma, lap); + auto ma = app.add_flag("--vt_debug_rdma_channel", appConfig.vt_debug_rdma_channel, map); + auto na = app.add_flag("--vt_debug_rdma_state", appConfig.vt_debug_rdma_state, nap); + auto oa = app.add_flag("--vt_debug_param", appConfig.vt_debug_param, oap); + auto pa = app.add_flag("--vt_debug_handler", appConfig.vt_debug_handler, pap); + auto qa = app.add_flag("--vt_debug_hierlb", appConfig.vt_debug_hierlb, qap); + auto qb = app.add_flag("--vt_debug_temperedlb", appConfig.vt_debug_temperedlb, qbp); + auto ra = app.add_flag("--vt_debug_scatter", appConfig.vt_debug_scatter, rap); + auto sa = app.add_flag("--vt_debug_sequence", appConfig.vt_debug_sequence, sap); + auto ta = app.add_flag("--vt_debug_sequence_vrt", appConfig.vt_debug_sequence_vrt, tap); + auto ua = app.add_flag("--vt_debug_serial_msg", appConfig.vt_debug_serial_msg, uap); + auto va = app.add_flag("--vt_debug_trace", appConfig.vt_debug_trace, vap); + auto wa = app.add_flag("--vt_debug_location", appConfig.vt_debug_location, wap); + auto xa = app.add_flag("--vt_debug_lb", appConfig.vt_debug_lb, xap); + auto ya = app.add_flag("--vt_debug_vrt", appConfig.vt_debug_vrt, yap); + auto za = app.add_flag("--vt_debug_vrt_coll", appConfig.vt_debug_vrt_coll, zap); + auto ab = app.add_flag("--vt_debug_worker", appConfig.vt_debug_worker, abp); + auto bb = app.add_flag("--vt_debug_group", appConfig.vt_debug_group, bbp); + auto cb = app.add_flag("--vt_debug_broadcast", appConfig.vt_debug_broadcast, cbp); + auto db = app.add_flag("--vt_debug_objgroup", appConfig.vt_debug_objgroup, dbp); + auto dc = app.add_flag("--vt_debug_phase", appConfig.vt_debug_phase, dcp); + auto dd = app.add_flag("--vt_debug_context", appConfig.vt_debug_context, ddp); + auto de = app.add_flag("--vt_debug_epoch", appConfig.vt_debug_epoch, dep); auto debugGroup = "Debug Print Configuration (must be compile-time enabled)"; r->group(debugGroup); @@ -334,11 +453,11 @@ void ArgConfig::addDebugPrintArgs(CLI::App& app) { de->group(debugGroup); auto dbq = "Always flush VT runtime prints"; - auto eb = app.add_flag("--vt_debug_print_flush", config_.vt_debug_print_flush, dbq); + auto eb = app.add_flag("--vt_debug_print_flush", appConfig.vt_debug_print_flush, dbq); eb->group(debugGroup); } -void ArgConfig::addLbArgs(CLI::App& app) { +void addLbArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for enabling load balancing and configuring it */ @@ -362,21 +481,21 @@ void ArgConfig::addLbArgs(CLI::App& app) { auto lbd = "vt_lb_stats"; auto lbs = "stats"; auto lba = ""; - auto s = app.add_flag("--vt_lb", config_.vt_lb, lb); - auto t1 = app.add_flag("--vt_lb_quiet", config_.vt_lb_quiet, lb_quiet); - auto u = app.add_option("--vt_lb_file_name", config_.vt_lb_file_name, lb_file_name, lbf) + auto s = app.add_flag("--vt_lb", appConfig.vt_lb, lb); + auto t1 = app.add_flag("--vt_lb_quiet", appConfig.vt_lb_quiet, lb_quiet); + auto u = app.add_option("--vt_lb_file_name", appConfig.vt_lb_file_name, lb_file_name, lbf) ->check(CLI::ExistingFile); - auto u1 = app.add_flag("--vt_lb_show_spec", config_.vt_lb_show_spec, lb_show_spec); - auto v = app.add_option("--vt_lb_name", config_.vt_lb_name, lb_name, lbn); - auto v1 = app.add_option("--vt_lb_args", config_.vt_lb_args, lb_args, lba); - auto w = app.add_option("--vt_lb_interval", config_.vt_lb_interval, lb_interval, lbi); - auto wl = app.add_flag("--vt_lb_keep_last_elm", config_.vt_lb_keep_last_elm, lb_keep_last_elm); - auto ww = app.add_flag("--vt_lb_stats", config_.vt_lb_stats, lb_stats); - auto xz = app.add_flag("--vt_lb_stats_compress", config_.vt_lb_stats_compress, lb_stats_comp); - auto wx = app.add_option("--vt_lb_stats_dir", config_.vt_lb_stats_dir, lb_stats_dir, lbd); - auto wy = app.add_option("--vt_lb_stats_file", config_.vt_lb_stats_file, lb_stats_file,lbs); - auto xx = app.add_option("--vt_lb_stats_dir_in", config_.vt_lb_stats_dir_in, lb_stats_dir_in, lbd); - auto xy = app.add_option("--vt_lb_stats_file_in", config_.vt_lb_stats_file_in, lb_stats_file_in,lbs); + auto u1 = app.add_flag("--vt_lb_show_spec", appConfig.vt_lb_show_spec, lb_show_spec); + auto v = app.add_option("--vt_lb_name", appConfig.vt_lb_name, lb_name, lbn); + auto v1 = app.add_option("--vt_lb_args", appConfig.vt_lb_args, lb_args, lba); + auto w = app.add_option("--vt_lb_interval", appConfig.vt_lb_interval, lb_interval, lbi); + auto wl = app.add_flag("--vt_lb_keep_last_elm", appConfig.vt_lb_keep_last_elm, lb_keep_last_elm); + auto ww = app.add_flag("--vt_lb_stats", appConfig.vt_lb_stats, lb_stats); + auto xz = app.add_flag("--vt_lb_stats_compress", appConfig.vt_lb_stats_compress, lb_stats_comp); + auto wx = app.add_option("--vt_lb_stats_dir", appConfig.vt_lb_stats_dir, lb_stats_dir, lbd); + auto wy = app.add_option("--vt_lb_stats_file", appConfig.vt_lb_stats_file, lb_stats_file,lbs); + auto xx = app.add_option("--vt_lb_stats_dir_in", appConfig.vt_lb_stats_dir_in, lb_stats_dir_in, lbd); + auto xy = app.add_option("--vt_lb_stats_file_in", appConfig.vt_lb_stats_file_in, lb_stats_file_in,lbs); auto debugLB = "Load Balancing"; s->group(debugLB); @@ -397,11 +516,11 @@ void ArgConfig::addLbArgs(CLI::App& app) { // help options deliberately omitted from the debugLB group above so that // they appear grouped with --vt_help when --vt_help is used auto help_lb_args = "Print help for --vt_lb_args"; - auto h1 = app.add_flag("--vt_help_lb_args", config_.vt_help_lb_args, help_lb_args); + auto h1 = app.add_flag("--vt_help_lb_args", appConfig.vt_help_lb_args, help_lb_args); (void) h1; } -void ArgConfig::addDiagnosticArgs(CLI::App& app) { +void addDiagnosticArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for controlling diagnostic collection and output */ @@ -410,11 +529,11 @@ void ArgConfig::addDiagnosticArgs(CLI::App& app) { auto file = "Output diagnostic summary table to text file"; auto csv = "Output diagnostic summary table to a comma-separated file"; auto base = "Use base units (seconds, units, etc.) for CSV file output"; - auto a = app.add_flag("--vt_diag_enable,!--vt_diag_disable", config_.vt_diag_enable, diag); - auto b = app.add_flag("--vt_diag_print_summary", config_.vt_diag_print_summary, sum); - auto c = app.add_option("--vt_diag_summary_file", config_.vt_diag_summary_file, file); - auto d = app.add_option("--vt_diag_summary_csv_file", config_.vt_diag_summary_csv_file, csv); - auto e = app.add_flag("--vt_diag_csv_base_units", config_.vt_diag_csv_base_units, base); + auto a = app.add_flag("--vt_diag_enable,!--vt_diag_disable", appConfig.vt_diag_enable, diag); + auto b = app.add_flag("--vt_diag_print_summary", appConfig.vt_diag_print_summary, sum); + auto c = app.add_option("--vt_diag_summary_file", appConfig.vt_diag_summary_file, file); + auto d = app.add_option("--vt_diag_summary_csv_file", appConfig.vt_diag_summary_csv_file, csv); + auto e = app.add_flag("--vt_diag_csv_base_units", appConfig.vt_diag_csv_base_units, base); auto diagnosticGroup = "Diagnostics"; a->group(diagnosticGroup); @@ -424,7 +543,7 @@ void ArgConfig::addDiagnosticArgs(CLI::App& app) { e->group(diagnosticGroup); } -void ArgConfig::addTerminationArgs(CLI::App& app) { +void addTerminationArgs(CLI::App& app, AppConfig& appConfig) { auto hang = "Disable termination hang detection"; auto hang_freq = "The number of tree traversals before a hang is detected"; auto ds = "Force use of Dijkstra-Scholten (DS) algorithm for rooted epoch termination detection"; @@ -433,13 +552,13 @@ void ArgConfig::addTerminationArgs(CLI::App& app) { auto terse = "Output epoch graph to file in terse mode"; auto progress = "Print termination counts when progress is stalled"; auto hfd = 1024; - auto x = app.add_flag("--vt_no_detect_hang", config_.vt_no_detect_hang, hang); - auto x1 = app.add_flag("--vt_term_rooted_use_ds", config_.vt_term_rooted_use_ds, ds); - auto x2 = app.add_flag("--vt_term_rooted_use_wave", config_.vt_term_rooted_use_wave, wave); - auto x3 = app.add_option("--vt_epoch_graph_on_hang", config_.vt_epoch_graph_on_hang, graph_on, true); - auto x4 = app.add_flag("--vt_epoch_graph_terse", config_.vt_epoch_graph_terse, terse); - auto x5 = app.add_option("--vt_print_no_progress", config_.vt_print_no_progress, progress, true); - auto y = app.add_option("--vt_hang_freq", config_.vt_hang_freq, hang_freq, hfd); + auto x = app.add_flag("--vt_no_detect_hang", appConfig.vt_no_detect_hang, hang); + auto x1 = app.add_flag("--vt_term_rooted_use_ds", appConfig.vt_term_rooted_use_ds, ds); + auto x2 = app.add_flag("--vt_term_rooted_use_wave", appConfig.vt_term_rooted_use_wave, wave); + auto x3 = app.add_option("--vt_epoch_graph_on_hang", appConfig.vt_epoch_graph_on_hang, graph_on, true); + auto x4 = app.add_flag("--vt_epoch_graph_terse", appConfig.vt_epoch_graph_terse, terse); + auto x5 = app.add_option("--vt_print_no_progress", appConfig.vt_print_no_progress, progress, true); + auto y = app.add_option("--vt_hang_freq", appConfig.vt_hang_freq, hang_freq, hfd); auto debugTerm = "Termination"; x->group(debugTerm); x1->group(debugTerm); @@ -450,14 +569,14 @@ void ArgConfig::addTerminationArgs(CLI::App& app) { y->group(debugTerm); } -void ArgConfig::addDebuggerArgs(CLI::App& app) { +void addDebuggerArgs(CLI::App& app, AppConfig& appConfig) { auto pause = "Pause at startup so GDB/LLDB can be attached"; - auto z = app.add_flag("--vt_pause", config_.vt_pause, pause); + auto z = app.add_flag("--vt_pause", appConfig.vt_pause, pause); auto launchTerm = "Debugging/Launch"; z->group(launchTerm); } -void ArgConfig::addUserArgs(CLI::App& app) { +void addUserArgs(CLI::App& app, AppConfig& appConfig) { auto user1 = "User Option 1a (boolean)"; auto user2 = "User Option 2a (boolean)"; auto user3 = "User Option 3a (boolean)"; @@ -467,15 +586,15 @@ void ArgConfig::addUserArgs(CLI::App& app) { auto userstr1 = "User Option 1c (std::string)"; auto userstr2 = "User Option 2c (std::string)"; auto userstr3 = "User Option 3c (std::string)"; - auto u1 = app.add_flag("--vt_user_1", config_.vt_user_1, user1); - auto u2 = app.add_flag("--vt_user_2", config_.vt_user_2, user2); - auto u3 = app.add_flag("--vt_user_3", config_.vt_user_3, user3); - auto ui1 = app.add_option("--vt_user_int_1", config_.vt_user_int_1, userint1, 0); - auto ui2 = app.add_option("--vt_user_int_2", config_.vt_user_int_2, userint2, 0); - auto ui3 = app.add_option("--vt_user_int_3", config_.vt_user_int_3, userint3, 0); - auto us1 = app.add_option("--vt_user_str_1", config_.vt_user_str_1, userstr1, ""); - auto us2 = app.add_option("--vt_user_str_2", config_.vt_user_str_2, userstr2, ""); - auto us3 = app.add_option("--vt_user_str_3", config_.vt_user_str_3, userstr3, ""); + auto u1 = app.add_flag("--vt_user_1", appConfig.vt_user_1, user1); + auto u2 = app.add_flag("--vt_user_2", appConfig.vt_user_2, user2); + auto u3 = app.add_flag("--vt_user_3", appConfig.vt_user_3, user3); + auto ui1 = app.add_option("--vt_user_int_1", appConfig.vt_user_int_1, userint1, 0); + auto ui2 = app.add_option("--vt_user_int_2", appConfig.vt_user_int_2, userint2, 0); + auto ui3 = app.add_option("--vt_user_int_3", appConfig.vt_user_int_3, userint3, 0); + auto us1 = app.add_option("--vt_user_str_1", appConfig.vt_user_str_1, userstr1, ""); + auto us2 = app.add_option("--vt_user_str_2", appConfig.vt_user_str_2, userstr2, ""); + auto us3 = app.add_option("--vt_user_str_3", appConfig.vt_user_str_3, userstr3, ""); auto userOpts = "User Options"; u1->group(userOpts); u2->group(userOpts); @@ -488,32 +607,32 @@ void ArgConfig::addUserArgs(CLI::App& app) { us3->group(userOpts); } -void ArgConfig::addSchedulerArgs(CLI::App& app) { +void addSchedulerArgs(CLI::App& app, AppConfig& appConfig) { auto nsched = "Number of times to run the progress function in scheduler"; auto ksched = "Run the MPI progress function at least every k handlers that run"; auto ssched = "Run the MPI progress function at least every s seconds"; - auto sca = app.add_option("--vt_sched_num_progress", config_.vt_sched_num_progress, nsched, 2); - auto hca = app.add_option("--vt_sched_progress_han", config_.vt_sched_progress_han, ksched, 0); - auto kca = app.add_option("--vt_sched_progress_sec", config_.vt_sched_progress_sec, ssched, 0.0); + auto sca = app.add_option("--vt_sched_num_progress", appConfig.vt_sched_num_progress, nsched, 2); + auto hca = app.add_option("--vt_sched_progress_han", appConfig.vt_sched_progress_han, ksched, 0); + auto kca = app.add_option("--vt_sched_progress_sec", appConfig.vt_sched_progress_sec, ssched, 0.0); auto schedulerGroup = "Scheduler Configuration"; sca->group(schedulerGroup); hca->group(schedulerGroup); kca->group(schedulerGroup); } -void ArgConfig::addConfigFileArgs(CLI::App& app) { +void addConfigFileArgs(CLI::App& app, AppConfig& appConfig) { auto doconfig = "Output all VT args to configuration file"; auto configname = "Name of configuration file to output"; - auto a1 = app.add_flag("--vt_output_config", config_.vt_output_config, doconfig); - auto a2 = app.add_option("--vt_output_config_file", config_.vt_output_config_file, configname, true); + auto a1 = app.add_flag("--vt_output_config", appConfig.vt_output_config, doconfig); + auto a2 = app.add_option("--vt_output_config_file", appConfig.vt_output_config_file, configname, true); auto configGroup = "Configuration File"; a1->group(configGroup); a2->group(configGroup); } -void ArgConfig::addRuntimeArgs(CLI::App& app) { +void addRuntimeArgs(CLI::App& app, AppConfig& appConfig) { auto max_size = "Maximum MPI send size (causes larger messages to be split " "into multiple MPI sends)"; auto assert = "Do not abort the program when vtAssert(..) is invoked"; @@ -521,13 +640,13 @@ void ArgConfig::addRuntimeArgs(CLI::App& app) { auto a1 = app.add_option( - "--vt_max_mpi_send_size", config_.vt_max_mpi_send_size, max_size, true + "--vt_max_mpi_send_size", appConfig.vt_max_mpi_send_size, max_size, true ); auto a2 = app.add_flag( - "--vt_no_assert_fail", config_.vt_no_assert_fail, assert + "--vt_no_assert_fail", appConfig.vt_no_assert_fail, assert ); auto a3 = app.add_flag( - "--vt_throw_on_abort", config_.vt_throw_on_abort, throw_on_abort + "--vt_throw_on_abort", appConfig.vt_throw_on_abort, throw_on_abort ); @@ -537,16 +656,16 @@ void ArgConfig::addRuntimeArgs(CLI::App& app) { a3->group(configRuntime); } -void ArgConfig::addThreadingArgs(CLI::App& app) { +void addThreadingArgs(CLI::App& app, AppConfig& appConfig) { #if (vt_feature_fcontext != 0) auto ult_disable = "Disable running handlers in user-level threads"; auto stack_size = "The default stack size for user-level threads"; auto a1 = app.add_flag( - "--vt_ult_disable", config_.vt_ult_disable, ult_disable + "--vt_ult_disable", appConfig.vt_ult_disable, ult_disable ); auto a2 = app.add_option( - "--vt_ult_stack_size", config_.vt_ult_stack_size, stack_size, true + "--vt_ult_stack_size", appConfig.vt_ult_stack_size, stack_size, true ); auto configThreads = "Threads"; @@ -555,6 +674,13 @@ void ArgConfig::addThreadingArgs(CLI::App& app) { #endif } +} /* end anon namespace */ + +/*static*/ std::unique_ptr +ArgConfig::construct(std::unique_ptr arg) { + return arg; +} + class VtFormatter : public CLI::Formatter { public: std::string make_usage(const CLI::App *, std::string name) const override { @@ -582,7 +708,26 @@ class VtFormatter : public CLI::Formatter { } }; -std::tuple ArgConfig::parse(int& argc, char**& argv) { +std::tuple ArgConfig::parse( + int& argc, char**& argv, AppConfig const* appConfig +) { + // If user didn't define appConfig, parse into this->config_. + if (not appConfig) { + return parseToConfig(argc, argv, config_); + } + + // If user defines appConfig, parse into temporary config for later comparison. + AppConfig config{*appConfig}; + auto const parse_result = parseToConfig(argc, argv, config); + + config_ = config; + + return parse_result; +} + +std::tuple ArgConfig::parseToConfig( + int& argc, char**& argv, AppConfig& appConfig +) { if (parsed_ || argc == 0 || argv == nullptr) { // Odd case.. pretend nothing bad happened. return std::make_tuple(-1, std::string{}); @@ -594,35 +739,35 @@ std::tuple ArgConfig::parse(int& argc, char**& argv) { app.set_help_flag("--vt_help", "Display help"); - addColorArgs(app); - addSignalArgs(app); - addMemUsageArgs(app); - addStackDumpArgs(app); - addTraceArgs(app); - addDebugPrintArgs(app); - addLbArgs(app); - addDiagnosticArgs(app); - addTerminationArgs(app); - addDebuggerArgs(app); - addUserArgs(app); - addSchedulerArgs(app); - addConfigFileArgs(app); - addRuntimeArgs(app); - addThreadingArgs(app); - - std::tuple result = parseArguments(app, /*out*/ argc, /*out*/ argv); + addColorArgs(app, appConfig); + addSignalArgs(app, appConfig); + addMemUsageArgs(app, appConfig); + addStackDumpArgs(app, appConfig); + addTraceArgs(app, appConfig); + addDebugPrintArgs(app, appConfig); + addLbArgs(app, appConfig); + addDiagnosticArgs(app, appConfig); + addTerminationArgs(app, appConfig); + addDebuggerArgs(app, appConfig); + addUserArgs(app, appConfig); + addSchedulerArgs(app, appConfig); + addConfigFileArgs(app, appConfig); + addRuntimeArgs(app, appConfig); + addThreadingArgs(app, appConfig); + + std::tuple result = parseArguments(app, argc, argv, appConfig); if (std::get<0>(result) not_eq -1) { // non-success return result; } // Determine the final colorization setting. - if (config_.vt_no_color) { - config_.colorize_output = false; + if (appConfig.vt_no_color) { + appConfig.colorize_output = false; } else { // Otherwise, colorize. // (Within MPI there is no good method to auto-detect.) - config_.colorize_output = true; + appConfig.colorize_output = true; } parsed_ = true; @@ -630,129 +775,6 @@ std::tuple ArgConfig::parse(int& argc, char**& argv) { return result; } -/** - * \internal - * Application specific cleanup and mapping to actual app args. - */ -void ArgConfig::postParseTransform() { - auto contains = [](std::vector &v, std::string str){ - return std::find(v.begin(), v.end(), str) not_eq v.end(); - }; - - config_.vt_trace_mpi = contains(arg_trace_mpi, "internal"); - config_.vt_trace_pmpi = contains(arg_trace_mpi, "external"); - - using config::ModeEnum; - - auto const& level = config_.vt_debug_level; - if (level == "terse" or level == "0") { - config_.vt_debug_level_val = ModeEnum::terse; - } else if (level == "normal" or level == "1") { - config_.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; - } else if (level == "verbose" or level == "2") { - config_.vt_debug_level_val = - ModeEnum::terse | ModeEnum::normal | ModeEnum::verbose; - } else { - vtAbort("Invalid value passed to --vt_debug_level"); - } -} - -std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, char**& argv) { - - std::vector vt_args; - - // Load up vectors (has curious ability to altnerate vt/mpi/passthru) - std::vector* rargs = nullptr; - for (int i = 1; i < argc; i++) { - char* c = argv[i]; - if (0 == strcmp(c, "--vt_args")) { - rargs = &vt_args; - } else if (0 == strcmp(c, "--")) { - rargs = &config_.passthru_args; - } else if (rargs) { - rargs->push_back(c); - } else if (0 == strncmp(c, "--vt_", 5)) { - // Implicit start of VT args allows pass-thru 'for compatibility' - // although the recommended calling pattern to always provide VT args first. - rargs = &vt_args; - rargs->push_back(c); - } else { - config_.passthru_args.push_back(c); - } - } - - // All must be accounted for - app.allow_extras(false); - - // Build string-vector and reverse order to parse (CLI quirk) - std::vector args_to_parse; - for (auto it = vt_args.crbegin(); it != vt_args.crend(); ++it) { - args_to_parse.push_back(*it); - } - - // Allow a input config file - app.set_config( - "--vt_input_config", - "", // no default file name - "Read in an ini config file for VT", - false // not required - ); - - try { - app.parse(args_to_parse); - } catch (CLI::Error &ex) { - // Return exit code and message, delaying logic processing of such. - // The default exit code for 'help' is 0. - std::stringstream message_stream; - int result = app.exit(ex, message_stream, message_stream); - - return std::make_tuple(result, message_stream.str()); - } - - // If the user specified to output the full configuration, save it in a string - // so node 0 can output in the runtime once MPI is init'ed - if (config_.vt_output_config) { - config_.vt_output_config_str = app.config_to_str(true, true); - } - - // Get the clean prog name; don't allow path bleed in usages. - // std::filesystem is C++17. - std::string clean_prog_name = argv[0]; - size_t l = clean_prog_name.find_last_of("/\\"); - if (l not_eq std::string::npos and l + 1 < clean_prog_name.size()) { - clean_prog_name = clean_prog_name.substr(l + 1, std::string::npos); - } - - config_.prog_name = clean_prog_name; - config_.argv_prog_name = argv[0]; - - postParseTransform(); - - // Rebuild passthru into ref-returned argc/argv - - // It should be possible to modify the original argv as the outgoing - // number of arguments is always less. As currently allocated here, - // ownership of the new object is ill-defined. - int new_argc = config_.passthru_args.size() + 1; // does not include argv[0] - - static std::unique_ptr new_argv = nullptr; - - new_argv = std::make_unique(new_argc + 1); - - int i = 0; - new_argv[i++] = config_.argv_prog_name; - for (auto&& arg : config_.passthru_args) { - new_argv[i++] = arg; - } - new_argv[i++] = nullptr; - - // Set them back with all vt (and MPI) arguments elided - argc = new_argc; - argv = new_argv.get(); - - return std::make_tuple(-1, std::string{}); -} - namespace { static std::string buildFile(std::string const& file, std::string const& dir) { std::string name = file; diff --git a/src/vt/configs/arguments/args.h b/src/vt/configs/arguments/args.h index 0efe341fa7..c2da8ae1da 100644 --- a/src/vt/configs/arguments/args.h +++ b/src/vt/configs/arguments/args.h @@ -73,8 +73,9 @@ struct ArgConfig : runtime::component::Component { /// On success the tuple will be {-1, ""}. Otherwise the exit code /// (which may be 0 if help was requested) will be returned along /// with an appropriate display message. - std::tuple parse(int& argc, char**& argv); - std::tuple parseArguments(CLI::App& app, int& argc, char**& argv); + std::tuple parse( + int& argc, char**& argv, AppConfig const* appConfig + ); static std::unique_ptr construct(std::unique_ptr arg); @@ -89,23 +90,9 @@ struct ArgConfig : runtime::component::Component { AppConfig config_; private: - void addColorArgs(CLI::App& app); - void addSignalArgs(CLI::App& app); - void addMemUsageArgs(CLI::App& app); - void addStackDumpArgs(CLI::App& app); - void addTraceArgs(CLI::App& app); - void addDebugPrintArgs(CLI::App& app); - void addLbArgs(CLI::App& app); - void addDiagnosticArgs(CLI::App& app); - void addTerminationArgs(CLI::App& app); - void addDebuggerArgs(CLI::App& app); - void addUserArgs(CLI::App& app); - void addSchedulerArgs(CLI::App& app); - void addConfigFileArgs(CLI::App& app); - void addRuntimeArgs(CLI::App& app); - void addThreadingArgs(CLI::App& app); - - void postParseTransform(); + std::tuple parseToConfig( + int& argc, char**& argv, AppConfig& appConfig + ); bool parsed_ = false; }; diff --git a/src/vt/configs/debug/debug_config.h b/src/vt/configs/debug/debug_config.h index 0109ef2aaf..c034e5beb4 100644 --- a/src/vt/configs/debug/debug_config.h +++ b/src/vt/configs/debug/debug_config.h @@ -206,7 +206,6 @@ struct Configuration { #include "vt/configs/features/features_featureswitch.h" #include "vt/configs/features/features_defines.h" -#include "vt/configs/features/features_enableif.h" #include "vt/configs/debug/debug_printconst.h" #endif /*INCLUDED_VT_CONFIGS_DEBUG_DEBUG_CONFIG_H*/ diff --git a/src/vt/configs/debug/debug_masterconfig.h b/src/vt/configs/debug/debug_masterconfig.h index d4b2044567..716c0264a4 100644 --- a/src/vt/configs/debug/debug_masterconfig.h +++ b/src/vt/configs/debug/debug_masterconfig.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H -#include - /* * Define the compile-time configuration options. Eventually this will be * partially defined with cmake options diff --git a/src/vt/configs/debug/debug_print.cc b/src/vt/configs/debug/debug_print.cc new file mode 100644 index 0000000000..0e2df5f60d --- /dev/null +++ b/src/vt/configs/debug/debug_print.cc @@ -0,0 +1,108 @@ +/* +//@HEADER +// ***************************************************************************** +// +// debug_print.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 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 "vt/configs/debug/debug_masterconfig.h" +#include "vt/configs/debug/debug_print.h" +#include "vt/configs/error/hard_error.h" + +#define vt_scoped_modifier_opt_definition(opt, val) \ + ScopedModifier_##opt##_##val::ScopedModifier_##opt##_##val() \ + : orig_val{::vt::theConfig()->vt_debug_##opt} { \ + ::vt::theConfig()->vt_debug_##opt = val; \ + } \ + \ + ScopedModifier_##opt##_##val::~ScopedModifier_##opt##_##val() { \ + ::vt::theConfig()->vt_debug_##opt = orig_val; \ + } \ + \ + ScopedModifier_##opt##_##val createScopedModifier_##opt##_##val() { \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ + return ScopedModifier_##opt##_##val{}; \ + } + +#define vt_define_debug_scoped_modifiers(opt) \ + vt_scoped_modifier_opt_definition(opt, true) \ + vt_scoped_modifier_opt_definition(opt, false) + +namespace vt { + +vt_define_debug_scoped_modifiers(all) +vt_define_debug_scoped_modifiers(none) +vt_define_debug_scoped_modifiers(gen) +vt_define_debug_scoped_modifiers(runtime) +vt_define_debug_scoped_modifiers(active) +vt_define_debug_scoped_modifiers(term) +vt_define_debug_scoped_modifiers(termds) +vt_define_debug_scoped_modifiers(barrier) +vt_define_debug_scoped_modifiers(event) +vt_define_debug_scoped_modifiers(pipe) +vt_define_debug_scoped_modifiers(pool) +vt_define_debug_scoped_modifiers(reduce) +vt_define_debug_scoped_modifiers(rdma) +vt_define_debug_scoped_modifiers(rdma_channel) +vt_define_debug_scoped_modifiers(rdma_state) +vt_define_debug_scoped_modifiers(param) +vt_define_debug_scoped_modifiers(handler) +vt_define_debug_scoped_modifiers(hierlb) +vt_define_debug_scoped_modifiers(temperedlb) +vt_define_debug_scoped_modifiers(scatter) +vt_define_debug_scoped_modifiers(sequence) +vt_define_debug_scoped_modifiers(sequence_vrt) +vt_define_debug_scoped_modifiers(serial_msg) +vt_define_debug_scoped_modifiers(trace) +vt_define_debug_scoped_modifiers(location) +vt_define_debug_scoped_modifiers(lb) +vt_define_debug_scoped_modifiers(vrt) +vt_define_debug_scoped_modifiers(vrt_coll) +vt_define_debug_scoped_modifiers(worker) +vt_define_debug_scoped_modifiers(group) +vt_define_debug_scoped_modifiers(broadcast) +vt_define_debug_scoped_modifiers(objgroup) +vt_define_debug_scoped_modifiers(phase) +vt_define_debug_scoped_modifiers(context) +vt_define_debug_scoped_modifiers(epoch) + +} diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index f252dd9d8a..aac28b217f 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_PRINT_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_PRINT_H -#include "vt/configs/arguments/app_config.h" #include "vt/configs/types/types_headers.h" #include "vt/configs/debug/debug_config.h" #include "vt/configs/debug/debug_colorize.h" @@ -159,6 +158,111 @@ #define vt_option_check_enabled(mode, bit) ((mode & bit) not_eq 0) +/** + * \brief Temporarily enable debug print option. + * vt needs to be initialized before usage. + */ +#define vt_debug_temp_enable_opt(opt) \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ + ::vt::theConfig()->vt_debug_##opt = true + +/** + * \brief Temporarily disable debug print option. + * vt needs to be initialized before usage. + */ +#define vt_debug_temp_disable_opt(opt) \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ + ::vt::theConfig()->vt_debug_##opt = false + +/** + * \brief Temporarily enable debug print option in given scope. When exiting + * a scope, it restores original option value. + * vt needs to be initialized before usage. + * + * Usage: + * { + * ... + * auto const scopedEnabledContext = vt_debug_scoped_enable_opt(context); + * ... + * } + */ +#define vt_debug_scoped_enable_opt(opt) createScopedModifier_##opt##_true() + +/** + * \brief Temporarily disable debug print option in given scope. When exiting + * a scope, it restores original option value. + * vt needs to be initialized before usage. + * + * Usage: + * { + * ... + * auto const scopedDisabledContext = vt_debug_scoped_disable_opt(context); + * ... + * } + */ +#define vt_debug_scoped_disable_opt(opt) createScopedModifier_##opt##_##false() + +#define vt_scoped_modifier_opt_declaration(opt, val) \ + struct ScopedModifier_##opt##_##val { \ + ScopedModifier_##opt##_##val(); \ + ~ScopedModifier_##opt##_##val(); \ + \ + private: \ + bool orig_val; \ + }; \ + \ + ScopedModifier_##opt##_##val createScopedModifier_##opt##_##val() + +#define vt_declare_debug_scoped_modifiers(opt) \ + vt_scoped_modifier_opt_declaration(opt, true); \ + vt_scoped_modifier_opt_declaration(opt, false) + +namespace vt { + +vt_declare_debug_scoped_modifiers(all); +vt_declare_debug_scoped_modifiers(none); +vt_declare_debug_scoped_modifiers(gen); +vt_declare_debug_scoped_modifiers(runtime); +vt_declare_debug_scoped_modifiers(active); +vt_declare_debug_scoped_modifiers(term); +vt_declare_debug_scoped_modifiers(termds); +vt_declare_debug_scoped_modifiers(barrier); +vt_declare_debug_scoped_modifiers(event); +vt_declare_debug_scoped_modifiers(pipe); +vt_declare_debug_scoped_modifiers(pool); +vt_declare_debug_scoped_modifiers(reduce); +vt_declare_debug_scoped_modifiers(rdma); +vt_declare_debug_scoped_modifiers(rdma_channel); +vt_declare_debug_scoped_modifiers(rdma_state); +vt_declare_debug_scoped_modifiers(param); +vt_declare_debug_scoped_modifiers(handler); +vt_declare_debug_scoped_modifiers(hierlb); +vt_declare_debug_scoped_modifiers(temperedlb); +vt_declare_debug_scoped_modifiers(scatter); +vt_declare_debug_scoped_modifiers(sequence); +vt_declare_debug_scoped_modifiers(sequence_vrt); +vt_declare_debug_scoped_modifiers(serial_msg); +vt_declare_debug_scoped_modifiers(trace); +vt_declare_debug_scoped_modifiers(location); +vt_declare_debug_scoped_modifiers(lb); +vt_declare_debug_scoped_modifiers(vrt); +vt_declare_debug_scoped_modifiers(vrt_coll); +vt_declare_debug_scoped_modifiers(worker); +vt_declare_debug_scoped_modifiers(group); +vt_declare_debug_scoped_modifiers(broadcast); +vt_declare_debug_scoped_modifiers(objgroup); +vt_declare_debug_scoped_modifiers(phase); +vt_declare_debug_scoped_modifiers(context); +vt_declare_debug_scoped_modifiers(epoch); + +} // namespace vt + namespace vt { namespace runtime { struct Runtime; }} /* end namespace vt::runtime */ @@ -168,7 +272,6 @@ extern runtime::Runtime* curRT; } /* end namespace vt */ namespace vt { namespace debug { -arguments::AppConfig const* preConfig(); NodeType preNode(); }} /* end namespace vt::debug */ diff --git a/src/vt/configs/debug/debug_var_unused.h b/src/vt/configs/debug/debug_var_unused.h index 481ebc70c3..c461fc6203 100644 --- a/src/vt/configs/debug/debug_var_unused.h +++ b/src/vt/configs/debug/debug_var_unused.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_VAR_UNUSED_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_VAR_UNUSED_H +#include + #define vt_force_use(...) vt::debug::useVars(__VA_ARGS__); namespace vt { namespace debug { diff --git a/src/vt/configs/error/code.h b/src/vt/configs/error/code.h index 73b33012b4..1f77cd4384 100644 --- a/src/vt/configs/error/code.h +++ b/src/vt/configs/error/code.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_CODE_H #define INCLUDED_VT_CONFIGS_ERROR_CODE_H -#include "vt/configs/error/code_class.h" - #include namespace vt { namespace error { diff --git a/src/vt/configs/error/common.h b/src/vt/configs/error/common.h index 068d262b0b..7a215d25f1 100644 --- a/src/vt/configs/error/common.h +++ b/src/vt/configs/error/common.h @@ -44,8 +44,7 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_COMMON_H #define INCLUDED_VT_CONFIGS_ERROR_COMMON_H -#include "vt/configs/types/types_headers.h" -#include "vt/collective/basic.h" +#include "vt/configs/types/types_type.h" #define INVERT_COND(cond) (!(cond)) #define DEBUG_LOCATION __FILE__,__LINE__,__func__ diff --git a/src/vt/configs/error/config_assert.h b/src/vt/configs/error/config_assert.h index 427b880bef..8b41608954 100644 --- a/src/vt/configs/error/config_assert.h +++ b/src/vt/configs/error/config_assert.h @@ -49,12 +49,8 @@ * build/runtime mode when the assertion breaks */ -#include "vt/configs/debug/debug_config.h" -#include "vt/configs/types/types_type.h" -#include "vt/configs/error/common.h" #include "vt/configs/error/assert_out.h" #include "vt/configs/error/assert_out_info.h" -#include "vt/configs/error/keyval_printer.h" #include #include diff --git a/src/vt/configs/error/error.h b/src/vt/configs/error/error.h index 438601b137..83ffc42b96 100644 --- a/src/vt/configs/error/error.h +++ b/src/vt/configs/error/error.h @@ -45,8 +45,6 @@ #define INCLUDED_VT_CONFIGS_ERROR_ERROR_H #include "vt/configs/types/types_headers.h" -#include "vt/configs/debug/debug_config.h" -#include "vt/configs/error/common.h" #include #include diff --git a/src/vt/configs/error/error.impl.h b/src/vt/configs/error/error.impl.h index 7f3317cf57..a92c09f82a 100644 --- a/src/vt/configs/error/error.impl.h +++ b/src/vt/configs/error/error.impl.h @@ -49,6 +49,7 @@ #include "vt/configs/error/common.h" #include "vt/configs/error/error.h" #include "vt/configs/error/pretty_print_message.h" +#include "vt/collective/basic.h" #include #include diff --git a/src/vt/configs/error/keyval_printer.h b/src/vt/configs/error/keyval_printer.h index 7008152875..db714b0544 100644 --- a/src/vt/configs/error/keyval_printer.h +++ b/src/vt/configs/error/keyval_printer.h @@ -44,9 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_KEYVAL_PRINTER_H #define INCLUDED_VT_CONFIGS_ERROR_KEYVAL_PRINTER_H -#include "vt/configs/error/common.h" -#include "vt/configs/debug/debug_config.h" - #include #include #include diff --git a/src/vt/configs/error/pretty_print_stack.h b/src/vt/configs/error/pretty_print_stack.h deleted file mode 100644 index 3d89e26307..0000000000 --- a/src/vt/configs/error/pretty_print_stack.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// pretty_print_stack.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 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 -*/ - -#if !defined INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H -#define INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H - -#include "vt/config.h" -#include "vt/configs/error/stack_out.h" -#include "vt/configs/debug/debug_colorize.h" - -#include - -namespace vt { namespace debug { namespace stack { - -inline std::string prettyPrintStack(StackVectorType const& stack) { - auto green = ::vt::debug::green(); - auto red = ::vt::debug::red(); - auto bred = ::vt::debug::bred(); - auto reset = ::vt::debug::reset(); - auto bd_green = ::vt::debug::bd_green(); - auto magenta = ::vt::debug::magenta(); - auto blue = ::vt::debug::blue(); - auto yellow = ::vt::debug::yellow(); - auto vt_pre = ::vt::debug::vtPre(); - auto node = ::vt::theContext()->getNode(); - auto node_str = ::vt::debug::proc(node); - auto prefix = vt_pre + node_str + " "; - auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); - auto title_node = fmt::format("on Node {}", node); - auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); - - std::string out = ""; - - out += fmt::format("{}", seperator); - out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); - out += fmt::format("{}", seperator); - - int i = 0; - for (auto&& t : stack) { - auto ret_str = fmt::format( - "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", - prefix, - bred, i, reset, - magenta, std::get<0>(t), std::get<1>(t), reset, - green, std::get<2>(t), reset, - std::get<3>(t), reset - ); - out += ret_str; - i++; - } - - //out += seperator + seperator + seperator; - - return out; -} - -}}} /* end namespace vt::debug::stack */ - -#endif /*INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H*/ diff --git a/src/vt/configs/error/soft_error.h b/src/vt/configs/error/soft_error.h index 7b939081fe..67edd3bf7a 100644 --- a/src/vt/configs/error/soft_error.h +++ b/src/vt/configs/error/soft_error.h @@ -51,9 +51,11 @@ * the cost of these checks can be fully optimized out. */ +#include "vt/collective/basic.h" #include "vt/configs/types/types_type.h" #include "vt/configs/error/common.h" #include "vt/configs/error/pretty_print_message.h" +#include "vt/configs/features/features_defines.h" #include diff --git a/src/vt/configs/error/stack_out.cc b/src/vt/configs/error/stack_out.cc index 040d49fe82..d98b5e098e 100644 --- a/src/vt/configs/error/stack_out.cc +++ b/src/vt/configs/error/stack_out.cc @@ -44,6 +44,8 @@ #include #include "vt/configs/error/stack_out.h" +#include "vt/configs/debug/debug_colorize.h" +#include "vt/context/context.h" #include #include @@ -117,5 +119,43 @@ DumpStackType dumpStack(int skip) { return std::make_tuple(trace_buf.str(),tuple); } -}}} /* end namespace vt::debug::stack */ +std::string prettyPrintStack(StackVectorType const& stack) { + auto green = ::vt::debug::green(); + auto bred = ::vt::debug::bred(); + auto reset = ::vt::debug::reset(); + auto magenta = ::vt::debug::magenta(); + auto yellow = ::vt::debug::yellow(); + auto vt_pre = ::vt::debug::vtPre(); + auto node = ::vt::theContext()->getNode(); + auto node_str = ::vt::debug::proc(node); + auto prefix = vt_pre + node_str + " "; + auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); + auto title_node = fmt::format("on Node {}", node); + auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); + + std::string out = ""; + + out += fmt::format("{}", seperator); + out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); + out += fmt::format("{}", seperator); + + int i = 0; + for (auto&& t : stack) { + auto ret_str = fmt::format( + "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", + prefix, + bred, i, reset, + magenta, std::get<0>(t), std::get<1>(t), reset, + green, std::get<2>(t), reset, + std::get<3>(t), reset + ); + out += ret_str; + i++; + } + + //out += seperator + seperator + seperator; + return out; +} + +}}} /* end namespace vt::debug::stack */ diff --git a/src/vt/configs/error/stack_out.h b/src/vt/configs/error/stack_out.h index 57a0b2aacf..cf50a829e0 100644 --- a/src/vt/configs/error/stack_out.h +++ b/src/vt/configs/error/stack_out.h @@ -47,12 +47,13 @@ #include #include #include +#include namespace vt { namespace debug { namespace stack { -using StackTupleType = std::tuple; +using StackTupleType = std::tuple; using StackVectorType = std::vector; -using DumpStackType = std::tuple; +using DumpStackType = std::tuple; /* * This function automatically produce a backtrace of the stack with demangled @@ -60,6 +61,8 @@ using DumpStackType = std::tuple; */ DumpStackType dumpStack(int skip = 0); +std::string prettyPrintStack(StackVectorType const& stack); + }}} /* end namespace vt::debug::stack */ #endif /*INCLUDED_VT_CONFIGS_ERROR_STACK_OUT_H*/ diff --git a/src/vt/configs/features/features_defines.h b/src/vt/configs/features/features_defines.h index 166ad98848..52fba7d23d 100644 --- a/src/vt/configs/features/features_defines.h +++ b/src/vt/configs/features/features_defines.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H #define INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H +#include + /* * All the defined features/options for debugging and backend enable-ifs */ @@ -72,4 +74,6 @@ #define vt_feature_libfort 0 || vt_feature_cmake_libfort #define vt_feature_production_build 0 || vt_feature_cmake_production_build +#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0) + #endif /*INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H*/ diff --git a/src/vt/configs/features/features_enableif.h b/src/vt/configs/features/features_enableif.h deleted file mode 100644 index 24b40876ee..0000000000 --- a/src/vt/configs/features/features_enableif.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// features_enableif.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 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 -*/ - -#if !defined INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H -#define INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H - -#include "vt/configs/features/features_defines.h" - -#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0) - -#endif /*INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H*/ diff --git a/src/vt/configs/generated/vt_git_revision.h b/src/vt/configs/generated/vt_git_revision.h index a2595f2bc6..f84d6b54af 100644 --- a/src/vt/configs/generated/vt_git_revision.h +++ b/src/vt/configs/generated/vt_git_revision.h @@ -46,6 +46,9 @@ #include +extern int const vt_version_major; +extern int const vt_version_minor; +extern int const vt_version_patch; extern std::string const vt_git_sha1; extern std::string const vt_git_exact_tag; extern std::string const vt_git_refspec; diff --git a/src/vt/configs/types/types_headers.h b/src/vt/configs/types/types_headers.h index f1ebde4d3e..606db97d04 100644 --- a/src/vt/configs/types/types_headers.h +++ b/src/vt/configs/types/types_headers.h @@ -49,5 +49,6 @@ #include "vt/configs/types/types_rdma.h" #include "vt/configs/types/types_size.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #endif /*INCLUDED_VT_CONFIGS_TYPES_TYPES_HEADERS_H*/ diff --git a/src/vt/configs/types/types_rdma.h b/src/vt/configs/types/types_rdma.h index 787ccdb69f..91383a153a 100644 --- a/src/vt/configs/types/types_rdma.h +++ b/src/vt/configs/types/types_rdma.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_TYPES_TYPES_RDMA_H #define INCLUDED_VT_CONFIGS_TYPES_TYPES_RDMA_H -#include "vt/configs/debug/debug_masterconfig.h" #include "vt/configs/types/types_type.h" #include diff --git a/src/vt/configs/types/types_sentinels.h b/src/vt/configs/types/types_sentinels.h index 06faefa1f0..7fd67a7a38 100644 --- a/src/vt/configs/types/types_sentinels.h +++ b/src/vt/configs/types/types_sentinels.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_TYPES_TYPES_SENTINELS_H #define INCLUDED_VT_CONFIGS_TYPES_TYPES_SENTINELS_H -#include "vt/configs/debug/debug_masterconfig.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_rdma.h" diff --git a/src/vt/configs/types/types_type.h b/src/vt/configs/types/types_type.h index adaf543d72..ed125fea76 100644 --- a/src/vt/configs/types/types_type.h +++ b/src/vt/configs/types/types_type.h @@ -128,7 +128,4 @@ using ActionNodeType = std::function; } // end namespace vt -// Include the epoch type, which is a strong, named type -#include "vt/epoch/epoch_type.h" - #endif /*INCLUDED_VT_CONFIGS_TYPES_TYPES_TYPE_H*/ diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index 40174e188e..b991a8760e 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -47,6 +47,7 @@ #include "vt/context/runnable_context/base.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #include diff --git a/src/vt/epoch/epoch_impl_type.h b/src/vt/epoch/epoch_impl_type.h index f04bc1dd51..30631d44bd 100644 --- a/src/vt/epoch/epoch_impl_type.h +++ b/src/vt/epoch/epoch_impl_type.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_EPOCH_EPOCH_IMPL_TYPE_H #define INCLUDED_VT_EPOCH_EPOCH_IMPL_TYPE_H +#include + namespace vt { namespace epoch { namespace detail { /// Epoch tag type for the strong type diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 323339c308..df37e99653 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -233,7 +233,7 @@ EventType ActiveMessenger::sendMsgBytesWithPut( vtWarnIf( !(dest != theContext()->getNode() || is_bcast), - "Destination {} should != this node" + fmt::format("Destination {} should != this node", dest) ); MsgSizeType new_msg_size = base.size(); @@ -522,8 +522,31 @@ EventType ActiveMessenger::doMessageSend( base, uninitialized_destination, true, &deliver ); + // Don't go through MPI with self-send, schedule the message locally instead + auto const this_node = theContext()->getNode(); if (deliver) { - sendMsgBytesWithPut(dest, base, send_tag); + if (dest != this_node) { + sendMsgBytesWithPut(dest, base, send_tag); + } else { + if (theContext()->getTask() != nullptr) { + auto lb = theContext()->getTask()->get(); + if (lb) { + auto const already_recorded = + envelopeCommStatsRecordedAboveBareHandler(msg->env); + if (not already_recorded) { + auto dest_elm_id = elm::ElmIDBits::createBareHandler(dest); + theContext()->getTask()->send(dest_elm_id, base.size()); + } + } + } + + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable( + base, true, envelopeGetHandler(msg->env), dest, han_type + ) .withTDEpochFromMsg(is_term) + .withLBStats(&bare_handler_stats_, bare_handler_dummy_elm_id_for_lb_stats_) + .enqueue(); + } return no_event; } @@ -979,7 +1002,8 @@ bool ActiveMessenger::prepareActiveMsgToRun( } if (has_handler) { - runnable::makeRunnable(base, not is_term, handler, from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(base, not is_term, handler, from_node, han_type) .withContinuation(cont) .withTag(tag) .withTDEpochFromMsg(is_term) diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index 1de65daeb4..0bd36b4940 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -66,8 +66,9 @@ void send(MsgSharedPtr msg, HandlerType han, NodeType dest_node) { auto holder = detail::getHolderBase(han); auto const& elm_id = holder->getElmID(); auto stats = &holder->getStats(); + auto han_type = auto_registry::RegistryTypeEnum::RegObjGroup; - runnable::makeRunnable(msg, true, han, this_node) + runnable::makeRunnable(msg, true, han, this_node, han_type) .withTDEpoch(cur_epoch) .withLBStats(stats, elm_id) .enqueue(); @@ -87,7 +88,8 @@ void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType dest_nod ); // this is a local invocation.. no thread required - runnable::makeRunnable(msg.msg_, false, han, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegObjGroup; + runnable::makeRunnable(msg.msg_, false, han, this_node, han_type) .withTDEpochFromMsg() .run(); } diff --git a/src/vt/pipe/callback/handler_send/callback_send.impl.h b/src/vt/pipe/callback/handler_send/callback_send.impl.h index fd172c0eab..c716d75327 100644 --- a/src/vt/pipe/callback/handler_send/callback_send.impl.h +++ b/src/vt/pipe/callback/handler_send/callback_send.impl.h @@ -110,7 +110,8 @@ CallbackSend::triggerDispatch(SignalDataType* data, PipeType const& pid) { if (this_node == send_node_) { auto msg = reinterpret_cast(data); auto m = promoteMsg(msg); - runnable::makeRunnable(m, true, handler_, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(m, true, handler_, this_node, han_type) .withTDEpochFromMsg() .enqueue(); } else { diff --git a/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h b/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h index 91c0581ba0..b9fc3859a6 100644 --- a/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h +++ b/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h @@ -71,7 +71,8 @@ void CallbackSendTypeless::trigger(MsgT* msg, PipeType const& pipe) { ); auto pmsg = promoteMsg(msg); if (this_node == send_node_) { - runnable::makeRunnable(pmsg, true, handler_, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(pmsg, true, handler_, this_node, han_type) .withTDEpochFromMsg() .enqueue(); } else { diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 5b8ccd8527..40bf4d585e 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -313,19 +313,19 @@ struct RunnableMaker { * \param[in] is_threaded whether it is threaded * \param[in] handler the handler bits * \param[in] from the node that caused this runnable to execute - * \param[in] han_type the type of handler (default RegGeneral) + * \param[in] han_type the type of handler * * \return the maker for further customization */ template RunnableMaker makeRunnable( MsgSharedPtr const& msg, bool is_threaded, HandlerType handler, - NodeType from, auto_registry::RegistryTypeEnum han_type = - auto_registry::RegistryTypeEnum::RegGeneral + NodeType from, auto_registry::RegistryTypeEnum han_type ) { auto r = std::make_unique(msg, is_threaded); if (han_type == auto_registry::RegistryTypeEnum::RegVrt or - han_type == auto_registry::RegistryTypeEnum::RegGeneral) { + han_type == auto_registry::RegistryTypeEnum::RegGeneral or + han_type == auto_registry::RegistryTypeEnum::RegObjGroup) { r->template addContext(msg, handler, from, han_type); } r->template addContext(from); @@ -339,15 +339,14 @@ RunnableMaker makeRunnable( * \param[in] is_threaded whether it is threaded * \param[in] handler the handler bits * \param[in] from the node that caused this runnable to execute - * \param[in] han_type the type of handler (default RegGeneral) * * \return the maker for further customization */ inline RunnableMaker makeRunnableVoid( - bool is_threaded, HandlerType handler, - NodeType from, auto_registry::RegistryTypeEnum han_type = - auto_registry::RegistryTypeEnum::RegGeneral + bool is_threaded, HandlerType handler, NodeType from ) { + // These are currently only types of registry entries that can be void + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; auto r = std::make_unique(is_threaded); // @todo: figure out how to trace this? r->template addContext(from); diff --git a/src/vt/runtime/mpi_access.h b/src/vt/runtime/mpi_access.h index 9b2deaf7c7..413f98cac4 100644 --- a/src/vt/runtime/mpi_access.h +++ b/src/vt/runtime/mpi_access.h @@ -44,7 +44,7 @@ #if !defined INCLUDED_VT_RUNTIME_MPI_ACCESS_H #define INCLUDED_VT_RUNTIME_MPI_ACCESS_H -#include "vt/configs/features/features_enableif.h" +#include "vt/configs/features/features_defines.h" #if vt_check_enabled(mpi_access_guards) #define VT_ALLOW_MPI_CALLS vt::runtime::ScopedMPIAccess _vt_allow_scoped_mpi{}; diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 837bc76363..b63befaecb 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -64,7 +64,6 @@ #include "vt/worker/worker_headers.h" #include "vt/configs/debug/debug_colorize.h" #include "vt/configs/error/stack_out.h" -#include "vt/configs/error/pretty_print_stack.h" #include "vt/utils/memory/memory_usage.h" #include "vt/runtime/component/component_pack.h" #include "vt/utils/mpi_limits/mpi_max_tag.h" @@ -100,7 +99,8 @@ namespace vt { namespace runtime { Runtime::Runtime( int& argc, char**& argv, WorkerCountType in_num_workers, - bool const interop_mode, MPI_Comm in_comm, RuntimeInstType const in_instance + bool const interop_mode, MPI_Comm in_comm, RuntimeInstType const in_instance, + arguments::AppConfig const* appConfig ) : instance_(in_instance), runtime_active_(false), is_interop_(interop_mode), num_workers_(in_num_workers), initial_communicator_(in_comm), @@ -153,7 +153,7 @@ Runtime::Runtime( // n.b. ref-update of args with pass-through arguments std::tuple result = - arg_config_->parse(/*out*/ argc, /*out*/ argv); + arg_config_->parse(argc, argv, appConfig); int exit_code = std::get<0>(result); if (getAppConfig()->vt_help_lb_args) { diff --git a/src/vt/runtime/runtime.h b/src/vt/runtime/runtime.h index 9820150378..0c76211beb 100644 --- a/src/vt/runtime/runtime.h +++ b/src/vt/runtime/runtime.h @@ -101,7 +101,8 @@ struct Runtime { WorkerCountType in_num_workers = no_workers, bool const interop_mode = false, MPI_Comm in_comm = MPI_COMM_WORLD, - RuntimeInstType const in_instance = RuntimeInstType::DefaultInstance + RuntimeInstType const in_instance = RuntimeInstType::DefaultInstance, + arguments::AppConfig const* appConfig = nullptr ); Runtime(Runtime const&) = delete; diff --git a/src/vt/runtime/runtime_banner.cc b/src/vt/runtime/runtime_banner.cc index c59f24b1bd..f5f9e09c18 100644 --- a/src/vt/runtime/runtime_banner.cc +++ b/src/vt/runtime/runtime_banner.cc @@ -164,7 +164,7 @@ void Runtime::printStartupBanner() { #endif std::string dirty = ""; - if (strncmp(vt_git_clean_status.c_str(), "DIRTY", 5) == 0) { + if (vt_git_clean_status == "DIRTY") { dirty = red + std::string("*dirty*") + reset; } @@ -174,29 +174,29 @@ void Runtime::printStartupBanner() { auto const version = std::to_string(std::get<0>(version_tuple)); auto const subversion = std::to_string(std::get<1>(version_tuple)); - auto f1 = fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)); - auto f2a = fmt::format("{}Program: {} ({})\n", green, - emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name)); - auto f2b = fmt::format("{}Running on: {}\n", green, emph(all_node)); - auto f3 = fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)); - auto f3a = fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)); - auto f3b = fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)); - - auto f4 = fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)); - auto f5 = fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)); - auto f6 = fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty); - auto f7 = fmt::format("{}Compile-time Features Enabled:{}\n", green, reset); - - fmt::print("{}{}{}", vt_pre, f1, reset); - fmt::print("{}{}{}", vt_pre, f2a, reset); - fmt::print("{}{}{}", vt_pre, f2b, reset); - fmt::print("{}{}{}", vt_pre, f3, reset); - fmt::print("{}{}{}", vt_pre, f3a, reset); - fmt::print("{}{}{}", vt_pre, f3b, reset); - fmt::print("{}{}{}", vt_pre, f4, reset); - fmt::print("{}{}{}", vt_pre, f5, reset); - fmt::print("{}{}{}", vt_pre, f6, reset); - fmt::print("{}{}{}", vt_pre, f7, reset); + auto vt_version_string = fmt::format("{}.{}.{}", vt_version_major, vt_version_minor, vt_version_patch); + std::array< std::string, 11 > info_lines = { + fmt::format("{}Version: {}\n", green, emph(vt_version_string)), + + fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)), + fmt::format("{}Program: {} ({})\n", green, + emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name)), + fmt::format("{}Running on: {}\n", green, emph(all_node)), + fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)), + fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)), + fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)), + + fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)), + fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)), + fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty), + fmt::format("{}Compile-time Features Enabled:{}\n", green, reset) + }; + + for (auto &&line: info_lines) + { + fmt::print("{}{}{}", vt_pre, line, reset); + } + for (size_t i = 0; i < features.size(); i++) { fmt::print("{}\t{}\n", vt_pre, emph(features.at(i))); } diff --git a/src/vt/runtime/runtime_get.cc b/src/vt/runtime/runtime_get.cc index 2a3d86a574..e7260d5882 100644 --- a/src/vt/runtime/runtime_get.cc +++ b/src/vt/runtime/runtime_get.cc @@ -168,7 +168,7 @@ static arguments::AppConfig preInitAppConfig{}; * * \return A modifiable configuration */ -arguments::AppConfig* preConfigRef(){ +arguments::AppConfig* preConfigRef() { return &preInitAppConfig; } diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index d8c189a81b..efd9d4c2a5 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -88,7 +88,8 @@ template auto msg_data = ptr_offset; auto user_msg = deserializeFullMessage(msg_data); - runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node, han_type) .withTDEpochFromMsg() .enqueue(); } @@ -132,7 +133,8 @@ template handler, recv_tag, envelopeGetEpoch(msg->env) ); - runnable::makeRunnable(msg, true, handler, node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, handler, node, han_type) .withTDEpoch(epoch, not is_valid_epoch) .withContinuation(action) .enqueue(); @@ -174,7 +176,8 @@ template print_ptr(user_msg.get()), envelopeGetEpoch(sys_msg->env) ); - runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node, han_type) .withTDEpochFromMsg() .enqueue(); } @@ -407,7 +410,8 @@ template auto base_msg = msg.template to(); return messaging::PendingSend(base_msg, [=](MsgPtr in){ - runnable::makeRunnable(msg, true, typed_handler, node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, typed_handler, node, han_type) .withTDEpochFromMsg() .enqueue(); }); diff --git a/src/vt/termination/termination.h b/src/vt/termination/termination.h index e0466b540d..8834006308 100644 --- a/src/vt/termination/termination.h +++ b/src/vt/termination/termination.h @@ -213,7 +213,7 @@ struct TerminationDetector : * \return the new epoch */ EpochType makeEpochRooted( - UseDS use_ds = UseDS{false}, + UseDS use_ds = UseDS{true}, ParentEpochCapture parent = ParentEpochCapture{} ); @@ -239,7 +239,7 @@ struct TerminationDetector : */ EpochType makeEpochRooted( std::string const& label, - UseDS use_ds = UseDS{false}, + UseDS use_ds = UseDS{true}, ParentEpochCapture parent = ParentEpochCapture{} ); diff --git a/src/vt/topos/location/location.impl.h b/src/vt/topos/location/location.impl.h index 2bd01c2b85..4b0ea48ca5 100644 --- a/src/vt/topos/location/location.impl.h +++ b/src/vt/topos/location/location.impl.h @@ -538,7 +538,8 @@ void EntityLocationCoord::routeMsgNode( hid, from, handler, envelopeGetRef(msg->env) ); - runnable::makeRunnable(msg, true, handler, from) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, handler, from, han_type) .withTDEpochFromMsg() .run(); } else { diff --git a/src/vt/trace/trace_lite.h b/src/vt/trace/trace_lite.h index b7f3e9dbfc..7ed64ba559 100644 --- a/src/vt/trace/trace_lite.h +++ b/src/vt/trace/trace_lite.h @@ -44,7 +44,7 @@ #if !defined INCLUDED_VT_TRACE_TRACE_LITE_H #define INCLUDED_VT_TRACE_TRACE_LITE_H -#include "vt/configs/features/features_enableif.h" +#include "vt/configs/features/features_defines.h" #include "vt/trace/trace_common.h" #include "vt/trace/trace_log.h" #include "vt/trace/trace_user_event.h" diff --git a/src/vt/utils/bits/bits_counter.h b/src/vt/utils/bits/bits_counter.h index 1d6b968bb1..8994f65d0a 100644 --- a/src/vt/utils/bits/bits_counter.h +++ b/src/vt/utils/bits/bits_counter.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_UTILS_BITS_BITS_COUNTER_H #define INCLUDED_VT_UTILS_BITS_BITS_COUNTER_H +#include + // Do not pull in other VT dependencies here namespace vt { namespace utils { diff --git a/src/vt/utils/strong/strong_type.h b/src/vt/utils/strong/strong_type.h index bc82096074..5088b5928e 100644 --- a/src/vt/utils/strong/strong_type.h +++ b/src/vt/utils/strong/strong_type.h @@ -44,6 +44,9 @@ #if !defined INCLUDED_VT_UTILS_STRONG_STRONG_TYPE_H #define INCLUDED_VT_UTILS_STRONG_STRONG_TYPE_H +#include +#include + namespace vt { namespace util { namespace strong { namespace detail { /** diff --git a/src/vt/vrt/collection/balance/baselb/baselb.cc b/src/vt/vrt/collection/balance/baselb/baselb.cc index 2035b69608..07cc718ad9 100644 --- a/src/vt/vrt/collection/balance/baselb/baselb.cc +++ b/src/vt/vrt/collection/balance/baselb/baselb.cc @@ -228,7 +228,9 @@ void BaseLB::notifyNewHostNodeOfObjectsArriving( } void BaseLB::migrateObjectTo(ObjIDType const obj_id, NodeType const to) { - transfers_.push_back(TransferDestType{obj_id, to}); + if (obj_id.curr_node != to) { + transfers_.push_back(TransferDestType{obj_id, to}); + } } void BaseLB::finalize(CountMsg* msg) { diff --git a/src/vt/vrt/collection/collection_builder.impl.h b/src/vt/vrt/collection/collection_builder.impl.h index f33a463927..81137355bf 100644 --- a/src/vt/vrt/collection/collection_builder.impl.h +++ b/src/vt/vrt/collection/collection_builder.impl.h @@ -62,7 +62,9 @@ std::tuple CollectionManager::makeCollection( po.proxy_bits_ = proxy_bits; if (not is_collective) { - auto ep = theTerm()->makeEpochRooted("collection construction"); + auto ep = theTerm()->makeEpochRooted( + "collection construction", term::UseDS{false} + ); theMsg()->pushEpoch(ep); using MsgType = param::ConstructParamMsg; auto m = makeMessage(po); diff --git a/tests/unit/collection/test_mapping.cc b/tests/unit/collection/test_mapping.cc index a09b25e414..62ed3439e2 100644 --- a/tests/unit/collection/test_mapping.cc +++ b/tests/unit/collection/test_mapping.cc @@ -256,7 +256,6 @@ struct MyDistMapper : vt::mapping::BaseMapper { /// get to decide the mapping return (val ^ my_state) % num_nodes; } else { - // runInEpochRooted is not DS? auto ep = theTerm()->makeEpochRooted("mapTest", term::UseDS{true}); theMsg()->pushEpoch(ep); proxy[owner].template send::getMap>( diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index d47fb7afb5..efa91da93e 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -47,40 +47,204 @@ #include +#include + namespace vt { namespace tests { namespace unit { -struct TestInitialization : TestParallelHarness { - void SetUp() override { - using namespace vt; +struct TestInitialization : TestParallelHarness { }; + +TEST_F(TestInitialization, test_initialize_with_args) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + + 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(nullptr); + + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 3); - TestHarness::SetUp(); + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm); - // communicator is duplicated. - MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_no_terminate, true); - static char prog_name[]{"vt_program"}; - static char cli_argument[]{"--cli_argument=100"}; - static char vt_no_terminate[]{"--vt_no_terminate"}; - custom_args.emplace_back(prog_name); - custom_args.emplace_back(cli_argument); - custom_args.emplace_back(vt_no_terminate); - custom_args.emplace_back(nullptr); + 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_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 2); + + arguments::AppConfig appConfig{}; + appConfig.vt_epoch_graph_on_hang = false; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_epoch_graph_on_hang, false); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + EXPECT_EQ(theConfig()->vt_lb_stats, true); + + // vt_no_detect_hang wasn't set, should be default + EXPECT_EQ(theConfig()->vt_no_detect_hang, false); + + 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_args_and_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + static char vt_no_detect_hang[]{"--vt_no_detect_hang"}; + + 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(vt_no_detect_hang); + custom_args.emplace_back(nullptr); - custom_argc = custom_args.size() - 1; - custom_argv = custom_args.data(); - EXPECT_EQ(custom_argc, 3); + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); - vt::initialize(custom_argc, custom_argv, no_workers, true, &comm); + EXPECT_EQ(custom_argc, 4); + + arguments::AppConfig appConfig{}; + appConfig.vt_color = false; + appConfig.vt_epoch_graph_on_hang = false; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + appConfig.vt_no_detect_hang = false; + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_color, false); + EXPECT_EQ(theConfig()->vt_epoch_graph_on_hang, false); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + EXPECT_EQ(theConfig()->vt_lb_stats, true); + EXPECT_EQ(theConfig()->vt_no_terminate, true); + // CLI args should overwrite hardcoded appConfig + EXPECT_EQ(theConfig()->vt_no_detect_hang, true); + + 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_file_and_args) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + 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"}; + static char vt_input_config[]{"--vt_input_config=test_cfg.toml"}; + + 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(vt_input_config); + custom_args.emplace_back(vt_lb_name); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char **custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 5); + + int this_rank; + MPI_Comm_rank(comm, &this_rank); + if (this_rank == 0) { + std::ofstream cfg_file_{"test_cfg.toml", std::ofstream::out | std::ofstream::trunc}; + cfg_file_ << "vt_lb_name = RandomLB\n"; + cfg_file_.close(); } + MPI_Barrier(comm); + + vt::initialize(custom_argc, custom_argv, no_workers, true, &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_file_args_and_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + 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"}; + static char vt_input_config[]{"--vt_input_config=test_cfg.toml"}; std::vector custom_args; - int custom_argc; - char** custom_argv; -}; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(vt_input_config); + custom_args.emplace_back(vt_lb_name); + custom_args.emplace_back(nullptr); + + 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"; + + int this_rank; + MPI_Comm_rank(comm, &this_rank); + if (this_rank == 0) { + std::ofstream cfg_file_{"test_cfg.toml", std::ofstream::out | std::ofstream::trunc}; + cfg_file_ << "vt_lb_name = RandomLB\n"; + cfg_file_.close(); + } + MPI_Barrier(comm); + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); -TEST_F(TestInitialization, test_initialize_with_args) { 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"); diff --git a/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc b/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc new file mode 100644 index 0000000000..50352f32cf --- /dev/null +++ b/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc @@ -0,0 +1,114 @@ +/* +//@HEADER +// ***************************************************************************** +// +// test_temp_enabling_debug_prints.nompi.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 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 + +#include "test_harness.h" + +#include +#include + +namespace vt { namespace tests { namespace unit { + +struct TestTempEnablingDisablingDebugPrints : TestHarness { }; + +TEST_F(TestTempEnablingDisablingDebugPrints, test_manual_enabling_disabling) { + vt::initialize(); + + EXPECT_EQ(theConfig()->vt_debug_all, false); + EXPECT_EQ(theConfig()->vt_debug_termds, false); + EXPECT_EQ(theConfig()->vt_debug_param, false); + EXPECT_EQ(theConfig()->vt_debug_scatter, false); + + vt_debug_temp_enable_opt(all); + vt_debug_temp_enable_opt(termds); + vt_debug_temp_enable_opt(param); + vt_debug_temp_enable_opt(scatter); + + EXPECT_EQ(theConfig()->vt_debug_all, true); + EXPECT_EQ(theConfig()->vt_debug_termds, true); + EXPECT_EQ(theConfig()->vt_debug_param, true); + EXPECT_EQ(theConfig()->vt_debug_scatter, true); + + vt_debug_temp_disable_opt(all); + vt_debug_temp_disable_opt(termds); + vt_debug_temp_disable_opt(param); + vt_debug_temp_disable_opt(scatter); + + EXPECT_EQ(theConfig()->vt_debug_all, false); + EXPECT_EQ(theConfig()->vt_debug_termds, false); + EXPECT_EQ(theConfig()->vt_debug_param, false); + EXPECT_EQ(theConfig()->vt_debug_scatter, false); + + vt::finalize(); +} + +TEST_F(TestTempEnablingDisablingDebugPrints, test_scoped_enabling_disabling) { + vt::initialize(); + + EXPECT_EQ(theConfig()->vt_debug_none, false); + EXPECT_EQ(theConfig()->vt_debug_active, false); + EXPECT_EQ(theConfig()->vt_debug_reduce, false); + EXPECT_EQ(theConfig()->vt_debug_context, false); + + { + auto const scopedEnabledNone = vt_debug_scoped_enable_opt(none); + auto const scopedEnabledActive = vt_debug_scoped_enable_opt(active); + auto const scopedEnabledReduce = vt_debug_scoped_enable_opt(reduce); + auto const scopedEnabledContext = vt_debug_scoped_enable_opt(context); + + EXPECT_EQ(theConfig()->vt_debug_none, true); + EXPECT_EQ(theConfig()->vt_debug_active, true); + EXPECT_EQ(theConfig()->vt_debug_reduce, true); + EXPECT_EQ(theConfig()->vt_debug_context, true); + } + + EXPECT_EQ(theConfig()->vt_debug_none, false); + EXPECT_EQ(theConfig()->vt_debug_active, false); + EXPECT_EQ(theConfig()->vt_debug_reduce, false); + EXPECT_EQ(theConfig()->vt_debug_context, false); + + vt::finalize(); +} + +}}} // end namespace vt::tests::unit diff --git a/vt_git_revision.cc.in b/vt_git_revision.cc.in index 300c991267..e5516088a3 100644 --- a/vt_git_revision.cc.in +++ b/vt_git_revision.cc.in @@ -45,12 +45,18 @@ #include +#define VT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define VT_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define VT_VERSION_PATCH @PROJECT_VERSION_PATCH@ #define VT_GIT_SHA1 "@GIT_SHA1@" #define VT_GIT_EXACT_TAG "@GIT_EXACT_TAG@" #define VT_GIT_REFSPEC "@GIT_REFSPEC@" #define VT_GIT_DESCRIPTION "@GIT_DESCRIPTION@" #define VT_GIT_CLEAN_STATUS "@GIT_CLEAN_STATUS@" +int const vt_version_major = VT_VERSION_MAJOR; +int const vt_version_minor = VT_VERSION_MINOR; +int const vt_version_patch = VT_VERSION_PATCH; std::string const vt_git_sha1 = VT_GIT_SHA1; std::string const vt_git_exact_tag = VT_GIT_EXACT_TAG; std::string const vt_git_refspec = VT_GIT_REFSPEC; diff --git a/vt_git_revision.h b/vt_git_revision.h deleted file mode 100644 index 086d6b8abf..0000000000 --- a/vt_git_revision.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// vt_git_revision.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 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 -*/ - -#if !defined VT_CONFIG_GIT_REVISION_H -#define VT_CONFIG_GIT_REVISION_H - -#include - -extern std::string const vt_git_sha1; -extern std::string const vt_git_exact_tag; -extern std::string const vt_git_refspec; -extern std::string const vt_git_description; -extern std::string const vt_git_clean_status; - -#endif /*VT_CONFIG_GIT_REVISION_H*/