-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][XPTI] Enable PI calls notifications with arguments #3973
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
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ad32ada
Initial argument handling implementation
alexbatashev 81a134e
A bit refined implementation
alexbatashev 9b6d5a1
improved comment
alexbatashev ae4c35d
Minor cleanup
alexbatashev 0d3a580
more cleanup
alexbatashev a5792a2
more stylistic changes
alexbatashev a283c03
more file headers
alexbatashev 08702b5
clang-format
alexbatashev df846f9
remove unused include
alexbatashev 3603bda
fix build
alexbatashev ab7fba6
More clang-format
alexbatashev cb248c1
Add arguments for function end as well
alexbatashev 3118d0c
get rid of piapiid
alexbatashev 571b6c4
clang-format
alexbatashev 71805c1
more clang-format
alexbatashev 3151a63
address more feedback
alexbatashev 224d802
Merge remote-tracking branch 'upstream/sycl' into xpti_pi_args
alexbatashev 9775db1
make CI a bit happier
alexbatashev 22ded67
more review feedback
alexbatashev 0b6a5bb
why local and remote clang-format do it differently?
alexbatashev 7a3cde1
remove tuple_view
alexbatashev 47ee4c4
more feedback
alexbatashev b236f2c
Merge remote-tracking branch 'upstream/sycl' into xpti_pi_args
alexbatashev 57e287f
use template magic instead of changing pi.def
alexbatashev 2e3321b
clang-format
alexbatashev 0b08a09
slight changes to xpti interfaces
alexbatashev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_library(pi_trace SHARED pi_trace.cpp) | ||
target_link_libraries(pi_trace PRIVATE xptifw) | ||
target_include_directories(pi_trace PRIVATE "${XPTI_SOURCE_DIR}/include") | ||
target_include_directories(pi_trace PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/") | ||
target_include_directories(pi_trace PRIVATE "${sycl_inc_dir}") | ||
target_include_directories(pi_trace PRIVATE "${sycl_src_dir}") | ||
|
||
if(UNIX) | ||
target_link_libraries(pi_trace PRIVATE dl) | ||
endif() | ||
|
||
if (XPTI_ENABLE_TBB) | ||
target_link_libraries(pi_trace PRIVATE tbb) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//==----------- pi_trace.cpp.cpp -------------------------------------------==// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// \file pi_trace.cpp | ||
/// A sample XPTI subscriber to demonstrate how to collect PI function call | ||
/// arguments. | ||
|
||
#include "xpti_trace_framework.h" | ||
|
||
#include "pi_arguments_handler.hpp" | ||
|
||
#include <detail/plugin_printers.hpp> | ||
|
||
#include <iostream> | ||
#include <mutex> | ||
#include <string> | ||
#include <string_view> | ||
#include <thread> | ||
|
||
static uint8_t GStreamID = 0; | ||
std::mutex GIOMutex; | ||
|
||
sycl::xpti_helpers::PiArgumentsHandler ArgHandler; | ||
|
||
// The lone callback function we are going to use to demonstrate how to attach | ||
// the collector to the running executable | ||
XPTI_CALLBACK_API void tpCallback(uint16_t trace_type, | ||
xpti::trace_event_data_t *parent, | ||
xpti::trace_event_data_t *event, | ||
uint64_t instance, const void *user_data); | ||
|
||
// Based on the documentation, every subscriber MUST implement the | ||
// xptiTraceInit() and xptiTraceFinish() APIs for their subscriber collector to | ||
// be loaded successfully. | ||
XPTI_CALLBACK_API void xptiTraceInit(unsigned int major_version, | ||
unsigned int minor_version, | ||
const char *version_str, | ||
const char *stream_name) { | ||
if (std::string_view(stream_name) == "sycl.pi.arg") { | ||
GStreamID = xptiRegisterStream(stream_name); | ||
xptiRegisterCallback( | ||
GStreamID, (uint16_t)xpti::trace_point_type_t::function_with_args_begin, | ||
tpCallback); | ||
xptiRegisterCallback( | ||
GStreamID, (uint16_t)xpti::trace_point_type_t::function_with_args_end, | ||
tpCallback); | ||
|
||
#define _PI_API(api) \ | ||
ArgHandler.set##_##api([](auto &&... Args) { \ | ||
std::cout << "---> " << #api << "(" \ | ||
<< "\n"; \ | ||
sycl::detail::pi::printArgs(Args...); \ | ||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::cout << ") ---> "; \ | ||
}); | ||
#include <CL/sycl/detail/pi.def> | ||
#undef _PI_API | ||
} | ||
} | ||
|
||
XPTI_CALLBACK_API void xptiTraceFinish(const char *stream_name) { | ||
// NOP | ||
} | ||
|
||
XPTI_CALLBACK_API void tpCallback(uint16_t TraceType, | ||
xpti::trace_event_data_t *Parent, | ||
xpti::trace_event_data_t *Event, | ||
uint64_t Instance, const void *UserData) { | ||
auto Type = static_cast<xpti::trace_point_type_t>(TraceType); | ||
if (Type == xpti::trace_point_type_t::function_with_args_end) { | ||
// Lock while we print information | ||
std::lock_guard<std::mutex> Lock(GIOMutex); | ||
|
||
const auto *Data = | ||
static_cast<const xpti::function_with_args_t *>(UserData); | ||
|
||
ArgHandler.handle(Data->function_id, Data->args_data); | ||
std::cout << *static_cast<pi_result *>(Data->ret_data) << "\n"; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.