@@ -115,8 +115,26 @@ namespace af
115115 // /
116116 // / \note The device memory returned by this function is only freed if
117117 // / af::free() is called explicitly
118+ // / \deprecated Use allocV2 instead. allocV2 accepts number of bytes
119+ // / instead of number of elements and returns a cl_mem object
120+ // / instead of the cl::Buffer object for the OpenCL backend.
121+ // / Otherwise the functionallity is identical to af::alloc.
122+ AF_DEPRECATED (" Use af::allocV2 instead" )
118123 AFAPI void *alloc (const size_t elements, const dtype type);
119124
125+ #if AF_API_VERSION >= 38
126+ // / \brief Allocates memory using ArrayFire's memory manager
127+ // /
128+ // / \param[in] bytes the number of bytes to allocate
129+ // / \returns Pointer to the device memory on the current device. This is a
130+ // / CUDA device pointer for the CUDA backend. A cl_mem pointer
131+ // / on the OpenCL backend and a C pointer for the CPU backend
132+ // /
133+ // / \note The device memory returned by this function is only freed if
134+ // / af::freeV2() is called explicitly
135+ AFAPI void *allocV2 (const size_t bytes);
136+ #endif
137+
120138 // / \brief Allocates memory using ArrayFire's memory manager
121139 //
122140 // / \param[in] elements the number of elements to allocate
@@ -129,7 +147,13 @@ namespace af
129147 // / sizeof(type)
130148 // / \note The device memory returned by this function is only freed if
131149 // / af::free() is called explicitly
132- template <typename T> T *alloc (const size_t elements);
150+ // / \deprecated Use allocV2 instead. allocV2 accepts number of bytes
151+ // / instead of number of elements and returns a cl_mem object
152+ // / instead of the cl::Buffer object for the OpenCL backend.
153+ // / Otherwise the functionallity is identical to af::alloc.
154+ template <typename T>
155+ AF_DEPRECATED (" Use af::allocV2 instead" )
156+ T *alloc (const size_t elements);
133157 // / @}
134158
135159 // / \ingroup device_func_free
@@ -140,8 +164,22 @@ namespace af
140164 // /
141165 // / \note This function will free a device pointer even if it has been
142166 // / previously locked.
167+ // / \deprecated Use af::freeV2 instead. af_alloc_device_v2 returns a
168+ // / cl_mem object instead of the cl::Buffer object for the
169+ // / OpenCL backend. Otherwise the functionallity is identical
170+ AF_DEPRECATED (" Use af::freeV2 instead" )
143171 AFAPI void free (const void *ptr);
144172
173+ #if AF_API_VERSION >= 38
174+ // / \ingroup device_func_free
175+ // / \copydoc device_func_free
176+ // / \param[in] ptr The pointer returned by af::allocV2
177+ // /
178+ // / This function will free a device pointer even if it has been previously
179+ // / locked.
180+ AFAPI void freeV2 (const void *ptr);
181+ #endif
182+
145183 // / \ingroup device_func_pinned
146184 // / @{
147185 // / \copydoc device_func_pinned
@@ -330,7 +368,11 @@ extern "C" {
330368
331369 \returns AF_SUCCESS if a pointer could be allocated. AF_ERR_NO_MEM if
332370 there is no memory
371+ \deprecated Use af_alloc_device_v2 instead. af_alloc_device_v2 returns a
372+ cl_mem object instead of the cl::Buffer object for the OpenCL
373+ backend. Otherwise the functionallity is identical
333374 */
375+ AF_DEPRECATED (" Use af_alloc_device_v2 instead" )
334376 AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes);
335377
336378 /* *
@@ -341,10 +383,45 @@ extern "C" {
341383
342384 \param[in] ptr The pointer allocated by af_alloc_device to be freed
343385
386+ \deprecated Use af_free_device_v2 instead. The new function handles the
387+ new behavior of the af_alloc_device_v2 function.
344388 \ingroup device_func_free
345389 */
390+ AF_DEPRECATED (" Use af_free_device_v2 instead" )
346391 AFAPI af_err af_free_device(void *ptr);
347392
393+ #if AF_API_VERSION >= 38
394+ /* *
395+ \brief Allocates memory using ArrayFire's memory manager
396+
397+ This device memory returned by this function can only be freed using
398+ af_free_device_v2.
399+
400+ \param [out] ptr Pointer to the device memory on the current device. This
401+ is a CUDA device pointer for the CUDA backend. A
402+ cl::Buffer pointer on the OpenCL backend and a C pointer
403+ for the CPU backend
404+ \param [in] bytes The number of bites to allocate on the device
405+
406+ \returns AF_SUCCESS if a pointer could be allocated. AF_ERR_NO_MEM if
407+ there is no memory
408+ \ingroup device_func_alloc
409+ */
410+ AFAPI af_err af_alloc_device_v2 (void **ptr, const dim_t bytes);
411+
412+ /* *
413+ \brief Returns memory to ArrayFire's memory manager.
414+
415+ This function will free a device pointer even if it has been previously
416+ locked.
417+
418+ \param[in] ptr The pointer allocated by af_alloc_device_v2 to be freed
419+ \note this function will not work for pointers allocated using the
420+ af_alloc_device function for all backends
421+ \ingroup device_func_free
422+ */
423+ AFAPI af_err af_free_device_v2 (void *ptr);
424+ #endif
348425 /* *
349426 \ingroup device_func_pinned
350427 */
0 commit comments