CXX0030: ошибка: выражение не может быть оценено, Visual Studio && CUDA
Всякий раз, когда я пытаюсь запустить код в отладчике, который я разместил ниже, он всегда показывает сообщение об ошибке на указателе устройства, например в переменной check_d, check_re_h ... говоря
CXX0030: ошибка: выражение не может быть оценено.
Я очень новичок в CUDA и визуальной студии, поэтому любая помощь будет принята с благодарностью.
#include
//#include
//#include"sourceannotations.h"
#include
//#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PI 3.141592654
using namespace std;
// #define checkCudaErrors(err) __checkCudaErrors (err, __FILE__, __LINE__)
struct vertex
{
float x,y,z,h;
// struct triangle* _triangle ;
// struct octree* tree ;
vertex():x(0),y(0),z(0),h(1){};//,tree(NULL)/*, _triangle(NULL)*/{}
vertex(float x, float y, float z, float h=0):x(x),y(y),z(z),h(h){};//,/*_triangle(NULL),*/tree(NULL){}
};
struct triangle
{
vertex v1,v2,v3;
triangle(){
//v1._triangle = v2._triangle = v3._triangle = this;
}
};
//if the function is decleared as global then it is run by multiple threads parallelly
__global__ void VecAdd(/*int *A, int *B, int *C,*/ int *check)
{
//int count =0;
int idx = blockIdx.x+ threadIdx.x;
// int count=0;
//int tx = threadIdx.x;
//this is for checking the value of idx
check[idx] = idx;
//C[idx] = A[idx] + B[idx];
}
__global__ void check(float mat[][4],vertex *a,float *re,int *index)
{
// float re[4];
float sum =0;
int idx = blockIdx.x+ threadIdx.x;
// index[idx] = idx;
//int count=0;
//int tx = threadIdx.x;
/*for (int i=0; ix;
sum += mat[idx][1]* a->y;
sum += mat[idx][2]* a->z;
sum += mat[idx][3];
/*sum += *((float*)mat+idx+4*0)* a->x;
sum += *((float*)mat+idx+4*1)* a->y;
sum += *((float*)mat+idx+4*2)* a->z;
sum += *((float*)mattr+idx+4*3);*/
/*}*/
re[idx] = sum;
}
int main()
{
//float res[4][4];
triangle t1;
t1.v1.x = 2;
t1.v1.y = 1.33512;
t1.v1.z = 5.849567;
t1.v2.x = 2;
t1.v2.y = -1.33512;
t1.v2.z = 5.849567;
t1.v3.x = 2;
t1.v3.y = 0;
t1.v3.z = 5;
vertex *check_d;
vertex *check_h;
float *check_re_d;
float *check_re_h;
float translation_check_d[4][4];
float translation_check_h[4][4] = {{1, 0, 0, -t1.v1.x},
{0, 1, 0, -t1.v1.y},
{0, 0, 1, -t1.v1.z},
{0 ,0 ,0, 1}};
check_h = new vertex(1,-4,3);
check_re_h = new float[4];
cudaMalloc((void**)&check_d,sizeof(vertex));
cudaMalloc((void**)&check_re_d,4*sizeof(float));
cudaMemcpy(check_d,check_h,sizeof(vertex),cudaMemcpyHostToDevice);
cudaMemcpy(check_re_d,check_re_h,4*sizeof(float),cudaMemcpyHostToDevice);
size_t dPitch;
cudaMallocPitch((void**)translation_check_d,&dPitch,4*sizeof(float),4);
cudaMemcpy2D(translation_check_d,dPitch,translation_check_h,dPitch,4*sizeof(float),4,cudaMemcpyHostToDevice);
int *index_h = NULL;
int *index_d = NULL;
index_h = new int[4];
cudaMalloc((void**)&index_d,4*sizeof(int));
cudaMemcpy(index_d,index_h,sizeof(int),cudaMemcpyHostToDevice);
check(translation_check_d,check_d,check_re_d,index_d);
//VecAdd(index_d);
cudaMemcpy(check_re_h,check_re_d,4*sizeof(float),cudaMemcpyDeviceToHost);
cudaMemcpy(index_h,index_d,4*sizeof(int),cudaMemcpyDeviceToHost);
std::cout