pub struct GpuDevice { /* private fields */ }Expand description
A selected GPU and its verified compilation target.
Implementations§
Source§impl GpuDevice
impl GpuDevice
Sourcepub fn target(&self) -> &Target
pub fn target(&self) -> &Target
Target for compiling a kernel on this GPU.
Examples found in repository?
examples/gemm_pipeline.rs (line 29)
21fn gpu_kernel(
22 runtime: &Runtime,
23 source: &str,
24 symbol: &str,
25 config: &[(&str, String)],
26 elements: usize,
27 bindings: Vec<BindingContract>,
28) -> Result<GpuKernel> {
29 let compiler = hrx::loom::Compiler::for_target(None, runtime.gpu()?.target())?;
30 let module = compiler.module(source);
31 let mut spec = hrx::loom::Specialization::new(symbol);
32 for (key, value) in config {
33 spec.set_config(*key, value.clone());
34 }
35 let artifact = module.compile(&spec)?;
36 let stream = hrx::gpu::Stream::open()?;
37 let raw = unsafe { stream.load_artifact(&artifact) }?;
38 let mut constants = hrx::gpu::Constants::new();
39 match raw.info().constant_byte_length {
40 8 => constants.push(elements as u32)?,
41 12 => constants.push(elements as u64)?,
42 _ => return Err(hrx::Error::Message("unexpected scalar ABI".into())),
43 }
44 constants.push(1f32)?;
45 unsafe {
46 runtime.load_gpu_kernel(
47 artifact.path(),
48 symbol,
49 [elements.div_ceil(256) as u32, 1, 1],
50 [256, 1, 1],
51 KernelContract {
52 bindings,
53 constants: constants.as_bytes().to_vec(),
54 },
55 )
56 }
57}Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuDevice
impl RefUnwindSafe for GpuDevice
impl Send for GpuDevice
impl Sync for GpuDevice
impl Unpin for GpuDevice
impl UnsafeUnpin for GpuDevice
impl UnwindSafe for GpuDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more