Skip to content

Commit

Permalink
Edits to tighten up the Totalview helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlie-Capps committed Oct 6, 2023
1 parent fe3f967 commit a54ed4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/cmake/thirdparty/SetupTotalview.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if(TOTALVIEW_DIR)
if (TOTALVIEW_INCLUDE_DIRECTORIES)
set(TOTALVIEW_FOUND TRUE)
set(CONDUIT_USE_TOTALVIEW TRUE)
set(CONDUIT_EXCLUDE_TV_DATA_DISPLAY FALSE)
endif()

endif()
8 changes: 5 additions & 3 deletions src/libs/conduit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ set(conduit_sources
)

if(TOTALVIEW_FOUND)
list(APPEND conduit_sources $<$<CONFIG:Debug>:debug/conduit_node_totalview.cpp>)
list(APPEND conduit_sources $<$<CONFIG:Debug>:${TOTALVIEW_SOURCE_DIRECTORY}/tv_data_display.c>)
list(APPEND conduit_sources debug/conduit_node_totalview.cpp)
if(NOT CONDUIT_EXCLUDE_TV_DATA_DISPLAY)
list(APPEND conduit_sources ${TOTALVIEW_SOURCE_DIRECTORY}/tv_data_display.c)
endif()
endif()

#
Expand Down Expand Up @@ -170,7 +172,7 @@ target_include_directories(conduit
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<$<AND:$<BOOL:TOTALVIEW_FOUND>,$<CONFIG:Debug>>:${TOTALVIEW_INCLUDE_DIRECTORIES}>)
$<$<BOOL:TOTALVIEW_FOUND>:${TOTALVIEW_INCLUDE_DIRECTORIES}>)


#################################
Expand Down
34 changes: 6 additions & 28 deletions src/libs/conduit/debug/conduit_node_totalview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,8 @@

static const char * empty_Node_TV_string = "(empty Node)";

const std::string dtype_to_TV_string ( const conduit::DataType dtype );
const std::string dtype_to_TV_string ( const conduit::DataType dtype, const char *hint );
const std::string index_to_TV_string ( int idx );
const std::string dtype_subscript ( const conduit::DataType dtype );

const std::string dtype_to_TV_string ( const conduit::DataType dtype )
{
// We'll see if this works.
const char *hint = dtype.name().c_str();

return dtype_to_TV_string(dtype, hint);
}

const std::string dtype_subscript ( const conduit::DataType dtype )
{
std::stringstream ss;

if (dtype.number_of_elements() > 1)
{
ss << "[" << dtype.number_of_elements() << "]";
}

return ss.str();
}

const std::string dtype_to_TV_string ( const conduit::DataType dtype, const char *hint )
{
Expand All @@ -45,8 +23,6 @@ const std::string dtype_to_TV_string ( const conduit::DataType dtype, const char
ss << index_to_TV_string(dtype.number_of_elements());
}

std::cout << "dtype_to_TV_string: " << ss.str() << std::endl;

return ss.str();
}

Expand All @@ -61,17 +37,18 @@ const std::string index_to_TV_string ( int idx )

int TV_ttf_display_type ( const conduit::Node *n )
{
const std::string type_name = dtype_to_TV_string(n->dtype());

switch(n->dtype().id()) {
case conduit::DataType::EMPTY_ID:
{
TV_ttf_add_row ("data", TV_ttf_type_ascii_string, empty_Node_TV_string);
break;
}
case conduit::DataType::OBJECT_ID:
{
const std::vector<std::string> & child_names = n->child_names();
const conduit::Schema & schema = n->schema();
for (const std::string & name : child_names) {
for (const std::string & name : child_names)
{
size_t cidx = (size_t)schema.child_index(name);
TV_ttf_add_row (name.c_str(), "conduit::Node *", &(n->m_children[cidx]));
}
Expand All @@ -80,7 +57,8 @@ int TV_ttf_display_type ( const conduit::Node *n )
case conduit::DataType::LIST_ID:
{
size_t number_of_children = (size_t)n->number_of_children();
for (size_t cidx = 0; cidx < number_of_children; ++cidx) {
for (size_t cidx = 0; cidx < number_of_children; ++cidx)
{
TV_ttf_add_row (index_to_TV_string(cidx).c_str(), "conduit::Node *", &(n->m_children[cidx]));
}
break;
Expand Down

0 comments on commit a54ed4d

Please sign in to comment.