Open Dart120 opened 7 months ago
ptrToDeviceA
points to the host memory, so dereferencing it on the device is invalid.
ptrToDeviceA
points to the host memory, so dereferencing it on the device is invalid.
I thought since ptrToDeviceA is now pointing to device memory then it would be okay to dereference on the device?
because of
// Redirect ptrToDeviceA to the new device memory allocation
*ptrToDeviceA = newDeviceA;
*ptrToDeviceA
points to device memory, but not ptrToDeviceA
.
*ptrToDeviceA
points to device memory, but notptrToDeviceA
Okay so ptrToDeviceA is a host memory pointer to a device memory pointer and that's why it doesn't work? In that case, how can I do what I was trying to do in this code without the error? Thank you?
I'm not sure what you are trying to do, but if you make memory allocation for deviceA
is accessible from the device, the code should work.
So change
MyStruct* deviceA = nullptr;
to
MyStruct* deviceA = malloc_device<MyStruct>(1, q);
I have just tried this and it didn't work
Here is what I mean:
MyStruct** ptrToDeviceA = malloc_shared<MyStruct*>(1, q);
manipulateStruct(ptrToDeviceA, q);
Ah okay, is it not possible to just use malloc_device in this case? If not why? Sorry about all the questions, just trying to wrap my head around it!
If I get it right, you want to override *ptrToDeviceA
on the host. malloc_device
allocations are not accessible from the host.
Please, read USM section of the spec: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_kinds_of_unified_shared_memory.
Describe the bug
Outside of the function the pointer is null, I pass a pointer to this pointer to the function Inside the function I allocate device memory for a struct, then change a field and then assign a pointer to the allocated struct to the pointer passed to the function. I then print the field. Once I leave the function I print the field. The first print doesn't work but the second does. I'm not sure why :(
To reproduce
Code Snippet
Compiled with
Error message
Expected
"This many nnz: 100"
Environment
OS: Linux "pop OS" Device and Vendor: Nvidia, RTX 2080ti clang version 19.0.0git (https://github.com/intel/llvm db6a05d101b990ead474b23a9c8c8ebc6e5710c9)
Additional context
lmk if you need more info