1616
1717#if AF_API_VERSION >= 37
1818
19- typedef void * af_buffer_info;
20-
2119typedef void * af_memory_manager ;
2220
23- #ifdef __cplusplus
24- namespace af {
25-
26- // / A simple RAII wrapper for af_buffer_info
27- class AFAPI buffer_info {
28- af_buffer_info p_;
29-
30- public:
31- buffer_info (af_buffer_info p);
32- buffer_info (void * ptr, af_event event);
33- ~buffer_info ();
34- #if AF_COMPILER_CXX_RVALUE_REFERENCES
35- buffer_info (buffer_info&& other);
36- buffer_info& operator =(buffer_info&& other);
37- #endif
38- void * getPtr () const ;
39- void setPtr (void * ptr);
40- af_event getEvent () const ;
41- void setEvent (af_event event);
42- af_buffer_info get () const ;
43- af_event unlockEvent ();
44- void * unlockPtr ();
45-
46- private:
47- buffer_info& operator =(const buffer_info& other);
48- buffer_info (const buffer_info& other);
49- };
50-
51- } // namespace af
52- #endif // __cplusplus
53-
5421#ifdef __cplusplus
5522extern "C" {
5623#endif // __cplusplus
5724
58- /* *
59- \brief Creates an \ref af_buffer_info handle from an \ref af_event event and
60- ptr
61-
62- \param[in] buf The \ref af_buffer_info object to be created
63- \param[in] ptr A pointer
64- \param[in] event An \ref af_event
65- \returns AF_SUCCESS
66-
67- \ingroup buffer_info
68- */
69- AFAPI af_err af_create_buffer_info (af_buffer_info* buf, void * ptr,
70- af_event event);
71-
72- /* *
73- \brief deletes the \ref af_buffer_info and its resources
74-
75- Deletes the \ref af_buffer_info object and its tracked resources. If buffer
76- still holds a pointer, that pointer is freed. Does NOT enqueue a wait on the
77- associated event
78-
79- \param[in] buf The \ref af_buffer_info object that will be deleted
80- \returns AF_SUCCESS
81-
82- \ingroup buffer_info
83- */
84- AFAPI af_err af_delete_buffer_info (af_buffer_info buf);
85-
86- /* *
87- \brief Retrieves a pointer from an \ref af_buffer_info
88-
89- \param[out] ptr The associated pointer
90- \param[in] buf The \ref af_buffer_info object
91- \returns AF_SUCCESS
92-
93- \ingroup buffer_info
94- */
95- AFAPI af_err af_buffer_info_get_ptr (void ** ptr, af_buffer_info buf);
96-
97- /* *
98- \brief Retrieves an \ref af_event from an \ref af_buffer_info
99-
100- \param[out] event The associated event
101- \param[in] buf The \ref af_buffer_info object
102- \returns AF_SUCCESS
103-
104- \ingroup buffer_info
105- */
106- AFAPI af_err af_buffer_info_get_event (af_event* event, af_buffer_info buf);
107-
108- /* *
109- \brief Sets a pointer on an \ref af_buffer_info
110-
111- \param[in] buf The \ref af_buffer_info object
112- \param[in] ptr The pointer to set
113- \returns AF_SUCCESS
114-
115- \ingroup buffer_info
116- */
117- AFAPI af_err af_buffer_info_set_ptr (af_buffer_info buf, void * ptr);
118-
119- /* *
120- \brief Sets an \ref af_event on an \ref af_buffer_info
121-
122- \param[in] buf The \ref af_buffer_info object
123- \param[in] event The \ref af_event to set
124- \returns AF_SUCCESS
125-
126- \ingroup buffer_info
127- */
128- AFAPI af_err af_buffer_info_set_event (af_buffer_info buf, af_event event);
129-
130- /* *
131- \brief Disassociates the \ref af_event from the \ref af_buffer_info object
132-
133- Gets the \ref af_event and disassociated it from the af_buffer_info object.
134- Deleting the af_buffer_info object will not affect this event.
135-
136- \param[out] event The \ref af_event that will be disassociated. If NULL no
137- event is returned and the event is NOT freed
138- \param[in] buf The target \ref af_buffer_info object
139- \returns AF_SUCCESS
140-
141- \ingroup buffer_info
142- */
143- AFAPI af_err af_unlock_buffer_info_event (af_event* event, af_buffer_info buf);
144-
145- /* *
146- \brief Disassociates the pointer from the \ref af_buffer_info object
147-
148- Gets the pointer and disassociated it from the \ref af_buffer_info object.
149- Deleting the \ref af_buffer_info object will not affect this pointer.
150-
151- \param[out] ptr The pointer that will be disassociated. If NULL no
152- pointer is returned and the data is NOT freed.
153- \param[in] buf The target \ref af_buffer_info object
154- \returns AF_SUCCESS
155-
156- \ingroup buffer_info
157- */
158- AFAPI af_err af_unlock_buffer_info_ptr (void ** ptr, af_buffer_info buf);
159-
16025/**
16126 \brief Called after a memory manager is set and becomes active.
16227
@@ -181,8 +46,7 @@ typedef af_err (*af_memory_manager_shutdown_fn)(af_memory_manager handle);
18146 \brief Function pointer that will be called by ArrayFire to allocate memory.
18247
18348 \param[in] handle a pointer to the active \ref af_memory_manager handle
184- \param[out] buffer_info a pointer to a \ref af_buffer_info containing the
185- pointer to the allocated buffer and an associated \ref af_event
49+ \param[out] ptr pointer to the allocated buffer
18650 \param[in] bytes number of bytes to allocate
18751 \param[in] user_lock a truthy value corresponding to whether or not the
18852 memory should have a user lock associated with it
@@ -198,7 +62,7 @@ typedef af_err (*af_memory_manager_shutdown_fn)(af_memory_manager handle);
19862 \ingroup memory_manager_api
19963*/
20064typedef af_err (* af_memory_manager_alloc_fn )(af_memory_manager handle ,
201- af_buffer_info* buffer_info ,
65+ void * * ptr ,
20266 /* bool */ int user_lock ,
20367 const unsigned ndims , dim_t * dims ,
20468 const unsigned element_size );
@@ -221,16 +85,13 @@ typedef af_err (*af_memory_manager_allocated_fn)(af_memory_manager handle,
22185
22286 \param[in] handle a pointer to the active \ref af_memory_manager handle
22387 \param[out] ptr the pointer to query
224- \param[in] event a new \ref af_event which will be marked before the free is
225- executed such that enqueing a wait on this event
22688 \param[in] user_unlock frees the memory from user lock
22789 \returns AF_SUCCESS
22890
22991 \ingroup memory_manager_api
23092*/
23193typedef af_err (* af_memory_manager_unlock_fn )(af_memory_manager handle ,
232- void * ptr, af_event event,
233- /* bool */ int user_unlock);
94+ void * ptr , /* bool */ int user_unlock );
23495
23596/**
23697 \brief Called to signal the memory manager should free memory if possible
0 commit comments