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
n : int
x : ctypes.c_void_p
incx : int
y : ctypes.c_void_p
incy : int
|
---|
Notes
Both x and y must contain n elements.
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