Skip to content

Commit 8ff1f9f

Browse files
committed
Move Kernel specific data from handler_impl to a separate data structure to use it in handler-based and handler-less submission paths
1 parent 59dafb2 commit 8ff1f9f

File tree

15 files changed

+704
-488
lines changed

15 files changed

+704
-488
lines changed

sycl/include/sycl/ext/oneapi/experimental/work_group_memory.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
namespace sycl {
2020
inline namespace _V1 {
21-
class handler;
2221

2322
namespace detail {
23+
class KernelData;
24+
2425
template <typename T> struct is_unbounded_array : std::false_type {};
2526

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

3940
private:
4041
size_t buffer_size;
41-
friend class sycl::handler;
42+
friend class KernelData;
4243
};
4344

4445
} // namespace detail

sycl/include/sycl/handler.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ class __SYCL_EXPORT handler {
495495
constexpr auto Info = detail::CompileTimeKernelInfo<Kernel>;
496496
MKernelName = Info.Name;
497497
// TODO support ESIMD in no-integration-header case too.
498-
setKernelInfo(KernelFuncPtr, Info.NumParams, Info.ParamDescGetter,
499-
Info.IsESIMD, Info.HasSpecialCaptures);
498+
setKernelInfo(KernelFuncPtr);
500499
setDeviceKernelInfoPtr(&detail::getDeviceKernelInfo<Kernel>());
501500
setType(detail::CGType::Kernel);
502501
}
@@ -520,23 +519,21 @@ class __SYCL_EXPORT handler {
520519
extractArgsAndReqsFromLambda(char *LambdaPtr, size_t KernelArgsNum,
521520
const detail::kernel_param_desc_t *KernelArgs,
522521
bool IsESIMD);
523-
#endif
524522
/// Extracts and prepares kernel arguments from the lambda using information
525523
/// from the built-ins or integration header.
526524
void extractArgsAndReqsFromLambda(
527525
char *LambdaPtr, detail::kernel_param_desc_t (*ParamDescGetter)(int),
528526
size_t NumKernelParams, bool IsESIMD);
529-
527+
#endif
530528
/// Extracts and prepares kernel arguments set via set_arg(s).
531529
void extractArgsAndReqs();
532530

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

541538
/// \return a string containing name of SYCL kernel.
542539
detail::ABINeutralKernelNameStrT getKernelName();
@@ -3609,7 +3606,10 @@ class __SYCL_EXPORT handler {
36093606

36103607
void addArg(detail::kernel_param_kind_t ArgKind, void *Req, int AccessTarget,
36113608
int ArgIndex);
3609+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
3610+
// TODO: remove in the next ABI-breaking window
36123611
void clearArgs();
3612+
#endif
36133613
void setArgsToAssociatedAccessors();
36143614

36153615
bool HasAssociatedAccessor(detail::AccessorImplHost *Req,
@@ -3656,10 +3656,12 @@ class __SYCL_EXPORT handler {
36563656
void setNDRangeDescriptor(sycl::range<1> NumWorkItems, sycl::id<1> Offset);
36573657
void setNDRangeDescriptor(sycl::range<1> NumWorkItems,
36583658
sycl::range<1> LocalSize, sycl::id<1> Offset);
3659-
3659+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
36603660
void setKernelInfo(void *KernelFuncPtr, int KernelNumArgs,
36613661
detail::kernel_param_desc_t (*KernelParamDescGetter)(int),
36623662
bool KernelIsESIMD, bool KernelHasSpecialCaptures);
3663+
#endif
3664+
void setKernelInfo(void *KernelFuncPtr);
36633665

36643666
void instantiateKernelOnHost(void *InstantiateKernelOnHostPtr);
36653667

sycl/include/sycl/stream.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ inline namespace _V1 {
4242
namespace detail {
4343

4444
class stream_impl;
45+
class KernelData;
4546

4647
using FmtFlags = unsigned int;
4748

@@ -1041,7 +1042,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(stream) stream
10411042
}
10421043
#endif
10431044

1044-
friend class handler;
1045+
friend class detail::KernelData;
10451046

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

sycl/source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ set(SYCL_COMMON_SOURCES
260260
"detail/device_filter.cpp"
261261
"detail/host_pipe_map.cpp"
262262
"detail/device_global_map.cpp"
263+
"detail/kernel_data.cpp"
263264
"detail/kernel_global_info.cpp"
264265
"detail/device_global_map_entry.cpp"
265266
"detail/device_image_impl.cpp"

sycl/source/detail/graph/dynamic_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void dynamic_command_group_impl::finalizeCGFList(
343343
MCommandGroups.push_back(std::shared_ptr<sycl::detail::CG>(RawCGPtr));
344344

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

348348
if (DynamicParams.size() > 0 &&
349349
Handler.getType() == sycl::detail::CGType::CodeplayHostTask) {

sycl/source/detail/graph/graph_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ node_impl &graph_impl::add(std::function<void(handler &)> CGF,
471471

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

476476
if (NodeType != node_type::kernel && DynamicParams.size() > 0) {
477477
throw sycl::exception(sycl::make_error_code(errc::invalid),

sycl/source/detail/handler_impl.hpp

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "sycl/handler.hpp"
1212
#include <detail/cg.hpp>
1313
#include <detail/kernel_bundle_impl.hpp>
14+
#include <detail/kernel_data.hpp>
1415
#include <memory>
1516
#include <sycl/ext/oneapi/experimental/enqueue_types.hpp>
1617

@@ -61,8 +62,7 @@ class handler_impl {
6162
}
6263

6364
KernelNameStrRefT getKernelName() const {
64-
assert(MDeviceKernelInfoPtr);
65-
return static_cast<KernelNameStrRefT>(MDeviceKernelInfoPtr->Name);
65+
return MKernelData.getKernelName();
6666
}
6767

6868
/// Registers mutually exclusive submission states.
@@ -108,12 +108,6 @@ class handler_impl {
108108
// If the pipe operation is read or write, 1 for read 0 for write.
109109
bool HostPipeRead = true;
110110

111-
ur_kernel_cache_config_t MKernelCacheConfig = UR_KERNEL_CACHE_CONFIG_DEFAULT;
112-
113-
bool MKernelIsCooperative = false;
114-
bool MKernelUsesClusterLaunch = false;
115-
uint32_t MKernelWorkGroupMemorySize = 0;
116-
117111
// Extra information for bindless image copy
118112
ur_image_desc_t MSrcImageDesc = {};
119113
ur_image_desc_t MDstImageDesc = {};
@@ -138,29 +132,17 @@ class handler_impl {
138132
sycl::ext::oneapi::experimental::node_type MUserFacingNodeType =
139133
sycl::ext::oneapi::experimental::node_type::empty;
140134

141-
// Storage for any SYCL Graph dynamic parameters which have been flagged for
142-
// registration in the CG, along with the argument index for the parameter.
143-
std::vector<std::pair<
144-
ext::oneapi::experimental::detail::dynamic_parameter_impl *, int>>
145-
MDynamicParameters;
146-
147135
/// The storage for the arguments passed.
148136
/// We need to store a copy of values that are passed explicitly through
149137
/// set_arg, require and so on, because we need them to be alive after
150138
/// we exit the method they are passed in.
151139
detail::CG::StorageInitHelper CGData;
152140

153-
/// The list of arguments for the kernel.
154-
std::vector<detail::ArgDesc> MArgs;
155-
156141
/// The list of associated accessors with this handler.
157142
/// These accessors were created with this handler as argument or
158143
/// have become required for this handler via require method.
159144
std::vector<detail::ArgDesc> MAssociatedAccesors;
160145

161-
/// Struct that encodes global size, local size, ...
162-
detail::NDRDescT MNDRDesc;
163-
164146
/// Type of the command group, e.g. kernel, fill. Can also encode version.
165147
/// Use getType and setType methods to access this variable unless
166148
/// manipulations with version are required
@@ -241,16 +223,7 @@ class handler_impl {
241223
// Allocation ptr to be freed asynchronously.
242224
void *MFreePtr = nullptr;
243225

244-
// Store information about the kernel arguments.
245-
void *MKernelFuncPtr = nullptr;
246-
int MKernelNumArgs = 0;
247-
detail::kernel_param_desc_t (*MKernelParamDescGetter)(int) = nullptr;
248-
bool MKernelIsESIMD = false;
249-
bool MKernelHasSpecialCaptures = true;
250-
251-
// A pointer to device kernel information. Cached on the application side in
252-
// headers or retrieved from program manager.
253-
DeviceKernelInfo *MDeviceKernelInfoPtr = nullptr;
226+
KernelData MKernelData;
254227
};
255228

256229
} // namespace detail

0 commit comments

Comments
 (0)