eyalroz / cuda-kat

CUDA kernel author's tools
BSD 3-Clause "New" or "Revised" License
104 stars 8 forks source link

Support more combinations of assumptions w.r.t. copying #77

Open eyalroz opened 4 years ago

eyalroz commented 4 years ago

Copying or moving data has (at least) the following variants:

  1. Element size in bytes 1.1 size is a power of 2 1.2 size is a natively-supported power of 2 (1, 2, 4, 8) 1.3 size is a multiple of the physical write quantum
  2. Destination alignment: 2.1 w.r.t. the element size 2.2 w.r.t. natively-supported sizes (2, 4, 8)
  3. Source alignment: 3.1 w.r.t. the element size 3.2 w.r.t. natively-supported sizes (2, 4, 8)
  4. Trivial copiability/movability
  5. Alignment effects of the number of elements 5.1 in itself 5.2 relative to the beginning of the source 5.3 relative to the beginning of the destination
  6. 6.1 Number of elements % warp size 6.2. Number of elements % block size

  7. Participation cohesion in the copying: Full grid, full block, full warp, no constraint.

We currently ignore most of these, in some cases to detrimental effect. We are particularly not mindful enough of alignment and its effects.

This also has effects on other functions in cuda_kat, e.g. append_to_global_memory(), which may be forced to opt for a detail::naive_copy() because of issues with copy() or copy_n().