저는 Java 프로그래머이며 C++ 및 Cuda를 처음 사용합니다. CudaRun.cu
분할 오류 C++ Cuda
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
....
}
내가 세그먼트 오류에서 얻을 내 지금
Input.h
클래스 입력 {
public:
const LucyDecimal * sellingPrice; //Ri
const LucyDecimal qc;
public:
Input(
const LucyDecimal * _sellingPrice,
const LucyDecimal _qc);
virtual ~Input();
};
Input::Input(
const LucyDecimal * _sellingPrice, //Ri
const LucyDecimal _qc):sellingPrice(_sellingPrice),qc(_qc)
{};
Input::~Input() {
}
: 나는 다음 일을 세그먼트 오류를 얻고있다 line-b
. line-a
초기화와 관련이 있습니까?
그러나'sellingPrice_temp'는 어떻게 값을 얻을 것입니까? – Jatin
'sellingPrice_temp'의 포인터 값은 다음과 같은 'cudaMalloc' 연산에 의해 설정됩니다 (http://stackoverflow.com/questions/12936986/why-does-cudamalloc-use-pointer-to-pointer/12937162#12937162). 호스트 코드 에서처럼'sellingPrice_temp'의 선언 바로 뒤에 나의 대답에 나열된'malloc' 연산은 포인터 값을 반환합니다. –
당신의 대답이 도움이되었습니다 : http://stackoverflow.com/questions/22156536/cudamalloc-of-a-structure-and-an-element-of-same-structure 하지만 그 대답은'cudeMemcpy'입니다. 구조.그래서'foo' 값을 어떻게 얻을 수 있습니까? – Jatin