Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. C++ AMP Fundamentals > Copying between CPU and GPU

Copying between CPU and GPU

Data is copied between the CPU and the accelerator (usually a GPU) either automatically or with one of the many overloads of the copy() method provided in amp.h. For example, you can construct an array on the default accelerator and copy data to it in a single call:

array<int, 1> a(5, v.begin(), v.end());

Alternatively, you can construct an empty array and later use the copy() function to fill it with data. An array_view associated with a container on the CPU will automatically copy to the accelerator when the processing of that array_view on the accelerator begins, and it can synchronize changed data back for use on the CPU, as shown in the array_view section earlier in this chapter.

These blocks of code are equivalent:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial