1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Metal backend: device discovery, kernel library and pipelines, shared buffers, and
//! command encoding with minimal barriers.
//!
//! ```no_run
//! # #[cfg(target_os = "macos")]
//! # fn main() -> nuvec_gpu::Result<()> {
//! use nuvec_gpu::{Arg, Device};
//!
//! let Some(device) = Device::system_default() else { return Ok(()) }; // no Metal here
//! let add = device.pipeline("nuvec_add_f32")?;
//! let a = device.buffer_from(&1.0f32.to_le_bytes().repeat(4))?;
//! let b = device.buffer_from(&2.0f32.to_le_bytes().repeat(4))?;
//! let mut out = device.new_buffer(16)?;
//! let mut cmd = device.command_buffer()?;
//! cmd.dispatch(&add, &[Arg::read(&a), Arg::read(&b), Arg::write(&mut out), Arg::bytes(&4u32.to_le_bytes())], 4)?;
//! cmd.commit().wait()?;
//! assert_eq!(&out.contents()?[..4], &3.0f32.to_le_bytes());
//! # Ok(())
//! # }
//! # #[cfg(not(target_os = "macos"))]
//! # fn main() {} // Metal exists only on Apple platforms
//! ```
//!
//! Buffers live in shared (unified) memory: the CPU reads GPU results in place. CPU access
//! is refused while submitted work uses a buffer, and GPU writes need `&mut Buffer`, so
//! CPU and GPU never race on the same memory.
//!
//! Arrays evaluated on the GPU (`nuvec-core`) use the process-wide [`Device::shared`]; its
//! allocator's limits and statistics are set and read there.
pub use ;
pub use DeviceInfo;
pub use MemoryStats;
pub use ;
pub use ;
/// The version of this crate.
pub const VERSION: &str = env!;