How to use double Buffer

Hello ~

I prepared processing the Video source …
Cuz the image size is large and definition is high…
I can’t copy all the video to Device memory…
So I plan to create the double buffer and control the switch
to copy the videos of different time…

The procedure I planed shows below …

  1. Loading the Videos (t=n) to the DRAM on CPU …

  2. Copying the videos (t=n) to the Device memory 1…
    3.1 Processing the videos (t=n) on GPU
    3.2 During the procedure 2.2 , we load the videos (next timing , t=n+1)
    and copy it to the Device memory 2 at the same time
    4.1 After solving the Device memory 1 , GPU continues processing
    the Device memory 2, and CPU loads and copies the video(t=n+2) to Device
    memory 1

  3. then goes on…

So … How to control CPU to load and copy data to Device_memory_1 while
GPU processes the Device_memory_2…

Thabks~~ :)

Use CUDA Streams and async CUDA operations.

This is what I’d do – it may be wrong or stupid :magic: …

Run some threads, and one of the threads runs two async-synchronising CUDA streams to keep the two device-side buffers cooking.

The Boost thread library is pretty nice. There are some sample stream / async projects in the CUDA SDK - there is an async example that contains part of the solution.

External Media Good Job ~ Appreciation !! That’s what I want …Thanks~!

OK, good to know that the info may be useful to you - Best of luck! Also, have fun. External Image This sort of programming can be a lot of fun IMO.