I am a Java programmer and new to C++ and Cuda. I am getting a segmentation fault doing below:
Input.h
class Input {
public:
const LucyDecimal * sellingPrice; //Ri
const LucyDecimal qc;
public:
Input(
const LucyDecimal * _sellingPrice,
const LucyDecimal _qc);
virtual ~Input();
};
Input.cpp
Input::Input(
const LucyDecimal * _sellingPrice, //Ri
const LucyDecimal _qc):sellingPrice(_sellingPrice),qc(_qc)
{};
Input::~Input() {
}
Now in my CudaRun.cu
void mainRun(Input in) {
Input *deviceIn;
deviceIn = new Input(NULL, NULL, NULL, NULL, 0.0, NULL,0.0,0.0,NULL,0.0,NULL,0.0);
//line-a
printf("Started. Just abt to call cuda \n");
int size = sizeof(Input);
cudaMalloc((void**) &deviceIn, size);
cudaMemcpy(deviceIn, &in, size, cudaMemcpyHostToDevice);
cudaMalloc((void**) deviceIn->sellingPrice, 4 * sizeof(LucyDecimal));
//line-b
....
}
I get a segmentation fault at line-b
. Has it got to do with line-a
initialization?