Skip to content

Commit

Permalink
wire init of new logging, keep old marcos wired
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrush committed Dec 9, 2024
1 parent f11cdd3 commit 37b805f
Show file tree
Hide file tree
Showing 21 changed files with 233 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/libs/ascent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ set(ascent_headers
# utils
utils/ascent_actions_utils.hpp
utils/ascent_data_logger.hpp
utils/ascent_logging.hpp
utils/ascent_logging_old.hpp
utils/ascent_block_timer.hpp
utils/ascent_mpi_utils.hpp
utils/ascent_string_utils.hpp
Expand Down Expand Up @@ -237,7 +237,7 @@ set(ascent_sources
utils/ascent_actions_utils.cpp
utils/ascent_data_logger.cpp
utils/ascent_block_timer.cpp
utils/ascent_logging.cpp
utils/ascent_logging_old.cpp
utils/ascent_mpi_utils.cpp
utils/ascent_string_utils.cpp
utils/ascent_web_interface.cpp
Expand Down
151 changes: 143 additions & 8 deletions src/libs/ascent/ascent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <ascent_empty_runtime.hpp>
#include <ascent_flow_runtime.hpp>
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>
#include <runtimes/ascent_main_runtime.hpp>
#include <utils/ascent_string_utils.hpp>
#include <flow.hpp>
Expand All @@ -36,6 +38,38 @@ using namespace conduit;
namespace ascent
{

//-----------------------------------------------------------------------------
namespace detail
{

//-----------------------------------------------------------------------------
int
ParRank(int comm_id)
{
int rank = 0;

#if defined(ASCENT_MPI_ENABLED)
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);
MPI_Comm_rank(mpi_comm, &rank);
#endif

return rank;
}

//-----------------------------------------------------------------------------
int
ParSize(int comm_id)
{
int comm_size=1;

#if defined(ASCENT_MPI_ENABLED)
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);
MPI_Comm_size(mpi_comm, &comm_size);
#endif

return comm_size;
}

//-----------------------------------------------------------------------------
void
quiet_handler(const std::string &,
Expand All @@ -44,6 +78,10 @@ quiet_handler(const std::string &,
{
}

}



//-----------------------------------------------------------------------------
Ascent::Ascent()
: m_runtime(NULL),
Expand Down Expand Up @@ -187,6 +225,9 @@ Ascent::open(const conduit::Node &options)
comm_id = options["mpi_comm"].to_int32();
}

int par_rank = detail::ParRank(comm_id);
int par_size = detail::ParSize(comm_id);

CheckForSettingsFile(opts_file,
processed_opts,
true,
Expand All @@ -201,20 +242,114 @@ Ascent::open(const conduit::Node &options)
m_options["mpi_comm"] = options["mpi_comm"];
}

if(m_options.has_path("messages") &&
m_options["messages"].dtype().is_string() )
Node echo_opts;
echo_opts["echo_threshold"] = "info";
echo_opts["ranks"] = "root";

// messages echoed to std out
if(m_options.has_path("messages"))
{
if(m_options["messages"].dtype().is_string())
{
std::string msgs_opt = m_options["messages"].as_string();
if( msgs_opt == "verbose")
{
m_verbose_msgs = true;
echo_opts["echo_threshold"] = "all";
}
else if(msgs_opt == "quiet")
{
m_verbose_msgs = false;
echo_opts["echo_threshold"] = "error";
}
}
else if(m_options["messages"].dtype().is_object())
{
const Node &msg_ops = m_options["messages"];
echo_opts.update(msg_ops);
if(msg_ops.has_child("echo_threshold") &&
msg_ops["echo_threshold"].dtype().is_string() )
{
std::string echo_thresh = msg_ops["echo_threshold"].as_string();
if(echo_thresh == "none" ||
echo_thresh == "error" ||
echo_thresh == "warn" )
{
m_verbose_msgs = false;
}
else
{
m_verbose_msgs = true;
}
}
}
}

ascent::Logger &logger = ascent::Logger::instance();

// setup echo
logger.set_echo_threshold(echo_opts["echo_threshold"].as_string());

// control for mpi case
// if ranks == "root"
// rank 0 is what is specified, echo_threshold = "none" for all others
// if ranks == "all"
// echo_threshold = specified option used for all ranks (alreay handled above)
std::string log_ranks_str = echo_opts["ranks"].as_string();

if(log_ranks_str == "root")
{
if(par_rank != 0)
{
logger.set_echo_threshold(ascent::Logger::NONE);
}
}

// logging options
//
// logging: true
//
// logging:
// file_pattern: zzzz
// log_threshold: info
//

Node logging_opts;
logging_opts["enabled"] = 0;
#if defined(ASCENT_MPI_ENABLED)
logging_opts["file_pattern"] = "ascent_log_output.yaml";
#else
logging_opts["file_pattern"] = "ascent_log_output_rank{rank:05d}.yaml";
#endif
logging_opts["log_threshold"] = "info";

if(m_options.has_path("logging"))
{
std::string msgs_opt = m_options["messages"].as_string();
if( msgs_opt == "verbose")
if(m_options["logging"].dtype().is_string() &&
m_options["logging"].as_string() == "true")
{
m_verbose_msgs = true;
logging_opts["enabled"] = 1;
}
else if(msgs_opt == "quiet")
else if(m_options["logging"].dtype().is_object())
{
m_verbose_msgs = false;
logging_opts["enabled"] = 1;
// pull over options
logging_opts.update(m_options["logging"]);
}
}

if(logging_opts["enabled"].to_int() == 1)
{
std::string file_pattern = logging_opts["file_pattern"].as_string();
#if defined(ASCENT_MPI_ENABLED)
ASCENT_LOG_OPEN( file_pattern ) // serial
#else
ASCENT_LOG_OPEN_RANK( file_pattern, par_rank ) // mpi par
#endif
}


// exception controls
if(m_options.has_path("exceptions") &&
m_options["exceptions"].dtype().is_string() )
{
Expand Down Expand Up @@ -300,7 +435,7 @@ Ascent::open(const conduit::Node &options)
// make sure to do this after.
if(!m_verbose_msgs)
{
conduit::utils::set_info_handler(quiet_handler);
conduit::utils::set_info_handler(detail::quiet_handler);
}

set_status("Ascent::open completed");
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/ascent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>
#include <ascent_block_timer.hpp>

#include <conduit.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/hola/ascent_hola.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// ascent includes
//-----------------------------------------------------------------------------
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

#include <fstream>

Expand Down
9 changes: 9 additions & 0 deletions src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ AscentRuntime::~AscentRuntime()
void
AscentRuntime::Initialize(const conduit::Node &options)
{

// handle logging first
#if defined(ASCENT_MPI_ENABLED)

#else

#endif


#if ASCENT_MPI_ENABLED
if(!options.has_child("mpi_comm") ||
!options["mpi_comm"].dtype().is_integer())
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/ascent_mfem_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ascent_mfem_data_adapter.hpp"

#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

// standard lib includes
#include <iostream>
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/ascent_transmogrifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "ascent_mfem_data_adapter.hpp"
#endif
#include "ascent_logging.hpp"
#include "ascent_logging_old.hpp"
#include <conduit_blueprint.hpp>
#include <algorithm>

Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/ascent_vtkh_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ascent_vtkh_collection.hpp"
#include "ascent_mpi_utils.hpp"
#include "ascent_logging.hpp"
#include "ascent_logging_old.hpp"

#if defined(ASCENT_MPI_ENABLED)
#include <mpi.h>
Expand Down
3 changes: 3 additions & 0 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <mpi.h>
#endif

#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

// VTKm includes
#define VTKM_USE_DOUBLE_PRECISION
#include <vtkm/cont/DataSet.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ascent_memory_manager.hpp"

#include "ascent_logging.hpp"
#include "ascent_logging_old.hpp"

#if defined(ASCENT_UMPIRE_ENABLED)
#include <umpire/Umpire.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <conduit.hpp>
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

//-----------------------------------------------------------------------------
// -- begin ascent:: --
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ascent_execution_manager.hpp"
#include <ascent_config.h>
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

namespace ascent
{
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/expressions/ascent_jit_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "ascent_jit_array.hpp"
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

//-----------------------------------------------------------------------------
// -- begin ascent:: --
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/expressions/ascent_jit_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "ascent_jit_field.hpp"
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

//-----------------------------------------------------------------------------
// -- begin ascent:: --
Expand Down
1 change: 1 addition & 0 deletions src/libs/ascent/runtimes/expressions/ascent_jit_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "ascent_jit_math.hpp"
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>

//-----------------------------------------------------------------------------
// -- begin ascent:: --
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ascent_memory_manager.hpp"
#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>
#include <ascent_config.h>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ascent_runtime_conduit_to_vtkm_parsing.hpp"

#include <ascent_logging.hpp>
#include <ascent_logging_old.hpp>
using namespace conduit;

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -252,6 +253,7 @@ parse_color_table(const conduit::Node &color_table_node)
const Node &peg = itr.next();
if(!peg.has_child("position"))
{
// FIXME: This should be an error
ASCENT_WARN("Color map control point must have a position");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

//-----------------------------------------------------------------------------
///
/// file: ascent_logging.cpp
/// file: ascent_logging_old.cpp
///
//-----------------------------------------------------------------------------

#include "ascent_logging.hpp"
#include "ascent_logging_old.hpp"

//-----------------------------------------------------------------------------
// -- begin ascent:: --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/// file: ascent_logging.hpp
///
//-----------------------------------------------------------------------------
#ifndef ASCENT_LOGGING_HPP
#define ASCENT_LOGGING_HPP
#ifndef ASCENT_LOGGING_OLD_HPP
#define ASCENT_LOGGING_OLD_HPP

#include <conduit.hpp>
#include <ascent_exports.h>
Expand Down
Loading

0 comments on commit 37b805f

Please sign in to comment.