1

From the cuda documentaion, cudaMemset2D is used to memset memory allocated by cudaMallocPitch. It is mentioned that "Pitch is used to meet alignment requirements for coalescing". The pitch size is returned by cudaMallocPitch function.

Question is, if my I allocate the memory with normal cudaMalloc, and define a pitch size myself (which is not necessarily a multiple of 128).

Can cudaMemset2D and other 2D functions be used for this memory?

Min Lin
  • 3,177
  • 2
  • 19
  • 32

1 Answers1

2

Yes, the 2D functions are simply strided copies. Although they would typically be used with underlying pitched allocations, it is not necessary to do so.

As an example, take a look at the answer provided by @njuffa here

Community
  • 1
  • 1
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257