Skip to content
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ find_package(Vulkan REQUIRED)
set(VIEW_FILES
src/view/src/rocprofvis_appwindow.cpp
src/view/src/rocprofvis_appwindow.h
src/view/src/rocprofvis_compare_files_dialog.cpp
src/view/src/rocprofvis_compare_files_dialog.h
src/view/src/welcome/rocprofvis_welcome_page.cpp
src/view/src/welcome/rocprofvis_welcome_page.h
src/view/src/rocprofvis_annotation_view.cpp
Expand Down
11 changes: 11 additions & 0 deletions src/controller/inc/rocprofvis_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ extern "C"
*/
rocprofvis_controller_t* rocprofvis_controller_alloc(char const* const filename);

/*
* Create a system controller that loads several trace files as one combined trace.
* Used by the Compare feature so two (or more) traces overlay on a single timeline; each
* file's tracks are tagged with its source instance index (see kRPVControllerTrackInstanceId).
* @param filenames Array of trace file paths.
* @param count Number of entries in filenames.
* @returns A valid controller, initialized to load the traces or nullptr on error.
*/
rocprofvis_controller_t* rocprofvis_controller_alloc_compare(char const* const* filenames,
uint64_t count);

/*
* Loads the file into the controller or returns an error.
* @param controller The controller to load into.
Expand Down
6 changes: 6 additions & 0 deletions src/controller/inc/rocprofvis_controller_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ typedef enum rocprofvis_controller_track_properties_t : uint32_t
kRPVControllerTrackNumberOfOperationTypes,
// Event operation type at the given index, see rocprofvis_dm_event_operation_t
kRPVControllerTrackOperationTypeIndexed,
// Source database instance index for track
kRPVControllerTrackInstanceId,
// Source database file index for track
kRPVControllerTrackFileId,
// Track order ranking
kRPVControllerTrackOrderRanking,
__kRPVControllerTrackPropertiesLast
} rocprofvis_controller_track_properties_t;
/* JSON: RPVTrack
Expand Down
43 changes: 43 additions & 0 deletions src/controller/src/rocprofvis_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,49 @@ rocprofvis_controller_t* rocprofvis_controller_alloc(char const* const filename)
}
return controller;
}
rocprofvis_controller_t* rocprofvis_controller_alloc_compare(char const* const* filenames, uint64_t count)
{
rocprofvis_controller_t* controller = nullptr;
if(filenames && count > 0)
{
try
{
std::vector<std::string> files;
files.reserve(count);
bool all_supported = true;
for(uint64_t i = 0; i < count; i++)
{
// Compare combines the inputs through the multinode rocprof engine, so
// every file must be a rocprof trace (reject legacy rocpd / compute / etc).
if(filenames[i] == nullptr ||
rocprofvis_db_identify_type(filenames[i]) != kRocprofSqlite)
{
spdlog::error("Compare: unsupported or missing trace '{}'",
filenames[i] ? filenames[i] : "(null)");
all_supported = false;
break;
}
files.emplace_back(filenames[i]);
}
// Compare always produces a combined system trace.
RocProfVis::Controller::Trace* trace =
all_supported ? new RocProfVis::Controller::SystemTrace(files) : nullptr;
if(trace && trace->Init() == kRocProfVisResultSuccess)
{
controller = (rocprofvis_controller_t*) trace;
}
else
{
delete trace;
}
}
catch(const std::exception& e)
{
spdlog::error("Failed to allocate compare controller: {}", e.what());
}
}
return controller;
}
rocprofvis_result_t rocprofvis_controller_load_async(rocprofvis_controller_t* controller, rocprofvis_controller_future_t* future)
{
rocprofvis_result_t result = kRocProfVisResultInvalidArgument;
Expand Down
53 changes: 34 additions & 19 deletions src/controller/src/system/rocprofvis_controller_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,18 @@ TopologyNode* TopologyNode::GetParent() {
}

TopologyNode* TopologyNode::GetParent(rocprofvis_controller_object_type_t type) {
if (m_parent && m_parent->GetType() == type)
// Walk up until we find the requested ancestor type. Terminate at the root
// (null parent) instead of dereferencing it - combined/compare topologies can
// contain tracks whose ancestor chain does not include the requested type.
if (m_parent == nullptr)
{
return m_parent;
return nullptr;
}
else
if (m_parent->GetType() == type)
{
return m_parent->GetParent(type);
return m_parent;
}
return m_parent->GetParent(type);
}

rocprofvis_result_t
Expand Down Expand Up @@ -265,9 +269,14 @@ TopologyNode::GetObject(rocprofvis_property_t property, uint64_t index,
result = *value ? kRocProfVisResultSuccess : kRocProfVisResultNotLoaded;
break;
case kRPVControllerStreamProcessor:
*value = (rocprofvis_handle_t*)m_children[kRPVControllerTopologyNodeProcessor][0];
{
std::vector<TopologyNode*>& processors =
m_children[kRPVControllerTopologyNodeProcessor];
*value = processors.empty() ? nullptr
: (rocprofvis_handle_t*)processors[0];
result = *value ? kRocProfVisResultSuccess : kRocProfVisResultNotLoaded;
break;
}
case kRPVControllerThreadTrack:
case kRPVControllerQueueTrack:
case kRPVControllerStreamTrack:
Expand Down Expand Up @@ -300,16 +309,19 @@ TopologyNode::GetObject(rocprofvis_property_t property, uint64_t index,
if (kRocProfVisResultSuccess == GetUInt64(kRPVControllerQueueProcess, 0, &queue_pid))
{
TopologyNode* system_node = GetParent(kRPVControllerObjectTypeNode);
for (auto process : system_node->m_children[kRPVControllerTopologyNodeProcess])
if (system_node)
{
uint64_t process_id;
if (kRocProfVisResultSuccess == process->GetUInt64(kRPVControllerProcessId, 0, &process_id))
for (auto process : system_node->m_children[kRPVControllerTopologyNodeProcess])
{
if (process_id == queue_pid)
uint64_t process_id;
if (kRocProfVisResultSuccess == process->GetUInt64(kRPVControllerProcessId, 0, &process_id))
{
*value = (rocprofvis_handle_t*)process;
result = kRocProfVisResultSuccess;
break;
if (process_id == queue_pid)
{
*value = (rocprofvis_handle_t*)process;
result = kRocProfVisResultSuccess;
break;
}
}
}
}
Expand All @@ -324,16 +336,19 @@ TopologyNode::GetObject(rocprofvis_property_t property, uint64_t index,
if (kRocProfVisResultSuccess == GetUInt64(kRPVControllerCounterProcess, 0, &counter_pid))
{
TopologyNode* system_node = GetParent(kRPVControllerObjectTypeNode);
for (auto process : system_node->m_children[kRPVControllerTopologyNodeProcess])
if (system_node)
{
uint64_t process_id;
if (kRocProfVisResultSuccess == process->GetUInt64(kRPVControllerProcessId, 0, &process_id))
for (auto process : system_node->m_children[kRPVControllerTopologyNodeProcess])
{
if (process_id == counter_pid)
uint64_t process_id;
if (kRocProfVisResultSuccess == process->GetUInt64(kRPVControllerProcessId, 0, &process_id))
{
*value = (rocprofvis_handle_t*)process;
result = kRocProfVisResultSuccess;
break;
if (process_id == counter_pid)
{
*value = (rocprofvis_handle_t*)process;
result = kRocProfVisResultSuccess;
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ SystemTrace::SystemTrace(const std::string& filename)

}

SystemTrace::SystemTrace(const std::vector<std::string>& filenames)
: Trace(__kRPVControllerSystemPropertiesFirst, __kRPVControllerSystemPropertiesLast,
filenames.empty() ? std::string() : filenames.front())
, m_files(filenames)
, m_timeline(nullptr)
, m_event_table(nullptr)
, m_sample_table(nullptr)
, m_search_table(nullptr)
, m_summary(nullptr)
, m_mem_mgmt(nullptr)
{

}

rocprofvis_result_t SystemTrace::Init()
{
rocprofvis_result_t result = kRocProfVisResultUnknownError;
Expand Down Expand Up @@ -134,8 +148,22 @@ rocprofvis_result_t SystemTrace::LoadRocpd(Future* future) {
m_dm_handle = rocprofvis_dm_create_trace();
if(nullptr != m_dm_handle)
{
rocprofvis_dm_database_t db =
rocprofvis_db_open_database(m_trace_file.c_str(), kAutodetect);
rocprofvis_dm_database_t db = nullptr;
if(m_files.size() > 1)
{
std::vector<const char*> file_ptrs;
file_ptrs.reserve(m_files.size());
for(const std::string& file : m_files)
{
file_ptrs.push_back(file.c_str());
}
db = rocprofvis_db_open_database_multi(file_ptrs.data(),
file_ptrs.size());
}
else
{
db = rocprofvis_db_open_database(m_trace_file.c_str(), kAutodetect);
}
if(nullptr != db && kRocProfVisDmResultSuccess ==
rocprofvis_dm_bind_trace_to_database(m_dm_handle, db))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class SystemTrace : public Trace
public:
SystemTrace(const std::string& filename);

// Compare/combine: open several files as one trace. Each file becomes a source
// instance whose index is exposed via kRPVControllerTrackInstanceId.
SystemTrace(const std::vector<std::string>& filenames);

virtual ~SystemTrace();

virtual rocprofvis_result_t Init() override;
Expand Down Expand Up @@ -83,6 +87,7 @@ class SystemTrace : public Trace
std::mutex& GetTableMutex(rocprofvis_dm_table_use_case_enum_t use_case);

private:
std::vector<std::string> m_files; // >1 entry => combined/compare load
std::vector<Track*> m_tracks;
std::vector<Node*> m_nodes;
Timeline* m_timeline;
Expand Down
22 changes: 22 additions & 0 deletions src/controller/src/system/rocprofvis_controller_track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,28 @@ rocprofvis_result_t Track::GetUInt64(rocprofvis_property_t property, uint64_t in
}
break;
}
case kRPVControllerTrackInstanceId:
{
*value = rocprofvis_dm_get_property_as_uint64(
m_dm_handle, kRPVDMTrackInstanceIdUInt64, 0);
result = kRocProfVisResultSuccess;
break;
}
case kRPVControllerTrackFileId:
{
*value = rocprofvis_dm_get_property_as_uint64(
m_dm_handle, kRPVDMTrackFileIdUInt64, 0);
result = kRocProfVisResultSuccess;
break;
}
case kRPVControllerTrackOrderRanking:
{
*value = rocprofvis_dm_get_property_as_uint64(
m_dm_handle, kRPVDMTrackOrderRankingUInt64, 0);
result = kRocProfVisResultSuccess;
break;
}

default:
{
result = UnhandledProperty(property);
Expand Down
18 changes: 17 additions & 1 deletion src/model/inc/rocprofvis_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,25 @@ rocprofvis_db_type_t rocprofvis_db_identify_type(rocprofvis_db_filename_t filena
*
***************************************************************************************************/
rocprofvis_dm_database_t rocprofvis_db_open_database(
rocprofvis_db_filename_t,
rocprofvis_db_filename_t,
rocprofvis_db_type_t);

/****************************************************************************************************
* @brief Opens several trace files as a single combined (multinode) database.
*
* Loads the supplied files into one database without requiring a multinode manifest on
* disk. Each file becomes a database instance whose instance index (0, 1, ...) matches
* its position in the array. Used by the Compare feature.
*
* @param filenames array of database file paths
* @param count number of entries in filenames
* @return handler to database object
*
***************************************************************************************************/
rocprofvis_dm_database_t rocprofvis_db_open_database_multi(
rocprofvis_db_filename_t const*,
rocprofvis_dm_size_t);

/****************************************************************************************************
* @brief Calculates size of memory used by database object
*
Expand Down
6 changes: 5 additions & 1 deletion src/model/inc/rocprofvis_interface_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ typedef enum rocprofvis_dm_track_property_t {
// Track process ID (PID or Agent ID)
kRPVDMTrackProcessIdUInt64,
// Track process ID (TID or Queue ID)
kRPVDMTrackSubProcessIdUInt64
kRPVDMTrackSubProcessIdUInt64,
// Track File ID
kRPVDMTrackFileIdUInt64,
// Track Order Ranking ID
kRPVDMTrackOrderRankingUInt64,
} rocprofvis_dm_track_property_t;

// Slice properties
Expand Down
47 changes: 47 additions & 0 deletions src/model/src/common/rocprofvis_c_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,53 @@
}
}

/****************************************************************************************************
* @brief Opens several trace files as a single combined (multinode) database.
*
* Skips the manifest-based detection in rocprofvis_db_open_database and constructs a
* multinode rocprof database directly from the provided file list. Each file becomes a
* database instance whose instance index matches its position in the array.
*
* @param filenames array of database file paths
* @param count number of entries in filenames
*
***************************************************************************************************/
rocprofvis_dm_database_t rocprofvis_db_open_database_multi(
rocprofvis_db_filename_t const* filenames,
rocprofvis_dm_size_t count){
PROFILE;
if (filenames == nullptr || count == 0)
{
spdlog::debug("No database files provided!");
return nullptr;
}
std::vector<std::string> files;
files.reserve(count);
for (rocprofvis_dm_size_t i = 0; i < count; i++)
{
ROCPROFVIS_ASSERT_MSG_RETURN(filenames[i],
RocProfVis::DataModel::ERROR_DATABASE_CANNOT_BE_NULL,
nullptr);
files.push_back(filenames[i]);
}
try {
RocProfVis::DataModel::Database* db =
new RocProfVis::DataModel::RocprofDatabase(files.front().c_str(), files);
if (kRocProfVisDmResultSuccess == db->Open()) {
return db;
}

Check warning

Code scanning / CodeQL

Catching by value Warning

This should catch a exception by (const) reference rather than by value.
Comment thread
Sajeeth-Wimalasuriyan marked this conversation as resolved.
Dismissed
else {
ROCPROFVIS_ASSERT_ALWAYS_MSG_RETURN("Error! Failed to open combined database!",
nullptr);
}
}
catch (std::exception ex)
{
ROCPROFVIS_ASSERT_ALWAYS_MSG_RETURN(
RocProfVis::DataModel::ERROR_MEMORY_ALLOCATION_FAILURE, nullptr);
}
}

/****************************************************************************************************
* @brief Calculates size of memory used by database object
*
Expand Down
3 changes: 2 additions & 1 deletion src/model/src/common/rocprofvis_common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ typedef struct {
std::map<uint32_t,std::pair<uint32_t,double>> histogram;
rocprofvis_dm_op_t op;
std::set<uint32_t> load_id;

//track order ranking
uint32_t order_id;
} rocprofvis_dm_track_params_t;

// rocprofvis_dm_trace_params_t contains trace parameters and shared between data model and database. Physically located in trace object and referenced by a pointer in binding structure.
Expand Down
Loading
Loading