skcuda.cublas.cublasSswap¶
-
skcuda.cublas.
cublasSswap
(handle, n, x, incx, y, incy)[source]¶ Swap single precision real vectors.
Swaps the contents of one single precision real vector with those of another single precision real vector.
Parameters: - handle (int) – CUBLAS context.
- n (int) – Number of elements in input vectors.
- x (ctypes.c_void_p) – Pointer to single precision real input/output 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.
Examples
>>> import pycuda.autoinit >>> import pycuda.gpuarray as gpuarray >>> import numpy as np >>> x = np.random.rand(5).astype(np.float32) >>> y = np.random.rand(5).astype(np.float32) >>> x_gpu = gpuarray.to_gpu(x) >>> y_gpu = gpuarray.to_gpu(y) >>> h = cublasCreate() >>> cublasSswap(h, x.size, x_gpu.gpudata, 1, y_gpu.gpudata, 1) >>> cublasDestroy(h) >>> np.allclose(x_gpu.get(), y) True >>> np.allclose(y_gpu.get(), x) True
Notes
Both x and y must contain n elements.
References