Skip to main content

MemoryMapper

Struct MemoryMapper 

Source
pub struct MemoryMapper;
Expand description

Maps CUDA memory spaces to Rust and WGSL equivalents.

Implementations§

Source§

impl MemoryMapper

Source

pub fn to_rust(storage: &StorageClass) -> MemoryMapping

Map a CUDA StorageClass to its Rust representation.

Source

pub fn rust_var_prefix(storage: &StorageClass, mutable: bool) -> String

Generate a Rust variable declaration prefix for the given storage class.

§Examples
  • StorageClass::Shared -> "/* __shared__ */ let mut "
  • StorageClass::Constant -> "const "
  • StorageClass::Auto -> "let "
Source

pub fn to_wgsl(storage: &StorageClass) -> MemoryMapping

Map a CUDA StorageClass to its WGSL representation.

Source

pub fn wgsl_var_decl( storage: &StorageClass, name: &str, wgsl_type: &str, ) -> String

Generate a WGSL variable declaration for the given storage class.

§Arguments
  • storage - The CUDA storage class
  • name - Variable name
  • wgsl_type - WGSL type string (e.g. “f32”, “array<f32, 256>”)
§Returns

A complete WGSL variable declaration string.

Source

pub fn wgsl_binding_decl( storage: &StorageClass, group: u32, binding: u32, name: &str, wgsl_type: &str, read_only: bool, ) -> String

Generate a WGSL binding declaration for a kernel parameter.

§Arguments
  • storage - The CUDA storage class
  • group - Binding group number
  • binding - Binding index
  • name - Variable name
  • wgsl_type - WGSL type string
  • read_only - Whether the binding is read-only
Source

pub fn parse_cuda_qualifier(qualifier: &str) -> StorageClass

Parse a CUDA memory space qualifier string into a StorageClass.

Source

pub fn requires_barrier(storage: &StorageClass) -> bool

Returns true if the storage class requires barrier synchronisation before other threads can see writes.

Source

pub fn is_read_only(storage: &StorageClass) -> bool

Returns true if the storage class is read-only.

Source

pub fn wgsl_barrier(storage: &StorageClass) -> Option<&'static str>

Returns the WGSL barrier function name needed after writes to this memory space, if any.

Source

pub fn rust_barrier(storage: &StorageClass) -> Option<&'static str>

Returns the Rust synchronization primitive needed after writes to this memory space, if any.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,