Similar to PyCUDA, PyOpenCL provides the functionality in the pyopencl.elementwise
class that allows us to evaluate the complicated expressions in a single computational pass. The method that realized this is:
ElementwiseKernel(context, argument, operation, name,",",", optional_parameters)
Here:
context
: This is the device or the group of devices on which the element-wise operation will be executedargument
: This is a C-like argument list of all the parameters involved in the computationoperation
: This is a string that represents the operation that is to be performed on the argument listname
: This is the kernel name associated withElementwiseKernel
optional_parameters
: These are not important for this recipe.