- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

device.h
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11 #include <af/defines.h>
12
13 #ifdef __cplusplus
14 namespace af
15 {
26 AFAPI void info();
41 AFAPI void deviceInfo(char* d_name, char* d_platform, char *d_toolkit, char* d_compute);
46 AFAPI int getDeviceCount();
52
58 AFAPI int getDevice();
59
67 AFAPI bool isDoubleAvailable(const int device);
68
73 AFAPI void setDevice(const int device);
74
79 AFAPI void sync(const int device = -1);
80
90 AFAPI void *alloc(const size_t elements, const dtype type);
91
93 //
100 template<typename T>
101 T* alloc(const size_t elements);
103
112 AFAPI void *pinned(const size_t elements, const dtype type);
113
118 template<typename T>
119 T* pinned(const size_t elements);
121
126 AFAPI void free(const void *ptr);
127
129 AFAPI void freePinned(const void *ptr);
131
137 // manager
139 // manager
142 AFAPI void deviceMemInfo(size_t *alloc_bytes, size_t *alloc_buffers,
143 size_t *lock_bytes, size_t *lock_buffers);
144
148 AFAPI void deviceGC();
150
154 AFAPI void setMemStepSize(const size_t size);
155
159 AFAPI size_t getMemStepSize();
160 }
161 #endif
162
163 #ifdef __cplusplus
164 extern "C" {
165 #endif
166
170 AFAPI af_err af_info();
171
172 AFAPI af_err af_init();
173
177 AFAPI af_err af_device_info(char* d_name, char* d_platform, char *d_toolkit, char* d_compute);
178
182 AFAPI af_err af_get_device_count(int *num_of_devices);
183
187 AFAPI af_err af_get_dbl_support(bool* available, const int device);
188
192 AFAPI af_err af_set_device(const int device);
193
197 AFAPI af_err af_get_device(int *device);
198
202 AFAPI af_err af_sync(const int device);
203
207 AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes);
208
212 AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes);
213
217 AFAPI af_err af_free_device(void *ptr);
218
222 AFAPI af_err af_free_pinned(void *ptr);
223
228 AFAPI af_err af_device_array(af_array *arr, const void *data, const unsigned ndims, const dim_t * const dims, const af_dtype type);
229
234 AFAPI af_err af_device_mem_info(size_t *alloc_bytes, size_t *alloc_buffers,
235 size_t *lock_bytes, size_t *lock_buffers);
236
241 AFAPI af_err af_device_gc();
242
247 AFAPI af_err af_set_mem_step_size(const size_t step_bytes);
248
253 AFAPI af_err af_get_mem_step_size(size_t *step_bytes);
254
255 #if AF_API_VERSION >= 31
256
262 AFAPI af_err af_lock_device_ptr(const af_array arr);
263 #endif
264
265 #if AF_API_VERSION >= 31
266
272 AFAPI af_err af_unlock_device_ptr(const af_array arr);
273 #endif
274
281 AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr);
282
283
284 #ifdef __cplusplus
285 }
286 #endif
af
Definition: algorithm.h:14
af_sync
AFAPI af_err af_sync(const int device)
af_get_device_ptr
AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr)
Get the device pointer and lock the buffer in memory manager.
af_device_gc
AFAPI af_err af_device_gc()
Call the garbage collection routine.
af::pinned
AFAPI void * pinned(const size_t elements, const dtype type)
Allocate pinned memory using ArrayFire's memory manager.
af_free_device
AFAPI af_err af_free_device(void *ptr)
af_init
AFAPI af_err af_init()
af::getMemStepSize
AFAPI size_t getMemStepSize()
Get the resolution of memory chunks.
af::info
AFAPI void info()
af_set_device
AFAPI af_err af_set_device(const int device)
af_alloc_pinned
AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes)
af_info
AFAPI af_err af_info()
af::deviceGC
AFAPI void deviceGC()
Call the garbage collection function in the memory manager.
af_alloc_device
AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes)
af::setMemStepSize
AFAPI void setMemStepSize(const size_t size)
Set the resolution of memory chunks.
af_err
af_err
Definition: defines.h:67
defines.h
dim_t
long long dim_t
Definition: defines.h:50
af_get_mem_step_size
AFAPI af_err af_get_mem_step_size(size_t *step_bytes)
Get the minimum memory chunk size.
af_get_device_count
AFAPI af_err af_get_device_count(int *num_of_devices)
AFAPI
#define AFAPI
Definition: defines.h:31
af::sync
AFAPI void sync(const int device=-1)
Blocks until the device is finished processing.
af::free
AFAPI void free(const void *ptr)
Free device memory allocated by ArrayFire's memory manager.
af_lock_device_ptr
AFAPI af_err af_lock_device_ptr(const af_array arr)
Lock the device buffer in the memory manager.
af_set_mem_step_size
AFAPI af_err af_set_mem_step_size(const size_t step_bytes)
Set the minimum memory chunk size.
af::isDoubleAvailable
AFAPI bool isDoubleAvailable(const int device)
Queries the current device for double precision floating point support.
af_unlock_device_ptr
AFAPI af_err af_unlock_device_ptr(const af_array arr)
Unlock device buffer in the memory manager.
af::deviceInfo
AFAPI void deviceInfo(char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
af_device_array
AFAPI af_err af_device_array(af_array *arr, const void *data, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create array from device memory.
af_device_info
AFAPI af_err af_device_info(char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
af_get_device
AFAPI af_err af_get_device(int *device)
af_array
void * af_array
Definition: defines.h:187
af::alloc
AFAPI void * alloc(const size_t elements, const dtype type)
Allocates memory using ArrayFire's memory manager.
af::deviceMemInfo
AFAPI void deviceMemInfo(size_t *alloc_bytes, size_t *alloc_buffers, size_t *lock_bytes, size_t *lock_buffers)
Gets information about the memory manager.
af_free_pinned
AFAPI af_err af_free_pinned(void *ptr)
af_get_dbl_support
AFAPI af_err af_get_dbl_support(bool *available, const int device)
af::getDeviceCount
AFAPI int getDeviceCount()
Gets the number of devices.
af_device_mem_info
AFAPI af_err af_device_mem_info(size_t *alloc_bytes, size_t *alloc_buffers, size_t *lock_bytes, size_t *lock_buffers)
Get memory information from the memory manager.
af_dtype
af_dtype
Definition: defines.h:166
af::freePinned
AFAPI void freePinned(const void *ptr)
Free device memory allocated by ArrayFire's memory manager.
af::dtype
af_dtype dtype
Definition: defines.h:329
af::setDevice
AFAPI void setDevice(const int device)
Sets the current device.
af::getDevice
AFAPI int getDevice()
Gets the current device ID.