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) {
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
std::remove_pointer< RT::PiProgram >::type PiProgramT
std::remove_pointer< RT::PiKernel >::type PiKernelT
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Definition: plugin.hpp:90
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
Definition: plugin.hpp:217
#define __SYCL_INLINE_VER_NAMESPACE(X)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
pi_result piKernelRelease(pi_kernel kernel)
pi_result piProgramRelease(pi_program program)
Denotes pointer to some entity with its general state and build error.