Managed memory

OpenACC provides an option to allow the compiler to handle memory management. We will be able to achieve better performance by managing memory ourselves; however, allowing the compiler to use the managed memory is very simple. We do not need to make any changes to our code to get the managed memory working.

In order to make use of the managed memory, we can pass the managed flag to the pgc++ compiler like this:

$ pgc++ -c -acc -ta=tesla:managed scrImagePgmPpmPackage.cpp
$ pgc++ -c -acc -ta=tesla:managed -Minfo=accel image_merging.cpp
$ pgc++ -o merging.out -acc -ta=tesla:managed -Minfo=accel scrImagePgmPpmPackage.o image_merging.o
$ ./blurring.out

After adding the managed clause, the compiler will basically ignore the data clauses, and the managed memory is used to transfer data between the CPU and GPU. Note that the managed memory is only for heap data and not stack/static data. The unified memory concept that we covered in the previous chapter will remain the same. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.31.73