Skip to main content

zip_map2_raw_into_validated

Function zip_map2_raw_into_validated 

Source
pub unsafe fn zip_map2_raw_into_validated<D: Copy + MaybeSendSync, A: Copy + MaybeSendSync, B: Copy + MaybeSendSync, OpA: ElementOp<A>, OpB: ElementOp<B>>(
    dest: &mut RawStridedMut<'_, D>,
    a: &RawStridedRef<'_, A>,
    b: &RawStridedRef<'_, B>,
    f: impl Fn(A, B) -> D + MaybeSync,
    validated: ValidatedDestinationLayout,
) -> Result<()>
Expand description

Prevalidated zip map2 raw into validated for kernel-family implementations.

§Safety

All input shapes must match the destination. validated must have been obtained for this destination’s current geometry, proving injectivity; possessing a marker from another layout is not sufficient. View/descriptor bounds and aliasing contracts must continue to hold throughout replay.

§Examples

use strided_basic::execution::*;
// SAFETY: the example supplies matching bounded layouts and disjoint storage.
use strided_basic::{RawStridedRef, RawStridedMut, Identity};
let values = [2.0_f64; 2];
let src = RawStridedRef::new(&values, &[2], &[1], 0).unwrap();
let mut output = [0.0; 2];
let mut dst = RawStridedMut::new(&mut output, &[2], &[1], 0).unwrap();
let checked = validate_destination_layout_without_alloc(&[2], &[1]).unwrap();
unsafe { zip_map2_raw_into_validated::<f64, f64, f64, Identity, Identity>(&mut dst, &src, &src, |a, b| a + b, checked) }.unwrap();
assert_eq!(output, [4.0; 2]);

§Errors

Forwards errors from the owning kernel or callback; callers must still satisfy the safety contract before invoking this prevalidated entry.