Skip to content

Revert "[SYCL][XPTI] Enable PI calls notifications with arguments" #4144

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 1 commit into from
Jul 19, 2021
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
3 changes: 0 additions & 3 deletions sycl/include/CL/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace detail {
constexpr const char *SYCL_STREAM_NAME = "sycl";
// Stream name being used for traces generated from the SYCL plugin layer
constexpr const char *SYCL_PICALL_STREAM_NAME = "sycl.pi";
// Stream name being used for traces generated from PI calls. This stream
// contains information about function arguments.
constexpr const char *SYCL_PIDEBUGCALL_STREAM_NAME = "sycl.pi.debug";
// Data structure that captures the user code location information using the
// builtin capabilities of the compiler
struct code_location {
Expand Down
4 changes: 0 additions & 4 deletions sycl/include/CL/sycl/detail/pi.def
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
// This is for convinience of doing same thing for all interfaces, e.g.
// declare, define, initialize.
//
// This list is used to define PiApiKind enum, which is part of external
// interface. To avoid ABI breakage, please, add new entries to the end of the
// list.
//
// Platform
_PI_API(piPlatformsGet)
_PI_API(piPlatformGetInfo)
Expand Down
22 changes: 0 additions & 22 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,6 @@ uint64_t emitFunctionBeginTrace(const char *FName);
/// \param FName The name of the PI API call
void emitFunctionEndTrace(uint64_t CorrelationID, const char *FName);

/// Notifies XPTI subscribers about PI function calls and packs call arguments.
///
/// \param FuncID is the API hash ID from PiApiID type trait.
/// \param FName The name of the PI API call.
/// \param ArgsData is a pointer to packed function call arguments.
uint64_t emitFunctionWithArgsBeginTrace(uint32_t FuncID, const char *FName,
unsigned char *ArgsData);

/// Notifies XPTI subscribers about PI function call result.
///
/// \param CorrelationID The correlation ID for the API call generated by the
/// emitFunctionWithArgsBeginTrace() call.
/// \param FuncID is the API hash ID from PiApiID type trait.
/// \param FName The name of the PI API call.
/// \param ArgsData is a pointer to packed function call arguments.
/// \param Result is function call result value.
void emitFunctionWithArgsEndTrace(uint64_t CorrelationID, uint32_t FuncID,
const char *FName, unsigned char *ArgsData,
pi_result Result);

// A wrapper for passing around byte array properties
class ByteArray {
public:
Expand Down Expand Up @@ -415,5 +395,3 @@ namespace RT = cl::sycl::detail::pi;

} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)

#undef _PI_API
7 changes: 0 additions & 7 deletions sycl/include/CL/sycl/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <CL/sycl/detail/type_list.hpp>

#include <array>
#include <tuple>
#include <type_traits>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down Expand Up @@ -351,12 +350,6 @@ template <access::address_space AS, class DataT>
using const_if_const_AS = DataT;
#endif

template <typename T> struct function_traits {};

template <typename Ret, typename... Args> struct function_traits<Ret(Args...)> {
using ret_type = Ret;
using args_type = std::tuple<Args...>;
};

} // namespace detail
} // namespace sycl
Expand Down
46 changes: 0 additions & 46 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ namespace detail {
xpti_td *GSYCLGraphEvent = nullptr;
/// Event to be used by PI layer related activities
xpti_td *GPICallEvent = nullptr;
/// Event to be used by PI layer calls with arguments
xpti_td *GPIArgCallEvent = nullptr;
/// Constants being used as placeholder until one is able to reliably get the
/// version of the SYCL runtime
constexpr uint32_t GMajVer = 1;
Expand Down Expand Up @@ -137,42 +135,6 @@ void emitFunctionEndTrace(uint64_t CorrelationID, const char *FName) {
#endif // XPTI_ENABLE_INSTRUMENTATION
}

uint64_t emitFunctionWithArgsBeginTrace(uint32_t FuncID, const char *FuncName,
unsigned char *ArgsData) {
uint64_t CorrelationID = 0;
#ifdef XPTI_ENABLE_INSTRUMENTATION
if (xptiTraceEnabled()) {
uint8_t StreamID = xptiRegisterStream(SYCL_PIDEBUGCALL_STREAM_NAME);
CorrelationID = xptiGetUniqueId();

xpti::function_with_args_t Payload{FuncID, FuncName, ArgsData, nullptr,
nullptr};

xptiNotifySubscribers(
StreamID, (uint16_t)xpti::trace_point_type_t::function_with_args_begin,
GPIArgCallEvent, nullptr, CorrelationID, &Payload);
}
#endif
return CorrelationID;
}

void emitFunctionWithArgsEndTrace(uint64_t CorrelationID, uint32_t FuncID,
const char *FuncName, unsigned char *ArgsData,
pi_result Result) {
#ifdef XPTI_ENABLE_INSTRUMENTATION
if (xptiTraceEnabled()) {
uint8_t StreamID = xptiRegisterStream(SYCL_PIDEBUGCALL_STREAM_NAME);

xpti::function_with_args_t Payload{FuncID, FuncName, ArgsData, &Result,
nullptr};

xptiNotifySubscribers(
StreamID, (uint16_t)xpti::trace_point_type_t::function_with_args_end,
GPIArgCallEvent, nullptr, CorrelationID, &Payload);
}
#endif
}

void contextSetExtendedDeleter(const cl::sycl::context &context,
pi_context_extended_deleter func,
void *user_data) {
Expand Down Expand Up @@ -481,14 +443,6 @@ static void initializePlugins(std::vector<plugin> *Plugins) {
GPICallEvent =
xptiMakeEvent("PI Layer", &PIPayload, xpti::trace_algorithm_event,
xpti_at::active, &PiInstanceNo);

xptiInitialize(SYCL_PIDEBUGCALL_STREAM_NAME, GMajVer, GMinVer, GVerStr);
xpti::payload_t PIArgPayload(
"Plugin Interface Layer (with function arguments)");
uint64_t PiArgInstanceNo;
GPIArgCallEvent = xptiMakeEvent("PI Layer with arguments", &PIArgPayload,
xpti::trace_algorithm_event, xpti_at::active,
&PiArgInstanceNo);
#endif
}

Expand Down
63 changes: 0 additions & 63 deletions sycl/source/detail/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/pi.hpp>
#include <CL/sycl/detail/type_traits.hpp>
#include <CL/sycl/stl.hpp>
#include <detail/plugin_printers.hpp>
#include <memory>
Expand All @@ -26,62 +25,7 @@ namespace sycl {
namespace detail {
#ifdef XPTI_ENABLE_INSTRUMENTATION
extern xpti::trace_event_data_t *GPICallEvent;
extern xpti::trace_event_data_t *GPIArgCallEvent;
#endif

template <PiApiKind Kind, size_t Idx, typename... Args>
struct array_fill_helper;

template <PiApiKind Kind> struct PiApiArgTuple;

#define _PI_API(api) \
template <> struct PiApiArgTuple<PiApiKind::api> { \
using type = typename function_traits<decltype(api)>::args_type; \
};

#include <CL/sycl/detail/pi.def>
#undef _PI_API

template <PiApiKind Kind, size_t Idx, typename T>
struct array_fill_helper<Kind, Idx, T> {
static void fill(unsigned char *Dst, T &&Arg) {
using ArgsTuple = typename PiApiArgTuple<Kind>::type;
// C-style cast is required here.
auto RealArg = (std::tuple_element_t<Idx, ArgsTuple>)(Arg);
*(std::remove_cv_t<std::tuple_element_t<Idx, ArgsTuple>> *)Dst = RealArg;
}
};

template <PiApiKind Kind, size_t Idx, typename T, typename... Args>
struct array_fill_helper<Kind, Idx, T, Args...> {
static void fill(unsigned char *Dst, const T &&Arg, Args &&... Rest) {
using ArgsTuple = typename PiApiArgTuple<Kind>::type;
// C-style cast is required here.
auto RealArg = (std::tuple_element_t<Idx, ArgsTuple>)(Arg);
*(std::remove_cv_t<std::tuple_element_t<Idx, ArgsTuple>> *)Dst = RealArg;
array_fill_helper<Kind, Idx + 1, Args...>::fill(
Dst + sizeof(decltype(RealArg)), std::forward<Args>(Rest)...);
}
};

template <typename... Ts>
constexpr size_t totalSize(const std::tuple<Ts...> &) {
return (sizeof(Ts) + ...);
}

template <PiApiKind Kind, typename... ArgsT>
auto packCallArguments(ArgsT &&... Args) {
using ArgsTuple = typename PiApiArgTuple<Kind>::type;

constexpr size_t TotalSize = totalSize(ArgsTuple{});

std::array<unsigned char, TotalSize> ArgsData;
array_fill_helper<Kind, 0, ArgsT...>::fill(ArgsData.data(),
std::forward<ArgsT>(Args)...);

return ArgsData;
}

/// The plugin class provides a unified interface to the underlying low-level
/// runtimes for the device-agnostic SYCL runtime.
///
Expand Down Expand Up @@ -141,10 +85,6 @@ class plugin {
// the per_instance_user_data field.
const char *PIFnName = PiCallInfo.getFuncName();
uint64_t CorrelationID = pi::emitFunctionBeginTrace(PIFnName);
auto ArgsData =
packCallArguments<PiApiOffset>(std::forward<ArgsT>(Args)...);
uint64_t CorrelationIDWithArgs = pi::emitFunctionWithArgsBeginTrace(
static_cast<uint32_t>(PiApiOffset), PIFnName, ArgsData.data());
#endif
RT::PiResult R;
if (pi::trace(pi::TraceLevel::PI_TRACE_CALLS)) {
Expand All @@ -163,9 +103,6 @@ class plugin {
#ifdef XPTI_ENABLE_INSTRUMENTATION
// Close the function begin with a call to function end
pi::emitFunctionEndTrace(CorrelationID, PIFnName);
pi::emitFunctionWithArgsEndTrace(CorrelationIDWithArgs,
static_cast<uint32_t>(PiApiOffset),
PIFnName, ArgsData.data(), R);
#endif
return R;
}
Expand Down
1 change: 0 additions & 1 deletion sycl/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_subdirectory(sycl-ls)
add_subdirectory(pi-trace)

# TODO: move each tool in its own sub-directory
add_executable(get_device_count_by_type get_device_count_by_type.cpp)
Expand Down
14 changes: 0 additions & 14 deletions sycl/tools/pi-trace/CMakeLists.txt

This file was deleted.

84 changes: 0 additions & 84 deletions sycl/tools/pi-trace/pi_trace.cpp

This file was deleted.

Loading