cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
library_kernel.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 #ifndef CUDA_API_WRAPPERS_MULTI_WRAPPER_LIBRARY_KERNEL_HPP
9 #define CUDA_API_WRAPPERS_MULTI_WRAPPER_LIBRARY_KERNEL_HPP
10 
11 #if CUDA_VERSION >= 12000
12 
13 #include "kernel.hpp"
14 #include "../library.hpp"
15 #include "../kernels/in_library.hpp"
16 
17 namespace cuda {
18 
19 namespace library {
20 
21 namespace kernel {
22 
23 inline attribute_value_t get_attribute(
24  const library::kernel_t& library_kernel,
25  kernel::attribute_t attribute,
26  const device_t& device)
27 {
28  return detail_::get_attribute(library_kernel.handle(), device.id(), attribute);
29 }
30 
31 inline void set_attribute(
32  const library::kernel_t& library_kernel,
33  kernel::attribute_t attribute,
34  const device_t& device,
35  attribute_value_t value)
36 {
37  detail_::set_attribute(library_kernel.handle(), device.id(), attribute, value);
38 }
39 
40 cuda::kernel_t contextualize(const kernel_t& kernel, const context_t& context)
41 {
42  auto new_handle = detail_::contextualize(kernel.handle(), context.handle());
43  using cuda::kernel::wrap;
44  return wrap(context.device_id(), context.handle(), new_handle, do_not_hold_primary_context_refcount_unit);
45 }
46 
47 } // namespace kernel
48 
49 } // namespace library
50 
51 } // namespace cuda
52 
53 #endif // CUDA_VERSION >= 12000
54 
55 #endif // CUDA_API_WRAPPERS_MULTI_WRAPPER_LIBRARY_KERNEL_HPP
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
array_t< T, NumDimensions > wrap(device::id_t device_id, context::handle_t context_handle, handle_t handle, dimensions_t< NumDimensions > dimensions) noexcept
Wrap an existing CUDA array in an array_t instance.
Definition: array.hpp:264
A non-owning wrapper for CUDA kernels - whether they be __global__ functions compiled apriori...
Definition: kernel.hpp:159