Skip to content

Commit

Permalink
Merge pull request #1436 from DARMA-tasking/1435-print-time-units-for…
Browse files Browse the repository at this point in the history
…-lb-times

1435: Print time units and adjust accordingly for LB times
  • Loading branch information
PhilMiller authored Jan 13, 2022
2 parents f88c3ba + 65af4ee commit 176190c
Show file tree
Hide file tree
Showing 45 changed files with 686 additions and 128 deletions.
10 changes: 10 additions & 0 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function(link_target_with_vt)
LINK_ATOMIC
LINK_MPI
LINK_FMT
LINK_ENG_FORMAT
LINK_ZLIB
LINK_FCONTEXT
LINK_CHECKPOINT
Expand Down Expand Up @@ -163,6 +164,15 @@ function(link_target_with_vt)
)
endif()

if (NOT DEFINED ARG_LINK_ENG_FORMAT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_ENG_FORMAT)
if (${ARG_DEBUG_LINK})
message(STATUS "link_target_with_vt: EngFormat-Cpp=${ARG_LINK_ENG_FORMAT}")
endif()
target_link_libraries(
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${ENG_FORMAT_LIBRARY}
)
endif()

if (NOT DEFINED ARG_LINK_CHECKPOINT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_CHECKPOINT)
if (${ARG_DEBUG_LINK})
message(STATUS "link_target_with_vt: checkpoint=${ARG_LINK_CHECKPOINT}")
Expand Down
4 changes: 4 additions & 0 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ add_subdirectory(${PROJECT_LIB_DIR}/CLI)
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)

# EngFormat-Cpp always included in the build
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)
add_subdirectory(${PROJECT_LIB_DIR}/EngFormat-Cpp)

# json library always included in the build
set(JSON_BuildTests OFF)
set(JSON_MultipleHeaders ON)
Expand Down
6 changes: 6 additions & 0 deletions cmake/trace_only_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ function(create_trace_only_target)
DESTINATION "include/vt-trace/fmt"
)

install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/../lib/EngFormat-Cpp/include/EngFormat-Cpp/eng_format.hpp"
DESTINATION "include/vt-trace/EngFormat-Cpp"
)

set(VT_TRACE_LIB vt-trace CACHE INTERNAL "" FORCE)
add_library(
${VT_TRACE_LIB}
Expand All @@ -114,6 +119,7 @@ function(create_trace_only_target)
TARGET ${VT_TRACE_LIB}
LINK_VT_LIB
LINK_FMT 1
LINK_ENG_FORMAT 1
LINK_ZLIB 1
LINK_MPI 1
)
Expand Down
4 changes: 2 additions & 2 deletions examples/collection/lb_iter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ int main(int argc, char** argv) {
.wait();

for (int i = 0; i < num_iter; i++) {
auto cur_time = vt::timing::Timing::getCurrentTime();
auto cur_time = vt::timing::getCurrentTime();

vt::runInEpochCollective([=]{
proxy.broadcastCollective<IterCol::IterMsg,&IterCol::iterWork>(10, i);
});

auto total_time = vt::timing::Timing::getCurrentTime() - cur_time;
auto total_time = vt::timing::getCurrentTime() - cur_time;
if (this_node == 0) {
fmt::print("iteration: iter={},time={}\n", i, total_time);
}
Expand Down
23 changes: 23 additions & 0 deletions lib/EngFormat-Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
project(EngFormat-Cpp CXX)
cmake_minimum_required(VERSION 3.0)

add_library(${PROJECT_NAME} include/EngFormat-Cpp/eng_format.hpp src/eng_format.cpp)

target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
target_compile_definitions(${PROJECT_NAME} PRIVATE ENG_FORMAT_MICRO_GLYPH="u")
add_subdirectory(test)
endif()
endif()

install(
DIRECTORY include/EngFormat-Cpp
DESTINATION include
CONFIGURATIONS ${build_type_list}
FILES_MATCHING PATTERN "*"
)
115 changes: 115 additions & 0 deletions lib/EngFormat-Cpp/include/EngFormat-Cpp/eng_format.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (C) 2005-2009 by Jukka Korpela
// Copyright (C) 2009-2013 by David Hoerl
// Copyright (C) 2013 by Martin Moene
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef ENG_FORMAT_H_INCLUDED
#define ENG_FORMAT_H_INCLUDED

#include <string>

/**
* convert a double to the specified number of digits in SI (prefix) or
* exponential notation, optionally followed by a unit.
*/
std::string
to_engineering_string( double value, int digits, bool exponential, std::string unit = "", std::string separator = " " );

/**
* convert the output of to_engineering_string() into a double.
*/
double
from_engineering_string( std::string text );

/**
* step a value by the smallest possible increment.
*/
std::string
step_engineering_string( std::string text, int digits, bool exponential, bool increment );

//
// Extended interface:
//

/**
* \var eng_prefixed
* \brief select SI (prefix) presentation: to_engineering_string(), step_engineering_string().
*/

/**
* \var eng_exponential
* \brief select exponential presentation: to_engineering_string(), step_engineering_string().
*/

extern struct eng_prefixed_t {} eng_prefixed;
extern struct eng_exponential_t {} eng_exponential;

/**
* \var eng_increment
* \brief let step_engineering_string() make a postive step.
*/

/**
* \var eng_decrement
* \brief let step_engineering_string() make a negative step.
*/

constexpr bool eng_increment = true;
constexpr bool eng_decrement = false;

/**
* convert a double to the specified number of digits in SI (prefix) notation,
* optionally followed by a unit.
*/
inline std::string
to_engineering_string( double value, int digits, eng_prefixed_t, std::string unit = "", std::string separator = " " )
{
return to_engineering_string( value, digits, false, unit, separator );
}

/**
* convert a double to the specified number of digits in exponential notation,
* optionally followed by a unit.
*/
inline std::string
to_engineering_string( double value, int digits, eng_exponential_t, std::string unit = "", std::string separator = " " )
{
return to_engineering_string( value, digits, true, unit, separator );
}

/**
* step a value by the smallest possible increment, using SI notation.
*/
inline std::string
step_engineering_string( std::string text, int digits, eng_prefixed_t, bool increment )
{
return step_engineering_string( text, digits, false, increment );
}

/**
* step a value by the smallest possible increment, using exponential notation.
*/
inline std::string
step_engineering_string( std::string text, int digits, eng_exponential_t, bool increment )
{
return step_engineering_string( text, digits, true, increment );
}

#endif // ENG_FORMAT_H_INCLUDED
Loading

0 comments on commit 176190c

Please sign in to comment.