1use oneapi_rs_sys::{context::ffi, kernel_bundle, types::ffi::DevicePtr};
10
11use crate::{device::Device, kernel::SourceKernelBundle};
12
13pub struct Context(pub(crate) cxx::UniquePtr<ffi::Context>);
16
17impl From<cxx::UniquePtr<ffi::Context>> for Context {
18 fn from(value: cxx::UniquePtr<ffi::Context>) -> Self {
19 Self(value)
20 }
21}
22
23impl Context {
24 pub fn new(devices: &[&Device]) -> Self {
25 let devices = devices
26 .iter()
27 .map(|d| DevicePtr {
28 ptr: (*d).clone().0,
29 })
30 .collect::<Vec<_>>();
31
32 ffi::new_context(devices).into()
33 }
34
35 pub fn create_kernel_bundle_from_source(&self, source: &str) -> SourceKernelBundle {
36 kernel_bundle::ffi::create_kernel_bundle_from_source(&self.0, source).into()
37 }
38}