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 
14 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 }
44 }
45 }
cl::sycl::detail::KernelProgramCache::BuildResult
Denotes pointer to some entity with its general state and build error.
Definition: kernel_program_cache.hpp:48
context_impl.hpp
kernel_program_cache.hpp
cl::sycl::detail::KernelProgramCache::PiKernelT
std::remove_pointer< RT::PiKernel >::type PiKernelT
Definition: kernel_program_cache.hpp:78
sycl
Definition: invoke_simd.hpp:68
plugin.hpp
piKernelRelease
pi_result piKernelRelease(pi_kernel kernel)
Definition: pi_esimd_emulator.cpp:1377
cl::sycl::detail::KernelProgramCache::BuildResult::Ptr
std::atomic< T * > Ptr
Definition: kernel_program_cache.hpp:49
piProgramRelease
pi_result piProgramRelease(pi_program program)
Definition: pi_esimd_emulator.cpp:1332
cl::sycl::detail::plugin::call
void call(ArgsT... Args) const
Calls the API, traces the call, checks the result.
Definition: plugin.hpp:217
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::plugin
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Definition: plugin.hpp:90
cl::sycl::detail::KernelProgramCache::PiProgramT
std::remove_pointer< RT::PiProgram >::type PiProgramT
Definition: kernel_program_cache.hpp:70
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12