Timeline for Pointer to Array of Pointers to Objects in CUDA
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 17, 2016 at 7:39 | vote | accept | CodingLumis | ||
Aug 17, 2016 at 7:32 | comment | added | CodingLumis |
I think I understand my mis-understanding in question 1. Obj** h_d_obj = (Obj**)malloc(sizeof(Obj*) * 3); allocates host memory enough to hold 3 pointers and returns a pointer to the memory to h_d_obj then cudaMalloc((void**)&h_d_obj[i], sizeof(Obj)); dereferences h_d_obj[i] to get the i-th pointer in host memory (although this pointer has never been set), then gets the address of this pointer with & to which cudaMalloc returns the address of an Obj in device memory. So h_d_obj points to host memory with device pointers and although h_d_obj has changed h_d_obj hasn't.
|
|
Aug 17, 2016 at 7:27 | comment | added | CodingLumis | Thank you @Robert Crovella for your answer. The diagram is very helpful. Also thank you for being so polite in by describing my confusion as "less-than-crisp", very kind of you :) | |
Aug 16, 2016 at 18:48 | history | edited | Robert Crovella | CC BY-SA 3.0 |
clean up
|
Aug 16, 2016 at 18:05 | history | edited | Robert Crovella | CC BY-SA 3.0 |
add host/device diagram
|
Aug 16, 2016 at 17:54 | history | answered | Robert Crovella | CC BY-SA 3.0 |