Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. int width = 64, height = 64;
  2. float* devPtr;
  3. size_t pitch;
  4. cudaMallocPitch(&devPtr, &pitch,
  5. width * sizeof(float), height);
  6. MyKernel<<<100, 512>>>(devPtr, pitch, width, height);
  7.  
  8. // Device code
  9. __global__ void MyKernel(float* devPtr,
  10. size_t pitch, int width, int height)
  11. {
  12. for (int r = 0; r < height; ++r) {
  13. float* row = (float*)((char*)devPtr + r * pitch);
  14. for (int c = 0; c < width; ++c) {
  15. float element = row[c];
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement