Skip to content

Commit

Permalink
[XPTI] Rework 64-bit universal ID to use a tuple of three 64-bit comp…
Browse files Browse the repository at this point in the history
…onents (#4318)

With the requirement of supporting 64-bit hash generation from code location+line number or kernel name + back trace + address or kernel name + address, the universal ID manages three 64-bit values representing each of these scenarios to generate a hash. Updated the unit tests and performance tests to use the new data structure and hash generation algorithm, including a simulation of 10000-1000000 million trace points that result in no collision.

Signed-off-by: Vasanth Tovinkere <vasanth.tovinkere@intel.com>
  • Loading branch information
tovinkere authored Aug 15, 2021
1 parent 2de0f92 commit a201984
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 327 deletions.
236 changes: 159 additions & 77 deletions xpti/include/xpti_data_types.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion xpti/include/xpti_trace_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ xptiMakeEvent(const char *name, xpti::payload_t *payload, uint16_t event,
/// performed
/// @return The trace event with unique ID equal to uid. If the unique ID is not
/// present, then nullptr will be returned.
XPTI_EXPORT_API const xpti::trace_event_data_t *xptiFindEvent(int64_t uid);
XPTI_EXPORT_API const xpti::trace_event_data_t *xptiFindEvent(uint64_t uid);

/// @brief Retrieves the payload information associated with an event
/// @details An event encapsulates the unique payload it represents and this
Expand Down
2 changes: 1 addition & 1 deletion xpti/src/xpti_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ xptiMakeEvent(const char *name, xpti::payload_t *payload, uint16_t event,
return nullptr;
}

XPTI_EXPORT_API const xpti::trace_event_data_t *xptiFindEvent(int64_t uid) {
XPTI_EXPORT_API const xpti::trace_event_data_t *xptiFindEvent(uint64_t uid) {
if (xpti::g_loader.noErrors()) {
auto f = xpti::g_loader.functionByIndex(XPTI_FIND_EVENT);
if (f) {
Expand Down
4 changes: 2 additions & 2 deletions xptifw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add_subdirectory(src)
# TODO enable samples and tests back once build problems are resolved.
# Currently builds for unit tests and samples fail mostly with dllimport/dllexport
# mismatch problems:
# syclpi_collector.cpp(32): error C2491: 'xptiTraceInit': definition of dllimport function not allowed
# syclpi_collector.cpp(32): error C2491: 'xptiTraceInit': definition of dllimport function not allowed
if (0)
add_subdirectory(unit_test)
add_subdirectory(samples/basic_collector)
Expand All @@ -52,6 +52,6 @@ endif()

# The tests in basic_test are written using TBB, so these tests are enabled
# only if TBB has been enabled.
if (XPTI_ENABLE_TBB)
if (0)
add_subdirectory(basic_test)
endif()
2 changes: 1 addition & 1 deletion xptifw/basic_test/performance_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void TestPerformance::runDataStructureTestsThreads(
}
ModelRow[(int)DSColumns::STInsertLookup] = ElapsedTime;

std::vector<int64_t> UIds;
std::vector<uint64_t> UIds;
std::vector<xpti::trace_event_data_t *> Events;
UIds.resize(MTracepoints);
Events.resize(MTracepoints);
Expand Down
2 changes: 1 addition & 1 deletion xptifw/basic_test/semantic_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void TestCorrectness::runTracepointTestThreads(int RunNo, int NumThreads,

if (!NumThreads) {
std::vector<xpti::payload_t *> Payloads;
std::vector<int64_t> UIds;
std::vector<uint64_t> UIds;
std::vector<xpti::trace_event_data_t *> Events;
Payloads.resize(TracepointCount);
UIds.resize(TracepointCount);
Expand Down
4 changes: 2 additions & 2 deletions xptifw/samples/basic_collector/basic_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ XPTI_CALLBACK_API void tpCallback(uint16_t TraceType,
uint32_t CPU = GThreadIDEnum.enumID(TID);
std::string Name;

if (Payload->name_sid != xpti::invalid_id) {
if (Payload->name_sid() != xpti::invalid_id) {
Name = truncate(Payload->name);
} else {
Name = "<unknown>";
Expand All @@ -144,7 +144,7 @@ XPTI_CALLBACK_API void tpCallback(uint16_t TraceType,
xptiLookupString(Item.second));
}

if (Payload->source_file_sid != xpti::invalid_id && Payload->line_no > 0) {
if (Payload->source_file_sid() != xpti::invalid_id && Payload->line_no > 0) {
printf("---[Source file:line no] %s:%d\n", Payload->source_file,
Payload->line_no);
}
Expand Down
Loading

0 comments on commit a201984

Please sign in to comment.