调用子程序时类型不匹配
type mismatch while calling the subroutine
"int *" 类型的参数与 "int" 类型的参数不兼容
__global__ void DeviceFun(thrust::device_vector<int>* arr, int len0, int len1)
{
int i = threadIdx;
if ( (i>=len0) && (i<len1) )
printf("arr[%d] = %d ", i, arr[i]);
}
int main()
{
thrust::device_vector<int> v(4);
thrust::fill(v.begin(), v.end(), 137);
int len = 4;
int len0 = 0;
int len1 = len;
DeviceFun<<<1, len>>>(&v, &len0, &len1);
cudaDeviceSynchronize();
return 0;
}
尝试修复错误以便编译和 运行 程序。
DeviceFun<<<1, len>>>(&v, &len0, &len1);
DeviceFun的签名是:
DeviceFun(int* arr, int len0, int len1)
但是,您将指向 len0 和 len1 的指针传递给函数。我认为您应该这样调用 DeviceFun:
DeviceFun<<1, len>>(&v[0], len0, len1);
"int *" 类型的参数与 "int" 类型的参数不兼容
__global__ void DeviceFun(thrust::device_vector<int>* arr, int len0, int len1)
{
int i = threadIdx;
if ( (i>=len0) && (i<len1) )
printf("arr[%d] = %d ", i, arr[i]);
}
int main()
{
thrust::device_vector<int> v(4);
thrust::fill(v.begin(), v.end(), 137);
int len = 4;
int len0 = 0;
int len1 = len;
DeviceFun<<<1, len>>>(&v, &len0, &len1);
cudaDeviceSynchronize();
return 0;
}
尝试修复错误以便编译和 运行 程序。
DeviceFun<<<1, len>>>(&v, &len0, &len1);
DeviceFun的签名是:
DeviceFun(int* arr, int len0, int len1)
但是,您将指向 len0 和 len1 的指针传递给函数。我认为您应该这样调用 DeviceFun:
DeviceFun<<1, len>>(&v[0], len0, len1);