-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Refactor kernel name based data approach #19117
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
Changes from 28 commits
7a259f0
2ae5678
7fde713
b38a467
8e41e7a
272bc61
bdb5b28
57553b7
abd48ae
a403873
f96055b
2908935
cceffaf
7fa2519
ed389b6
66f4928
5fc91a5
fa50f3f
c2444de
87543f5
0351125
b28f95e
23fa732
84e07bd
a1cd6c8
2a51c3a
737e745
37f68c8
223f28d
eb7b242
1040963
e950dfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| //==------------------- compile_time_kernel_info.hpp -----------------------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| #pragma once | ||
|
|
||
| #include <sycl/detail/kernel_desc.hpp> | ||
| #include <sycl/detail/string_view.hpp> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
| inline namespace compile_time_kernel_info_v1 { | ||
|
|
||
| // This is being passed across ABI boundary, so we don't use std::string_view, | ||
| // at least for as long as we support user apps built with GNU libstdc++'s | ||
| // pre-C++11 ABI. | ||
| struct CompileTimeKernelInfoTy { | ||
| detail::string_view Name; | ||
| unsigned NumParams = 0; | ||
| bool IsESIMD = false; | ||
| detail::string_view FileName{}; | ||
| detail::string_view FunctionName{}; | ||
| unsigned LineNumber = 0; | ||
| unsigned ColumnNumber = 0; | ||
| int64_t KernelSize = 0; | ||
| using ParamDescGetterT = kernel_param_desc_t (*)(int); | ||
| ParamDescGetterT ParamDescGetter = nullptr; | ||
| bool HasSpecialCaptures = true; | ||
| }; | ||
|
|
||
| template <class Kernel> | ||
| inline constexpr CompileTimeKernelInfoTy CompileTimeKernelInfo{ | ||
| std::string_view(getKernelName<Kernel>()), | ||
vinser52 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| getKernelNumParams<Kernel>(), | ||
| isKernelESIMD<Kernel>(), | ||
| std::string_view(getKernelFileName<Kernel>()), | ||
| std::string_view(getKernelFunctionName<Kernel>()), | ||
| getKernelLineNumber<Kernel>(), | ||
| getKernelColumnNumber<Kernel>(), | ||
| getKernelSize<Kernel>(), | ||
| &getKernelParamDesc<Kernel>, | ||
| hasSpecialCaptures<Kernel>()}; | ||
|
|
||
| } // namespace compile_time_kernel_info_v1 | ||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //==--------------------- get_device_kernel_info.hpp -----------------------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| #pragma once | ||
|
|
||
| #include <sycl/detail/compile_time_kernel_info.hpp> | ||
| #include <sycl/detail/kernel_desc.hpp> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| class DeviceKernelInfo; | ||
| // Lifetime of the underlying `DeviceKernelInfo` is tied to the availability of | ||
| // the `sycl_device_binaries` corresponding to this kernel. In other words, once | ||
| // user library is unloaded (see __sycl_unregister_lib), program manager destoys | ||
| // this `DeviceKernelInfo` object and the reference returned from here becomes | ||
| // stale. | ||
| __SYCL_EXPORT DeviceKernelInfo & | ||
| getDeviceKernelInfo(const CompileTimeKernelInfoTy &); | ||
|
|
||
| template <class Kernel> DeviceKernelInfo &getDeviceKernelInfo() { | ||
| static DeviceKernelInfo &Info = | ||
| getDeviceKernelInfo(CompileTimeKernelInfo<Kernel>); | ||
| return Info; | ||
| } | ||
|
|
||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| struct KernelNameBasedCacheT; | ||
| __SYCL_EXPORT KernelNameBasedCacheT *createKernelNameBasedCache(); | ||
| #endif | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| //==---------------------- device_kernel_info.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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| #include <detail/device_kernel_info.hpp> | ||
| #include <detail/program_manager/program_manager.hpp> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace detail { | ||
|
|
||
| DeviceKernelInfo::DeviceKernelInfo(const CompileTimeKernelInfoTy &Info) | ||
| : CompileTimeKernelInfoTy(Info) | ||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| , | ||
| Name(Info.Name.data()) | ||
| #endif | ||
| { | ||
| init(Name.data()); | ||
| } | ||
|
|
||
| void DeviceKernelInfo::init(KernelNameStrRefT KernelName) { | ||
| auto &PM = detail::ProgramManager::getInstance(); | ||
| MUsesAssert = PM.kernelUsesAssert(KernelName); | ||
| MImplicitLocalArgPos = PM.kernelImplicitLocalArgPos(KernelName); | ||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| MInitialized.store(true); | ||
| #endif | ||
| } | ||
|
|
||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| void DeviceKernelInfo::initIfNeeded(KernelNameStrRefT KernelName) { | ||
| if (!MInitialized.load()) | ||
| init(KernelName); | ||
| } | ||
| #endif | ||
|
|
||
| template <typename OtherTy> | ||
| inline constexpr bool operator==(const CompileTimeKernelInfoTy &LHS, | ||
| const OtherTy &RHS) { | ||
|
|
||
| // TODO replace with std::tie(...) == std::tie(...) once there is | ||
| // implicit conversion from detail to std string_view. | ||
| return std::string_view{LHS.Name} == std::string_view{RHS.Name} && | ||
| LHS.NumParams == RHS.NumParams && LHS.IsESIMD == RHS.IsESIMD && | ||
| std::string_view{LHS.FileName} == std::string_view{RHS.FileName} && | ||
| std::string_view{LHS.FunctionName} == | ||
| std::string_view{RHS.FunctionName} && | ||
| LHS.LineNumber == RHS.LineNumber && | ||
| LHS.ColumnNumber == RHS.ColumnNumber && | ||
| LHS.KernelSize == RHS.KernelSize && | ||
| LHS.ParamDescGetter == RHS.ParamDescGetter && | ||
| LHS.HasSpecialCaptures == RHS.HasSpecialCaptures; | ||
| } | ||
|
|
||
| void DeviceKernelInfo::setCompileTimeInfoIfNeeded( | ||
| const CompileTimeKernelInfoTy &Info) { | ||
| if (isCompileTimeInfoSet()) | ||
| CompileTimeKernelInfoTy::operator=(Info); | ||
| assert(isCompileTimeInfoSet()); | ||
|
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sergey-semenov , what did you mean by those lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That probably indicates lack of test coverage for this scenario. If that's true, I don't think it's worth adding since my next PR will essentially make all kernel info behave like this (i.e. runtime information will be filled out during image registration, compile time information will be filled out during the first access to device kernel info with compile time information available).
I'll look into it, let's see if #20003 hits any failures in precommit. |
||
| assert(Info == *this); | ||
| } | ||
|
|
||
| FastKernelSubcacheT &DeviceKernelInfo::getKernelSubcache() { | ||
| assertInitialized(); | ||
| return MFastKernelSubcache; | ||
| } | ||
| bool DeviceKernelInfo::usesAssert() { | ||
| assertInitialized(); | ||
| return MUsesAssert; | ||
| } | ||
| const std::optional<int> &DeviceKernelInfo::getImplicitLocalArgPos() { | ||
| assertInitialized(); | ||
| return MImplicitLocalArgPos; | ||
| } | ||
|
|
||
| bool DeviceKernelInfo::isCompileTimeInfoSet() const { return KernelSize != 0; } | ||
|
|
||
| void DeviceKernelInfo::assertInitialized() { | ||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| assert(MInitialized.load() && "Data needs to be initialized before use"); | ||
| #endif | ||
| } | ||
|
|
||
| } // namespace detail | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
Uh oh!
There was an error while loading. Please reload this page.