In the last chapter, we set up our programming environment. Now, with our drivers and compilers firmly in place, we will begin the actual GPU programming! We will start by learning how to use PyCUDA for some basic and fundamental operations. We will first see how to query our GPU—that is, we will start by writing a small Python program that will tell us what the characteristics of our GPU are, such as the core count, architecture, and memory. We will then spend some time getting acquainted with how to transfer memory between Python and the GPU with PyCUDA's gpuarray class and how to use this class for basic computations. The remainder of this chapter will be spent showing how to write some basic functions (which we will refer to as CUDA Kernels) that we can directly launch onto the GPU.
The learning outcomes for this chapter are as follows...