我是cuda和C ++的新手,似乎无法弄清楚这一点。
我想要做的是将2d数组A复制到设备,然后将其复制回相同的数组B。
我希望B数组具有与A相同的值,但是有些地方我做错了。
CUDA-4.2,针对Win32、64位计算机,NVIDIA Quadro K5000进行编译
这是代码。
void main(){
cout<<"Host main" << endl;
// Host code
const int width = 3;
const int height = 3;
float* devPtr;
float a[width][height];
//load and display input array
cout << "a array: "<< endl;
for (int i = 0 ; i < width; i ++)
{
for (int j = 0 ; j < height; j ++)
{
a[i][j] = i + j;
cout << a[i][j] << " ";
}
cout << …Run Code Online (Sandbox Code Playgroud)