Skip to content

Commit 176190c

Browse files
authored
Merge pull request #1436 from DARMA-tasking/1435-print-time-units-for-lb-times
1435: Print time units and adjust accordingly for LB times
2 parents f88c3ba + 65af4ee commit 176190c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+686
-128
lines changed

cmake/link_vt.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function(link_target_with_vt)
2424
LINK_ATOMIC
2525
LINK_MPI
2626
LINK_FMT
27+
LINK_ENG_FORMAT
2728
LINK_ZLIB
2829
LINK_FCONTEXT
2930
LINK_CHECKPOINT
@@ -163,6 +164,15 @@ function(link_target_with_vt)
163164
)
164165
endif()
165166

167+
if (NOT DEFINED ARG_LINK_ENG_FORMAT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_ENG_FORMAT)
168+
if (${ARG_DEBUG_LINK})
169+
message(STATUS "link_target_with_vt: EngFormat-Cpp=${ARG_LINK_ENG_FORMAT}")
170+
endif()
171+
target_link_libraries(
172+
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${ENG_FORMAT_LIBRARY}
173+
)
174+
endif()
175+
166176
if (NOT DEFINED ARG_LINK_CHECKPOINT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_CHECKPOINT)
167177
if (${ARG_DEBUG_LINK})
168178
message(STATUS "link_target_with_vt: checkpoint=${ARG_LINK_CHECKPOINT}")

cmake/load_bundled_libraries.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ add_subdirectory(${PROJECT_LIB_DIR}/CLI)
2323
set(FMT_LIBRARY fmt)
2424
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
2525

26+
# EngFormat-Cpp always included in the build
27+
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)
28+
add_subdirectory(${PROJECT_LIB_DIR}/EngFormat-Cpp)
29+
2630
# json library always included in the build
2731
set(JSON_BuildTests OFF)
2832
set(JSON_MultipleHeaders ON)

cmake/trace_only_functions.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ function(create_trace_only_target)
9898
DESTINATION "include/vt-trace/fmt"
9999
)
100100

101+
install(
102+
FILES "${CMAKE_CURRENT_SOURCE_DIR}/../lib/EngFormat-Cpp/include/EngFormat-Cpp/eng_format.hpp"
103+
DESTINATION "include/vt-trace/EngFormat-Cpp"
104+
)
105+
101106
set(VT_TRACE_LIB vt-trace CACHE INTERNAL "" FORCE)
102107
add_library(
103108
${VT_TRACE_LIB}
@@ -114,6 +119,7 @@ function(create_trace_only_target)
114119
TARGET ${VT_TRACE_LIB}
115120
LINK_VT_LIB
116121
LINK_FMT 1
122+
LINK_ENG_FORMAT 1
117123
LINK_ZLIB 1
118124
LINK_MPI 1
119125
)

examples/collection/lb_iter.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ int main(int argc, char** argv) {
124124
.wait();
125125

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

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

133-
auto total_time = vt::timing::Timing::getCurrentTime() - cur_time;
133+
auto total_time = vt::timing::getCurrentTime() - cur_time;
134134
if (this_node == 0) {
135135
fmt::print("iteration: iter={},time={}\n", i, total_time);
136136
}

lib/EngFormat-Cpp/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
project(EngFormat-Cpp CXX)
2+
cmake_minimum_required(VERSION 3.0)
3+
4+
add_library(${PROJECT_NAME} include/EngFormat-Cpp/eng_format.hpp src/eng_format.cpp)
5+
6+
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
7+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
8+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
9+
10+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
11+
include(CTest)
12+
if(BUILD_TESTING)
13+
target_compile_definitions(${PROJECT_NAME} PRIVATE ENG_FORMAT_MICRO_GLYPH="u")
14+
add_subdirectory(test)
15+
endif()
16+
endif()
17+
18+
install(
19+
DIRECTORY include/EngFormat-Cpp
20+
DESTINATION include
21+
CONFIGURATIONS ${build_type_list}
22+
FILES_MATCHING PATTERN "*"
23+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Copyright (C) 2005-2009 by Jukka Korpela
2+
// Copyright (C) 2009-2013 by David Hoerl
3+
// Copyright (C) 2013 by Martin Moene
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
#ifndef ENG_FORMAT_H_INCLUDED
24+
#define ENG_FORMAT_H_INCLUDED
25+
26+
#include <string>
27+
28+
/**
29+
* convert a double to the specified number of digits in SI (prefix) or
30+
* exponential notation, optionally followed by a unit.
31+
*/
32+
std::string
33+
to_engineering_string( double value, int digits, bool exponential, std::string unit = "", std::string separator = " " );
34+
35+
/**
36+
* convert the output of to_engineering_string() into a double.
37+
*/
38+
double
39+
from_engineering_string( std::string text );
40+
41+
/**
42+
* step a value by the smallest possible increment.
43+
*/
44+
std::string
45+
step_engineering_string( std::string text, int digits, bool exponential, bool increment );
46+
47+
//
48+
// Extended interface:
49+
//
50+
51+
/**
52+
* \var eng_prefixed
53+
* \brief select SI (prefix) presentation: to_engineering_string(), step_engineering_string().
54+
*/
55+
56+
/**
57+
* \var eng_exponential
58+
* \brief select exponential presentation: to_engineering_string(), step_engineering_string().
59+
*/
60+
61+
extern struct eng_prefixed_t {} eng_prefixed;
62+
extern struct eng_exponential_t {} eng_exponential;
63+
64+
/**
65+
* \var eng_increment
66+
* \brief let step_engineering_string() make a postive step.
67+
*/
68+
69+
/**
70+
* \var eng_decrement
71+
* \brief let step_engineering_string() make a negative step.
72+
*/
73+
74+
constexpr bool eng_increment = true;
75+
constexpr bool eng_decrement = false;
76+
77+
/**
78+
* convert a double to the specified number of digits in SI (prefix) notation,
79+
* optionally followed by a unit.
80+
*/
81+
inline std::string
82+
to_engineering_string( double value, int digits, eng_prefixed_t, std::string unit = "", std::string separator = " " )
83+
{
84+
return to_engineering_string( value, digits, false, unit, separator );
85+
}
86+
87+
/**
88+
* convert a double to the specified number of digits in exponential notation,
89+
* optionally followed by a unit.
90+
*/
91+
inline std::string
92+
to_engineering_string( double value, int digits, eng_exponential_t, std::string unit = "", std::string separator = " " )
93+
{
94+
return to_engineering_string( value, digits, true, unit, separator );
95+
}
96+
97+
/**
98+
* step a value by the smallest possible increment, using SI notation.
99+
*/
100+
inline std::string
101+
step_engineering_string( std::string text, int digits, eng_prefixed_t, bool increment )
102+
{
103+
return step_engineering_string( text, digits, false, increment );
104+
}
105+
106+
/**
107+
* step a value by the smallest possible increment, using exponential notation.
108+
*/
109+
inline std::string
110+
step_engineering_string( std::string text, int digits, eng_exponential_t, bool increment )
111+
{
112+
return step_engineering_string( text, digits, true, increment );
113+
}
114+
115+
#endif // ENG_FORMAT_H_INCLUDED

0 commit comments

Comments
 (0)