cubecl_matmul/components/global/
copy_mechanism.rs

1use cubecl_core as cubecl;
2use cubecl_core::prelude::barrier::Barrier;
3use cubecl_core::prelude::*;
4
5#[cube]
6/// Allows to copy a slice of data from global to shared memory asynchronously
7pub trait CopyMechanism: CubeType + Sync + Send + 'static {
8    /// Copy the `source` slice to `destination`, assuming `source`'s length <= `destination`'s
9    fn memcpy_async<ES: Numeric>(
10        this: &Self,
11        source: &Slice<Line<ES>>,
12        destination: &mut SliceMut<Line<ES>>,
13    );
14}
15
16#[cube]
17impl CopyMechanism for Barrier {
18    fn memcpy_async<ES: Numeric>(
19        this: &Self,
20        source: &Slice<Line<ES>>,
21        destination: &mut SliceMut<Line<ES>>,
22    ) {
23        this.memcpy_async(source, destination)
24    }
25}