Skip to content

[XPTI] Refactoring - Removing TBB dependency #10187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions xpti/include/xpti/xpti_trace_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ xptiQueryMetadata(xpti::trace_event_data_t *e);
/// @return bool that indicates whether it is enabled or not
XPTI_EXPORT_API bool xptiTraceEnabled();

/// @brief Check if tracing is enabled for a stream or stream and trace type
/// @details If the tracing is enabled by the XPTI_TRACE_ENABLE=1
/// environment variable, a valid dispatcher is available for dispatching
/// calls to the framework and if there exists one or more valid subscribers
/// subscribing to a stream or a stream and trace type in that stream, then
/// this method will return TRUE
/// @param stream Stream ID
/// @param ttype The trace type within the stream
/// @return bool that indicates whether it is enabled or not
XPTI_EXPORT_API bool xptiCheckTraceEnabled(uint16_t stream, uint16_t ttype = 0);

/// @brief Resets internal state
/// @details This method is currently ONLY used by the tests and is NOT
/// recommended for use in the instrumentation of applications or runtimes.
Expand Down Expand Up @@ -511,5 +522,6 @@ typedef xpti::result_t (*xpti_add_metadata_t)(xpti::trace_event_data_t *,
const char *, xpti::object_id_t);
typedef xpti::metadata_t *(*xpti_query_metadata_t)(xpti::trace_event_data_t *);
typedef bool (*xpti_trace_enabled_t)();
typedef bool (*xpti_check_trace_enabled_t)(uint16_t stream, uint16_t ttype);
typedef void (*xpti_force_set_trace_enabled_t)(bool);
}
13 changes: 13 additions & 0 deletions xpti/src/xpti_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum functions_t {
XPTI_REGISTER_PAYLOAD,
XPTI_QUERY_PAYLOAD_BY_UID,
XPTI_FORCE_SET_TRACE_ENABLED,
XPTI_CHECK_TRACE_ENABLED,

// All additional functions need to appear before
// the XPTI_FW_API_COUNT enum
Expand Down Expand Up @@ -76,6 +77,7 @@ class ProxyLoader {
{XPTI_ADD_METADATA, "xptiAddMetadata"},
{XPTI_QUERY_METADATA, "xptiQueryMetadata"},
{XPTI_TRACE_ENABLED, "xptiTraceEnabled"},
{XPTI_CHECK_TRACE_ENABLED, "xptiCheckTraceEnabled"},
{XPTI_FORCE_SET_TRACE_ENABLED, "xptiForceSetTraceEnabled"}};

public:
Expand Down Expand Up @@ -428,6 +430,17 @@ XPTI_EXPORT_API bool xptiTraceEnabled() {
return false;
}

XPTI_EXPORT_API bool xptiCheckTraceEnabled(uint16_t stream, uint16_t ttype) {
if (xpti::ProxyLoader::instance().noErrors()) {
auto f =
xpti::ProxyLoader::instance().functionByIndex(XPTI_CHECK_TRACE_ENABLED);
if (f) {
return (*(xpti_check_trace_enabled_t)f)(stream, ttype);
}
}
return false;
}

XPTI_EXPORT_API void xptiTraceTryToEnable() {
xpti::ProxyLoader::instance().tryToEnable();
}
Expand Down
7 changes: 1 addition & 6 deletions xptifw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,9 @@ endif()
if (XPTI_BUILD_SAMPLES)
add_subdirectory(samples/basic_collector)
add_subdirectory(samples/syclpi_collector)
add_subdirectory(basic_test)
endif()

if (XPTI_BUILD_BENCHMARK)
add_subdirectory(benchmark)
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)
add_subdirectory(basic_test)
endif()
5 changes: 1 addition & 4 deletions xptifw/basic_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ add_executable(XPTIFWBasicTests ${SOURCES})
target_link_libraries(XPTIFWBasicTests PRIVATE xptifw ${CMAKE_DL_LIBS})

if (UNIX)
target_compile_definitions(XPTIFWBasicTests PRIVATE -gline-tables-only -O3)
add_compile_options(-gline-tables-only -O3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please clarify what this change stands for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line used to cause CMake errors and has been changed to ensure we have -O3 for the basic performance tests

endif()

# There's a XPTI_ENABLE_TBB guard in xptifw/CMakeLists.txt
target_link_libraries(XPTIFWBasicTests PRIVATE tbb)

# Override default LLVM bin location
set_target_properties(XPTIFWBasicTests
PROPERTIES
Expand Down
11 changes: 8 additions & 3 deletions xptifw/basic_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ fall under two categories:

1. Semantic tests: These tests perform correctness checks on the API call to
ensure the right data is being retrieved. The semantic tests are categorized
into string table tests, trace point tests and notification tests.
into string table tests, trace point tests and notification tests. These tests
are run serially as well as using threads. For multi-threaded run, the tests
use std::for_each with std::execution::par execution policy.

2. Performance tests: These test attempt to capture the average cost of various
operations that are a part of creating trace points in applications. The tests
are categorized into data structure tests and instrumentation tests.
are categorized into data structure tests and instrumentation tests. These tests
are measured serially as well as by scaling the number of threads.

To support the multithreaded tests, the tests rely on a thread pool [implementation](https://github.com/bshoshany/thread-pool.git). Copyright (c) 2023 [Barak Shoshany](https://baraksh.com/). Licensed under the [MIT license](external/LICENSE.txt).

For more detail on the framework, the tests that are provided and their usage,
please consult the [XPTI Framework library documentation](doc/XPTI_Framework.md).
please consult the [XPTI Framework library documentation](doc/XPTI_Framework.md).
1 change: 1 addition & 0 deletions xptifw/basic_test/cl_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class CommandLineParser {
}
return MEmptyString;
}
return MEmptyString;
}

private:
Expand Down
Loading