August 2015
Intermediate to advanced
286 pages
5h 42m
English
In the previous recipe, we saw how to invoke a kernel function using the class:
pycuda.compiler.SourceModule(kernel_source, nvcc="nvcc", options=None, other_options)
It creates a module from the CUDA source code called kernel_source. Then, the NVIDIA nvcc compiler is invoked with options to compile the code.
However, PyCUDA introduces the class pycuda.gpuarray.GPUArray that provides a high-level interface to perform calculations with CUDA:
class pycuda.gpuarray.GPUArray(shape, dtype, *, allocator=None, order="C")
This works in a similar way to numpy.ndarray, which stores its data and performs its computations on the compute device. The shape and dtype arguments work exactly as in NumPy.
All the arithmetic methods in ...
Read now
Unlock full access