Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ad32ada
Initial argument handling implementation
alexbatashev Jun 19, 2021
81a134e
A bit refined implementation
alexbatashev Jun 22, 2021
9b6d5a1
improved comment
alexbatashev Jun 22, 2021
ae4c35d
Minor cleanup
alexbatashev Jun 22, 2021
0d3a580
more cleanup
alexbatashev Jun 22, 2021
a5792a2
more stylistic changes
alexbatashev Jun 22, 2021
a283c03
more file headers
alexbatashev Jun 22, 2021
08702b5
clang-format
alexbatashev Jun 22, 2021
df846f9
remove unused include
alexbatashev Jun 22, 2021
3603bda
fix build
alexbatashev Jun 22, 2021
ab7fba6
More clang-format
alexbatashev Jun 22, 2021
cb248c1
Add arguments for function end as well
alexbatashev Jun 22, 2021
3118d0c
get rid of piapiid
alexbatashev Jun 23, 2021
571b6c4
clang-format
alexbatashev Jun 23, 2021
71805c1
more clang-format
alexbatashev Jun 23, 2021
3151a63
address more feedback
alexbatashev Jun 24, 2021
224d802
Merge remote-tracking branch 'upstream/sycl' into xpti_pi_args
alexbatashev Jun 24, 2021
9775db1
make CI a bit happier
alexbatashev Jun 24, 2021
22ded67
more review feedback
alexbatashev Jun 24, 2021
0b6a5bb
why local and remote clang-format do it differently?
alexbatashev Jun 24, 2021
7a3cde1
remove tuple_view
alexbatashev Jun 30, 2021
47ee4c4
more feedback
alexbatashev Jul 2, 2021
b236f2c
Merge remote-tracking branch 'upstream/sycl' into xpti_pi_args
alexbatashev Jul 2, 2021
57e287f
use template magic instead of changing pi.def
alexbatashev Jul 6, 2021
2e3321b
clang-format
alexbatashev Jul 6, 2021
0b08a09
slight changes to xpti interfaces
alexbatashev Jul 8, 2021
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: 3 additions & 0 deletions sycl/include/CL/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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_PIARGCALL_STREAM_NAME = "sycl.pi.arg";
// Data structure that captures the user code location information using the
// builtin capabilities of the compiler
struct code_location {
Expand Down
19 changes: 19 additions & 0 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ 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 ArgsData is a pointer to packed function call arguments.
uint64_t emitFunctionWithArgsBeginTrace(uint32_t FuncID,
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 ArgsData is a pointer to packed function call arguments.
/// \param Result is function call result value.
void emitFunctionWithArgsEndTrace(uint64_t CorrelationID, uint32_t FuncID,
unsigned char *ArgsData, pi_result Result);

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

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

#undef _PI_API
60 changes: 60 additions & 0 deletions sycl/include/CL/sycl/detail/pi_api_id.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//==---------- pi_api_id.hpp - PI API function IDs -------------------------==//
//
// 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_api_id.hpp
/// This file contains mapping between PI API functions and their IDs. A hash
/// function is used to generate IDs. The reason for usage of a hash function
/// instead of raw values of PiApiKind is ABI stability. New functions can be
/// added to PiApiKind, and there's no reliable way for external XPTI users to
/// know when to update the values. Hashes are calculated from API function
/// name, so it will remain the same after update to pi.def.
///
/// \ingroup sycl_pi

#pragma once

#include <CL/sycl/detail/pi.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {
constexpr uint32_t cxpow(uint32_t Base, uint32_t Pow) {
uint32_t Res = Base;
for (uint32_t I = 1; I < Pow; I++)
Res *= Base;
return Res;
}

/// This is a simple implementation of polynomial rolling hash function.
///
/// The general formula for the hash is Sum(s[i] * p^i) mod m.
/// Since only English characters are used for PI function names, p = 53 is
/// chosen. m = 1051 is a fairly big prime number for the task.
constexpr uint32_t cxhash(const char *Str) {
constexpr uint32_t p = 53;
constexpr uint32_t m = 1051;
uint32_t Hash = 0;
uint32_t Len = 0;
while (Str[Len++] != '\0')
Hash += Str[Len - 1] * cxpow(p, Len - 1);
return Hash % m;
}

template <PiApiKind Api> struct PiApiID {};

#define _PI_API(api) \
template <> struct PiApiID<PiApiKind::api> { \
static constexpr uint32_t id = cxhash(#api); \
};

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

#undef _PI_API
} // namespace detail
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
Loading