Skip to content

Commit 9d89307

Browse files
committed
Adding raw_ptr()
1 parent 417e841 commit 9d89307

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

arrayfire/array.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,25 @@ def __del__(self):
454454
backend.get().af_release_array(self.arr)
455455

456456
def device_ptr(self):
457+
"""
458+
Return the device pointer exclusively held by the array.
459+
460+
Returns
461+
------
462+
ptr : int
463+
Contains location of the device pointer
464+
465+
Note
466+
----
467+
- This can be used to integrate with custom C code and / or PyCUDA or PyOpenCL.
468+
- No other arrays will share the same device pointer.
469+
- If multiple arrays share the same memory a copy of the memory is done and a pointer to the new copy is returned.
470+
"""
471+
ptr = ct.c_void_p(0)
472+
backend.get().af_get_device_ptr(ct.pointer(ptr), self.arr)
473+
return ptr.value
474+
475+
def raw_ptr(self):
457476
"""
458477
Return the device pointer held by the array.
459478
@@ -466,9 +485,10 @@ def device_ptr(self):
466485
----
467486
- This can be used to integrate with custom C code and / or PyCUDA or PyOpenCL.
468487
- No mem copy is peformed, this function returns the raw device pointer.
488+
- This pointer may be shared with other arrays. Use this function with caution.
469489
"""
470490
ptr = ct.c_void_p(0)
471-
backend.get().af_get_device_ptr(ct.pointer(ptr), self.arr)
491+
backend.get().af_get_raw_ptr(ct.pointer(ptr), self.arr)
472492
return ptr.value
473493

474494
def elements(self):

0 commit comments

Comments
 (0)