DPC++ Runtime
Runtime libraries for oneAPI DPC++
kernel_program_cache.cpp
Go to the documentation of this file.
1 //==--- kernel_program_cache.cpp - Cache for kernel and program -*- C++-*---==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
11 #include <detail/plugin.hpp>
12 
13 namespace sycl {
15 namespace detail {
16 KernelProgramCache::~KernelProgramCache() {
17  for (auto &ProgIt : MCachedPrograms.Cache) {
18  ProgramWithBuildStateT &ProgWithState = ProgIt.second;
19  PiProgramT *ToBeDeleted = ProgWithState.Ptr.load();
20 
21  if (!ToBeDeleted)
22  continue;
23 
24  auto KernIt = MKernelsPerProgramCache.find(ToBeDeleted);
25 
26  if (KernIt != MKernelsPerProgramCache.end()) {
27  for (auto &p : KernIt->second) {
28  KernelWithBuildStateT &KernelWithState = p.second;
29  PiKernelT *Kern = KernelWithState.Ptr.load();
30 
31  if (Kern) {
32  const detail::plugin &Plugin = MParentContext->getPlugin();
33  Plugin.call<PiApiKind::piKernelRelease>(Kern);
34  }
35  }
36  MKernelsPerProgramCache.erase(KernIt);
37  }
38 
39  const detail::plugin &Plugin = MParentContext->getPlugin();
40  Plugin.call<PiApiKind::piProgramRelease>(ToBeDeleted);
41  }
42 }
43 } // namespace detail
44 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
45 } // namespace sycl
context_impl.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
kernel_program_cache.hpp
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::detail::KernelProgramCache::PiKernelT
std::remove_pointer< RT::PiKernel >::type PiKernelT
Definition: kernel_program_cache.hpp:87
plugin.hpp
piKernelRelease
pi_result piKernelRelease(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1400
sycl::_V1::detail::KernelProgramCache::BuildResult
Denotes pointer to some entity with its general state and build error.
Definition: kernel_program_cache.hpp:49
sycl::_V1::detail::KernelProgramCache::BuildResult::Ptr
std::atomic< T * > Ptr
Definition: kernel_program_cache.hpp:50
sycl::_V1::detail::KernelProgramCache::PiProgramT
std::remove_pointer< RT::PiProgram >::type PiProgramT
Definition: kernel_program_cache.hpp:71
sycl::_V1::detail::plugin
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Definition: plugin.hpp:90
piProgramRelease
pi_result piProgramRelease(pi_program program)
Definition: pi_esimd_emulator.cpp:1355
sycl::_V1::detail::plugin::call
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
Definition: plugin.hpp:217