我是CUDA的新手,我正在尝试使用cudaMemcpyToSymbol的示例程序,但是它给了我cudaErrorUnknown。下面是我正在尝试的示例程序。
在最后一行,其打印内容为“ cudaMemcpyToSymbol()的输出为:cudaErrorUnknown”。
#include <iostream>
#include<cuda_runtime.h>
#include<string>
using namespace std;
int main()
{
void *ptr0,*ptr1;
string out;
char str[100]="Hi, I am Ellesemere. What is ur name?";
char output[100];
out=cudaGetErrorString(cudaSetDevice(0));
cout<<"The value of cudaSetDevice() is: "<<out<<endl;
out=cudaGetErrorString(cudaMalloc(&ptr0,100));
cout<<"The output of cudaMalloc() is: "<<out<<endl;
out=cudaGetErrorString(cudaMemcpyToSymbol(ptr0,str,100,0,cudaMemcpyHostToDevice));
cout<<"The output of cudaMemcpyToSymbol() is: "<<out<<endl;
}
我期望cudaSuccess作为cudaMemcpyToSymbol的输出,而不是cudaErrorUnknown。谁能帮我解决一下问题。