Skip to content

[SYCL] Move Kernel specific data from handler_impl to a separate data structure #19843

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

Draft
wants to merge 4 commits into
base: sycl
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

namespace sycl {
inline namespace _V1 {
class handler;

namespace detail {
class KernelData;

template <typename T> struct is_unbounded_array : std::false_type {};

template <typename T> struct is_unbounded_array<T[]> : std::true_type {};
Expand All @@ -38,7 +39,7 @@ class work_group_memory_impl {

private:
size_t buffer_size;
friend class sycl::handler;
friend class KernelData;
};

} // namespace detail
Expand Down
13 changes: 7 additions & 6 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,23 +501,21 @@ class __SYCL_EXPORT handler {
extractArgsAndReqsFromLambda(char *LambdaPtr, size_t KernelArgsNum,
const detail::kernel_param_desc_t *KernelArgs,
bool IsESIMD);
#endif
/// Extracts and prepares kernel arguments from the lambda using information
/// from the built-ins or integration header.
void extractArgsAndReqsFromLambda(
char *LambdaPtr, detail::kernel_param_desc_t (*ParamDescGetter)(int),
size_t NumKernelParams, bool IsESIMD);

#endif
/// Extracts and prepares kernel arguments set via set_arg(s).
void extractArgsAndReqs();

#if defined(__INTEL_PREVIEW_BREAKING_CHANGES)
// TODO: processArg need not to be public
__SYCL_DLL_LOCAL
#endif
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
// TODO: remove in the next ABI-breaking window.
void processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
const int Size, const size_t Index, size_t &IndexShift,
bool IsKernelCreatedFromSource, bool IsESIMD);
#endif

/// \return a string containing name of SYCL kernel.
detail::ABINeutralKernelNameStrT getKernelName();
Expand Down Expand Up @@ -3611,7 +3609,10 @@ class __SYCL_EXPORT handler {

void addArg(detail::kernel_param_kind_t ArgKind, void *Req, int AccessTarget,
int ArgIndex);
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
// TODO: remove in the next ABI-breaking window
void clearArgs();
#endif
void setArgsToAssociatedAccessors();

bool HasAssociatedAccessor(detail::AccessorImplHost *Req,
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/sycl/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ inline namespace _V1 {
namespace detail {

class stream_impl;
class KernelData;

using FmtFlags = unsigned int;

Expand Down Expand Up @@ -1041,7 +1042,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(stream) stream
}
#endif

friend class handler;
friend class detail::KernelData;

template <typename SYCLObjT> friend class ext::oneapi::weak_object;

Expand Down
1 change: 1 addition & 0 deletions sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ set(SYCL_COMMON_SOURCES
"detail/device_filter.cpp"
"detail/host_pipe_map.cpp"
"detail/device_global_map.cpp"
"detail/kernel_data.cpp"
"detail/kernel_global_info.cpp"
"detail/device_global_map_entry.cpp"
"detail/device_image_impl.cpp"
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/graph/dynamic_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void dynamic_command_group_impl::finalizeCGFList(
MCommandGroups.push_back(std::shared_ptr<sycl::detail::CG>(RawCGPtr));

// Track dynamic_parameter usage in command-group
auto &DynamicParams = Handler.impl->MDynamicParameters;
auto &DynamicParams = Handler.impl->MKernelData.getDynamicParameters();

if (DynamicParams.size() > 0 &&
Handler.getType() == sycl::detail::CGType::CodeplayHostTask) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/graph/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ node_impl &graph_impl::add(std::function<void(handler &)> CGF,

// Retrieve any dynamic parameters which have been registered in the CGF and
// register the actual nodes with them.
auto &DynamicParams = Handler.impl->MDynamicParameters;
auto &DynamicParams = Handler.impl->MKernelData.getDynamicParameters();

if (NodeType != node_type::kernel && DynamicParams.size() > 0) {
throw sycl::exception(sycl::make_error_code(errc::invalid),
Expand Down
20 changes: 2 additions & 18 deletions sycl/source/detail/handler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "sycl/handler.hpp"
#include <detail/cg.hpp>
#include <detail/kernel_bundle_impl.hpp>
#include <detail/kernel_data.hpp>
#include <memory>
#include <sycl/ext/oneapi/experimental/enqueue_types.hpp>

Expand Down Expand Up @@ -133,21 +134,12 @@ class handler_impl {
sycl::ext::oneapi::experimental::node_type MUserFacingNodeType =
sycl::ext::oneapi::experimental::node_type::empty;

// Storage for any SYCL Graph dynamic parameters which have been flagged for
// registration in the CG, along with the argument index for the parameter.
std::vector<std::pair<
ext::oneapi::experimental::detail::dynamic_parameter_impl *, int>>
MDynamicParameters;

/// The storage for the arguments passed.
/// We need to store a copy of values that are passed explicitly through
/// set_arg, require and so on, because we need them to be alive after
/// we exit the method they are passed in.
detail::CG::StorageInitHelper CGData;

/// The list of arguments for the kernel.
std::vector<detail::ArgDesc> MArgs;

/// The list of associated accessors with this handler.
/// These accessors were created with this handler as argument or
/// have become required for this handler via require method.
Expand Down Expand Up @@ -236,15 +228,7 @@ class handler_impl {
// Allocation ptr to be freed asynchronously.
void *MFreePtr = nullptr;

// Store information about the kernel arguments.
void *MKernelFuncPtr = nullptr;
int MKernelNumArgs = 0;
detail::kernel_param_desc_t (*MKernelParamDescGetter)(int) = nullptr;
bool MKernelIsESIMD = false;
bool MKernelHasSpecialCaptures = true;

// A pointer to a kernel name based cache retrieved on the application side.
KernelNameBasedCacheT *MKernelNameBasedCachePtr = nullptr;
KernelData MKernelData;
};

} // namespace detail
Expand Down
Loading
Loading