Here are the basics…I get this error when writing to write to a pointer…
typedef struct{
float *rmin;
.
.
.
double *detect;
int ndetect;
} kParams;
typedef struct{
int rmin_S;
.
.
.
int detect_S;
}kSizes;
__global__ void kernel(kParams *d_kp, kSizes d_ks){
for(int i=0;i<d_kp[0].ndetect;i++){
d_kp[0].rmin[i]=d_kp[0].detect[i]; // fails because of this
}
}
int main(){
kParams *h_kp=NULL;
kParams *d_kp=NULL;
kSizes h_ks;
h_kp=(kParams*)malloc(sizeof(kParams));
cudaMalloc((void**)&d_kp,sizeof(kParams));
cudaMalloc((void**)&h_kp[0].detect,sizeof(double));
cudaMalloc((void**)&h_kp[0].rmin,sizeof(float));
h_kp[0].ndetect=1;
cudaMemcpy(d_kp[0].detect,h_kp[0].detect,sizeof(double));
cudaMemcpy(d_kp[0].rmin,h_kp[0].rmin,sizeof(float));
kernel<<<1,2>>>(d_kp,d_ks);
.
.
.
// copy back and free memory
.
.
.
}
can anyone give me soem insight as to why this might be failing?