make_tiled_copy
Create a tiled_copy policy. For transpose copy operations, the actual matrix size is determined by the product of the CopyAtom Ops transpose matrix size and the corresponding m and n dimensions from atom_shape. For prefetch operations, the actual matrix size is the product of the CopyAtom Ops prefetch matrix size and the corresponding m dimension in atom_shape.
Currently, m and n in atom_shape do not support extension. Restrictions vary across different CopyAtom Ops, as outlined in the following table.
Interface Definition
template<typename CopyAtom, typename Shape>
TiledCopy<CopyAtom, Shape> make_tiled_copy( CopyAtom copy_atom, Shape atom_shape);
Template Parameters
Parameter |
Type |
Description |
|---|---|---|
CopyAtom |
typename |
Copy atom policy type. |
Shape |
typename |
Shape type. |
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
copy_atom |
CopyAtom, Ops<copy_atom_t> |
Copy atom policy. Currently, copy_atom_t can be set to:
|
Input |
atom_shape |
Shape |
Number of times that the atom policy is executed in each dimension. For the transpose atom operation, both m and n are included. For the prefetch atom operation, only m is included. |
Input |
Return Value
TiledCopy<StoreCopy, Shape> object returned.
Examples
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 | #include <stdio.h> #include <stdlib.h> #include "kupl_mma.h" using namespace kupl::tensor; int main() { constexpr int MATRIX_M = 32; constexpr int MATRIX_N = 512; double *dst = (double*)malloc(sizeof(double) * MATRIX_M * MATRIX_N); double *src = (double*)malloc(sizeof(double) * MATRIX_M * MATRIX_N); for (int i = 0; i < MATRIX_M; i++) { for (int j = 0; j < MATRIX_N; j++) { dst[i * MATRIX_N + j] = 0.0; src[i * MATRIX_N + j] = i * MATRIX_N + j; } } auto shape_d = make_shape(Int<MATRIX_M>{}, Int<MATRIX_N>{}); auto shape_s = make_shape(Int<MATRIX_M>{}, Int<MATRIX_N>{}); auto stride_d = make_stride(Int<1>{}, Int<MATRIX_M>{}); auto stride_s = make_stride(Int<MATRIX_N>{}, Int<1>{}); auto layout_d = make_layout(shape_d, stride_d); auto layout_s = make_layout(shape_s, stride_s); auto atom_copy_shape = make_shape(Int<1>{}, Int<MATRIX_N>{}); auto tiled_copy = make_tiled_copy(Ops<KP36_32x1_F64_TRANS_RM2CM>{}, atom_copy_shape); auto tensor_d = make_tensor(dst, layout_d); auto tensor_s = make_tensor(src, layout_s); tensor_tiled_copy(tiled_copy, tensor_d, tensor_s); free(src); free(dst); return 0; } |
The preceding example illustrates the row-major to column-major copy process for a 32 × 512_F64 matrix. The copy tiling policy is initialized via make_tiled_copy, utilizing the COPY_32x1_F64_RM2CM atom method with an atom_shape of shape<1, 512>.