MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / add

Function add

examples/cuda/gpu/add_gpu/src/lib.rs:12–18  ·  view source on GitHub ↗
(a: &[f32], b: &[f32], c: *mut f32)

Source from the content-addressed store, hash-verified

10#[kernel]
11#[allow(improper_ctypes_definitions, clippy::missing_safety_doc)]
12pub unsafe fn add(a: &[f32], b: &[f32], c: *mut f32) {
13 let idx = thread::index_1d() as usize;
14 if idx < a.len() {
15 let elem = &mut *c.add(idx);
16 *elem = a[idx] + b[idx];
17 }
18}

Callers 1

configure_llvmFunction · 0.85

Calls 3

index_1dFunction · 0.85
addMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected