-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2147: fix incorrect order of parameters for call to beginProcessing #2148
Changes from all commits
29ec80b
41437d4
cb50a14
f286d15
dc22536
47a8f82
3c4d0e3
1921d59
f8a80b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,7 +359,7 @@ TraceProcessingTag Trace::beginProcessing( | |
); | ||
|
||
if (theConfig()->vt_trace_memory_usage) { | ||
addMemoryEvent(theMemUsage()->getFirstUsage()); | ||
addMemoryEvent(theMemUsage()->getFirstUsage(), time); | ||
} | ||
|
||
return TraceProcessingTag{ep, loggedEvent}; | ||
|
@@ -404,7 +404,7 @@ void Trace::endProcessing( | |
); | ||
|
||
if (theConfig()->vt_trace_memory_usage) { | ||
addMemoryEvent(theMemUsage()->getFirstUsage()); | ||
addMemoryEvent(theMemUsage()->getFirstUsage(), time); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
} | ||
|
||
// Final event is same as original with a few .. tweaks. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,24 @@ struct TraceLite { | |
return static_cast<TimeIntegerType>(time * 1e6); | ||
} | ||
|
||
/** | ||
* \brief Get the number of recorded trace events | ||
* | ||
* \return the number of trace events | ||
*/ | ||
std::size_t getNumTraceEvents() const { | ||
return traces_.size(); | ||
} | ||
|
||
/** | ||
* @brief Get the last recorded trace event | ||
* | ||
* @return the last recorded trace event | ||
*/ | ||
const LogType* getLastTraceEvent() const noexcept { | ||
return traces_.empty() ? nullptr : &traces_.back(); | ||
} | ||
|
||
Comment on lines
+255
to
+272
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These functions are mostly used for testing but might be useful in other circumstances |
||
protected: | ||
/** | ||
* \brief Emit a 'stop' trace for previous open event or a '[re]start' trace | ||
|
@@ -349,7 +367,7 @@ struct TraceLite { | |
* | ||
* \return computed bytes used for tracing (lower bound) | ||
*/ | ||
std::size_t getTracesSize() const { | ||
std::size_t getTracesSize() const noexcept { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I driveby-changed this to noexcept because it should be |
||
return traces_.size() * sizeof(Log); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
//@HEADER | ||
// ***************************************************************************** | ||
// | ||
// test_runnable_context_trace.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 [email protected] | ||
// | ||
// ***************************************************************************** | ||
//@HEADER | ||
*/ | ||
|
||
#include <vt/context/runnable_context/trace.h> | ||
|
||
#include "test_parallel_harness.h" | ||
#include "test_helpers.h" | ||
|
||
#if vt_check_enabled(trace_enabled) | ||
|
||
namespace vt { namespace tests { namespace unit { | ||
|
||
using TestRunnableContextTrace = TestParallelHarness; | ||
|
||
struct TraceMsg : ::vt::Message { | ||
}; | ||
|
||
void handler_func( TraceMsg * ) | ||
{} | ||
|
||
TEST_F(TestRunnableContextTrace, runnable_context_trace_test_1) { | ||
if (!theTrace()->checkDynamicRuntimeEnabled()) | ||
GTEST_SKIP() << "trace tests require --vt_trace to be set"; | ||
|
||
auto msg = makeMessage< TraceMsg >(); | ||
|
||
auto handler = auto_registry::makeAutoHandler< TraceMsg, handler_func >(); | ||
|
||
HandlerManager::setHandlerTrace(handler, true); | ||
|
||
// Give some nonsense parameters but Trace shouldn't touch them | ||
auto t = ctx::Trace( msg, /* in_trace_event */ 7, | ||
handler, /* in_from_node */ 3, | ||
5, 9, 3, 2 ); | ||
|
||
// One event for the trace, one for the top open event, third if mem usage tracing is enabled | ||
const int add_num_events = theConfig()->vt_trace_memory_usage ? 3 : 2; | ||
|
||
auto num_events = theTrace()->getNumTraceEvents(); | ||
t.start(TimeType{3}); | ||
EXPECT_EQ(num_events + add_num_events, theTrace()->getNumTraceEvents()); | ||
auto *last_trace = theTrace()->getLastTraceEvent(); | ||
EXPECT_NE(last_trace, nullptr); | ||
EXPECT_EQ(last_trace->type, theConfig()->vt_trace_memory_usage ? trace::eTraceConstants::MemoryUsageCurrent : trace::eTraceConstants::BeginProcessing); | ||
EXPECT_EQ(last_trace->time, TimeType{3}); | ||
|
||
num_events = theTrace()->getNumTraceEvents(); | ||
t.finish(TimeType{7}); | ||
EXPECT_EQ(num_events + add_num_events, theTrace()->getNumTraceEvents()); | ||
last_trace = theTrace()->getLastTraceEvent(); | ||
EXPECT_NE(last_trace, nullptr); | ||
// Counterintuitive, but we restart the open event as the last action | ||
EXPECT_EQ(last_trace->type, trace::eTraceConstants::BeginProcessing); | ||
EXPECT_EQ(last_trace->time, TimeType{7}); // Time should still match though | ||
} | ||
|
||
}}} // end namespace vt::tests::unit | ||
|
||
#endif // vt_check_enabled(trace_enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this so that the recorded events would be consistent (otherwise it uses the current time)