skcuda.cublas.cublasSdot

skcuda.cublas.cublasSdot(handle, n, x, incx, y, incy)[source]

Vector dot product (single precision real)

Computes the dot product of two single precision real vectors. cublasCdotc and cublasZdotc use the conjugate of the first vector when computing the dot product.

Parameters:
  • handle (int) – CUBLAS context.
  • n (int) – Number of elements in input vectors.
  • x (ctypes.c_void_p) – Pointer to single precision real input vector.
  • incx (int) – Storage spacing between elements of x.
  • y (ctypes.c_void_p) – Pointer to single precision real input/output vector.
  • incy (int) – Storage spacing between elements of y.
Returns:

d – Dot product of x and y.

Return type:

np.float32

Examples

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> x = np.float32(np.random.rand(5))
>>> y = np.float32(np.random.rand(5))
>>> x_gpu = gpuarray.to_gpu(x)
>>> y_gpu = gpuarray.to_gpu(y)
>>> h = cublasCreate()
>>> d = cublasSdot(h, x_gpu.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1)
>>> cublasDestroy(h)
>>> np.allclose(d, np.dot(x, y))
True

Notes

Both x and y must contain n elements.

References

cublas<t>dot