因为有些矩阵运算常见的pycuda无法满足,需要用到vector,vector在cuda里面就是thrust。
下载thrust官方example。
git clone https://github.com/thrust/thrust.git
——————————————————————————————————————————
#include
#include
#include
#include
#include
#include
#include
#include
int main(void)
{
thrust::device_vector
thrust::device_vector
thrust::device_vector
thrust::sequence(X.begin(), X.end());//赋值给x,是一个排列。
thrust::copy(X.begin(), X.end(), std::ostream_iterator
thrust::transform(X.begin(), X.end(), Y.begin(), thrust::negate
thrust::fill(Z.begin(), Z.end(), 3);//z的值全部都是3
std::cout<
thrust::copy(Y.begin(), Y.end(), std::ostream_iterator
return 0;
}
我是因为在一个视频流矩阵里面,要对每一个坐标进行矩阵乘法运算,搞了半天,还差一点点。