say i have class like this
class TheBox{
public:
int value1;
int value2;
int **p;
int size;
int result;
int test(){
result = 0;
for (int i = 0; i < size; i++){
result += *p[i];
}
return result;
}
};
and i use it like this
int main(){
TheBox b;
b.value1 = 5;
b.value2 = 7;
b.size = 10;
b.p = (int**)malloc(sizeof(int*)*b.size);
b.p[0] = &b.value1;
b.p[1] = &b.value1;
b.p[2] = &b.value2;
b.p[3] = &b.value1;
b.p[4] = &b.value1;
b.p[5] = &b.value2;
b.p[6] = &b.value2;
b.p[7] = &b.value1;
b.p[8] = &b.value1;
b.p[9] = &b.value1;
cout << b.host() << endl; //should output 56
b.value2 = 8;
cout << b.host() << endl; //should output 59
}
My question is how do i do cudaMemCpy for object "b"?
The problem occurs when trying to copy array "p" i have to know beforehand whether it contains value1 or value2.
Is there a way to correctly do cudaMemcpy for object "b" without this information?