Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int width = 64, height = 64;
- float* devPtr;
- size_t pitch;
- cudaMallocPitch(&devPtr, &pitch,
- width * sizeof(float), height);
- MyKernel<<<100, 512>>>(devPtr, pitch, width, height);
- // Device code
- __global__ void MyKernel(float* devPtr,
- size_t pitch, int width, int height)
- {
- for (int r = 0; r < height; ++r) {
- float* row = (float*)((char*)devPtr + r * pitch);
- for (int c = 0; c < width; ++c) {
- float element = row[c];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement