Unverified Commit d6be21dc authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Distributed debug print cleanup (#4403)

* remove code

* Cleanup

* cleanup

* cleanup

* Fix build error
parent 7848f18d
......@@ -60,7 +60,6 @@ namespace ngraph
virtual const std::string& get_name() const = 0;
virtual int get_size() = 0;
virtual int get_rank() = 0;
virtual void log_print(const std::string& timestamp, const std::vector<char>& buf) = 0;
virtual void all_reduce(void* in,
void* out,
......
......@@ -35,12 +35,6 @@ int ngraph::distributed::Null::get_rank()
return 0;
}
void ngraph::distributed::Null::log_print(const std::string& timestamp,
const std::vector<char>& buf)
{
std::cout << timestamp << ": " << std::string(buf.data()) << "\n";
}
void ngraph::distributed::Null::all_reduce(void*, void*, element::Type_t, reduction::Type, size_t)
{
throw ngraph_error("Distributed Library not supported/mentioned");
......
......@@ -30,7 +30,6 @@ namespace ngraph
const std::string& get_name() const override;
int get_size() override;
int get_rank() override;
void log_print(const std::string& timestamp, const std::vector<char>& buf) override;
void all_reduce(void* in,
void* out,
element::Type_t element_type,
......
......@@ -56,7 +56,6 @@ int main(int argc, char** argv)
int rc = RUN_ALL_TESTS();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - start);
NGRAPH_DEBUG_PRINT("[MAIN] Tests finished: Time: %d ms Exit code: %d", elapsed.count(), rc);
return rc;
}
......@@ -70,65 +70,3 @@ LogHelper::~LogHelper()
}
// Logger::log_item(m_stream.str());
}
#if defined(__linux) || defined(__APPLE__)
std::string ngraph::get_timestamp()
{
// get current time
auto now = std::chrono::system_clock::now();
// get number of nanoseconds for the current second
// (remainder after division into seconds)
auto ns =
std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()) % 1000000;
// convert to std::time_t in order to convert to std::tm (broken time)
auto timer = std::chrono::system_clock::to_time_t(now);
// convert to broken time
char buffer[256];
buffer[0] = 0;
std::tm* bt = std::localtime(&timer);
if (bt)
{
strftime(buffer, sizeof(buffer), "%H:%M:%S", bt);
}
std::ostringstream timestamp;
timestamp << buffer;
timestamp << '.' << std::setfill('0') << std::setw(3) << ns.count();
return timestamp.str();
}
void ngraph::LogPrintf(const char* fmt, ...)
{
va_list args1;
va_start(args1, fmt);
va_list args2;
va_copy(args2, args1);
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
std::vector<char> buf(1 + std::vsnprintf(nullptr, 0, fmt, args1));
va_end(args1);
std::vsnprintf(buf.data(), buf.size(), fmt, args2);
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
va_end(args2);
get_distributed_interface()->log_print(get_timestamp(), buf);
}
// This function will be executed only once during startup (loading of the DSO)
static bool CheckLoggingLevel()
{
if (getenv_bool("NGRAPH_DISABLE_LOGGING"))
{
return true;
}
return false;
}
bool ngraph::DISABLE_LOGGING = CheckLoggingLevel();
#endif
......@@ -169,21 +169,4 @@ namespace ngraph
#define NGRAPH_DEBUG \
::ngraph::NullLogger {}
#endif
#if defined(__linux) || defined(__APPLE__)
std::string get_timestamp();
void LogPrintf(const char* fmt, ...);
extern bool DISABLE_LOGGING;
#define NGRAPH_DEBUG_PRINT(fmt, ...) \
do \
{ \
if (!ngraph::DISABLE_LOGGING) \
{ \
ngraph::LogPrintf(fmt, __VA_ARGS__); \
} \
} while (0)
#else
#define NGRAPH_DEBUG_PRINT(fmt, ...)
#endif
}
......@@ -42,18 +42,13 @@ namespace ngraph
auto reduce_type = allreduce->get_reduce_type();
auto external_function_name = external_function->get_function_name();
NGRAPH_DEBUG_PRINT(
"AllReduce Queued[%d]: Function: %s Node: %s %s Size: "
"%d",
call_seq,
external_function_name.c_str(),
node->get_name().c_str(),
// if provenance_tags is set in nGraph once and only once, it will print the tag
// name otherwise, it will print the get_friendly_name
node->get_provenance_tags().size() == 1
? (*(node->get_provenance_tags()).begin()).c_str()
: node->get_friendly_name().c_str(),
count);
NGRAPH_DEBUG << "AllReduce Queued[" << call_seq
<< "]: Function: " << external_function_name
<< " Node: " << node->get_name() << " "
<< (node->get_provenance_tags().size() == 1
? (*(node->get_provenance_tags()).begin())
: node->get_friendly_name())
<< " Size: " << count;
auto functor =
[&, count, reduce_type, data_type, arg_buffer_index, out_buffer_index](
......
......@@ -63,11 +63,7 @@ int main(int argc, char** argv)
ngraph::runtime::ngmlir::initializeNGraphMLIR();
#endif
auto start = std::chrono::system_clock::now();
int rc = RUN_ALL_TESTS();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - start);
NGRAPH_DEBUG_PRINT("[MAIN] Tests finished: Time: %d ms Exit code: %d", elapsed.count(), rc);
return rc;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment