A high-performance general-purpose compute library

- Main Page
- Tutorials
- 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();
47 AFAPI const char* infoString(const bool verbose = false);
57 AFAPI void deviceInfo(char* d_name, char* d_platform, char *d_toolkit, char* d_compute);
58
64 AFAPI int getDeviceCount();
65
71 AFAPI int getDevice();
72
81 AFAPI bool isDoubleAvailable(const int device);
82
91 AFAPI bool isHalfAvailable(const int device);
92
97 AFAPI void setDevice(const int device);
98
103 AFAPI void sync(const int device = -1);
104
122 AF_DEPRECATED("Use af::allocV2 instead")
123 AFAPI void *alloc(const size_t elements, const dtype type);
124
125#if AF_API_VERSION >= 38
135 AFAPI void *allocV2(const size_t bytes);
136#endif
137
139 //
154 template <typename T>
155 AF_DEPRECATED("Use af::allocV2 instead")
156 T *alloc(const size_t elements);
158
170 AF_DEPRECATED("Use af::freeV2 instead")
171 AFAPI void free(const void *ptr);
172
173#if AF_API_VERSION >= 38
180 AFAPI void freeV2(const void *ptr);
181#endif
182
190 AFAPI void *pinned(const size_t elements, const dtype type);
191
196 template<typename T>
197 T* pinned(const size_t elements);
199
204 AFAPI void freePinned(const void *ptr);
205
206#if AF_API_VERSION >= 33
216 AFAPI void *allocHost(const size_t elements, const dtype type);
217#endif
218
219#if AF_API_VERSION >= 33
231 template<typename T>
232 AFAPI T* allocHost(const size_t elements);
233#endif
234
235#if AF_API_VERSION >= 33
237 //
243 AFAPI void freeHost(const void *ptr);
244#endif
245
251 // manager
253 // manager
258 AFAPI void deviceMemInfo(size_t *alloc_bytes, size_t *alloc_buffers,
259 size_t *lock_bytes, size_t *lock_buffers);
260
261#if AF_API_VERSION >= 33
264 //
268 //
272 AFAPI void printMemInfo(const char *msg = NULL, const int device_id = -1);
273#endif
274
278 AFAPI void deviceGC();
280
285 AFAPI void setMemStepSize(const size_t size);
286
291 AFAPI size_t getMemStepSize();
292}
293#endif
294
295#ifdef __cplusplus
296 extern "C" {
297#endif
298
302 AFAPI af_err af_info();
303
307 AFAPI af_err af_init();
308
317 AFAPI af_err af_info_string(char** str, const bool verbose);
318
324 AFAPI af_err af_device_info(char* d_name, char* d_platform, char *d_toolkit, char* d_compute);
325
329 AFAPI af_err af_get_device_count(int *num_of_devices);
330
334 AFAPI af_err af_get_dbl_support(bool* available, const int device);
335
339 AFAPI af_err af_get_half_support(bool *available, const int device);
340
344 AFAPI af_err af_set_device(const int device);
345
349 AFAPI af_err af_get_device(int *device);
350
354 AFAPI af_err af_sync(const int device);
355
375 AF_DEPRECATED("Use af_alloc_device_v2 instead")
376 AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes);
377
390 AF_DEPRECATED("Use af_free_device_v2 instead")
391 AFAPI af_err af_free_device(void *ptr);
392
393#if AF_API_VERSION >= 38
410 AFAPI af_err af_alloc_device_v2(void **ptr, const dim_t bytes);
411
423 AFAPI af_err af_free_device_v2(void *ptr);
424#endif
428 AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes);
429
433 AFAPI af_err af_free_pinned(void *ptr);
434
435#if AF_API_VERSION >= 33
439 AFAPI af_err af_alloc_host(void **ptr, const dim_t bytes);
440#endif
441
442#if AF_API_VERSION >= 33
446 AFAPI af_err af_free_host(void *ptr);
447#endif
448
453 AFAPI af_err af_device_array(af_array *arr, void *data, const unsigned ndims, const dim_t * const dims, const af_dtype type);
454
459 AFAPI af_err af_device_mem_info(size_t *alloc_bytes, size_t *alloc_buffers,
460 size_t *lock_bytes, size_t *lock_buffers);
461
462#if AF_API_VERSION >= 33
485 AFAPI af_err af_print_mem_info(const char *msg, const int device_id);
486#endif
487
492 AFAPI af_err af_device_gc();
493
500 AFAPI af_err af_set_mem_step_size(const size_t step_bytes);
501
508 AFAPI af_err af_get_mem_step_size(size_t *step_bytes);
509
510#if AF_API_VERSION >= 31
517#if AF_API_VERSION >= 33
518 AF_DEPRECATED("Use af_lock_array instead")
519#endif
520 AFAPI af_err af_lock_device_ptr(const af_array arr);
521#endif
522
523#if AF_API_VERSION >= 31
530#if AF_API_VERSION >= 33
531 AF_DEPRECATED("Use af_unlock_array instead")
532#endif
533 AFAPI af_err af_unlock_device_ptr(const af_array arr);
534#endif
535
536#if AF_API_VERSION >= 33
543 AFAPI af_err af_lock_array(const af_array arr);
544#endif
545
546#if AF_API_VERSION >= 33
553 AFAPI af_err af_unlock_array(const af_array arr);
554#endif
555
556#if AF_API_VERSION >= 34
565 AFAPI af_err af_is_locked_array(bool *res, const af_array arr);
566#endif
567
576 AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr);
577
578#if AF_API_VERSION >= 38
596 AFAPI af_err af_set_kernel_cache_directory(const char* path,
597 int override_env);
598
618 AFAPI af_err af_get_kernel_cache_directory(size_t *length, char *path);
619
620#endif
621
622#ifdef __cplusplus
623}
624#endif
defines.h
af_dtype
af_dtype
Definition defines.h:210
dim_t
long long dim_t
Definition defines.h:56
af_err
af_err
Definition defines.h:71
af_array
void * af_array
Definition defines.h:240
AF_DEPRECATED
#define AF_DEPRECATED(msg)
Definition defines.h:44
AFAPI
#define AFAPI
Definition defines.h:38
af_device_array
AFAPI af_err af_device_array(af_array *arr, void *data, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create array from device memory.
af_alloc_host
AFAPI af_err af_alloc_host(void **ptr, const dim_t bytes)
af::allocHost
AFAPI void * allocHost(const size_t elements, const dtype type)
Allocate memory on host.
af::allocV2
AFAPI void * allocV2(const size_t bytes)
Allocates memory using ArrayFire's memory manager.
af_alloc_device
AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes)
Allocates memory using ArrayFire's memory manager.
af::alloc
AFAPI void * alloc(const size_t elements, const dtype type)
Allocates memory using ArrayFire's memory manager.
af_alloc_device_v2
AFAPI af_err af_alloc_device_v2(void **ptr, const dim_t bytes)
Allocates memory using ArrayFire's memory manager.
af_get_device_count
AFAPI af_err af_get_device_count(int *num_of_devices)
af::getDeviceCount
AFAPI int getDeviceCount()
Gets the number of devices.
af_get_dbl_support
AFAPI af_err af_get_dbl_support(bool *available, const int device)
af::isDoubleAvailable
AFAPI bool isDoubleAvailable(const int device)
Queries the current device for double precision floating point support.
af_free_host
AFAPI af_err af_free_host(void *ptr)
af::freeHost
AFAPI void freeHost(const void *ptr)
Free memory allocated internally by ArrayFire.
af::freePinned
AFAPI void freePinned(const void *ptr)
Free pinned memory allocated by ArrayFire's memory manager
af_free_pinned
AFAPI af_err af_free_pinned(void *ptr)
af_free_device
AFAPI af_err af_free_device(void *ptr)
Returns memory to ArrayFire's memory manager.
af::free
AFAPI void free(const void *ptr)
Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.
af_free_device_v2
AFAPI af_err af_free_device_v2(void *ptr)
Returns memory to ArrayFire's memory manager.
af::freeV2
AFAPI void freeV2(const void *ptr)
Returns memory to ArrayFire's memory manager. The memory will return to the memory pool.
af::getDevice
AFAPI int getDevice()
Gets the current device ID.
af_get_half_support
AFAPI af_err af_get_half_support(bool *available, const int device)
af::isHalfAvailable
AFAPI bool isHalfAvailable(const int device)
Queries the current device for half precision floating point support.
af::infoString
AFAPI const char * infoString(const bool verbose=false)
af_info_string
AFAPI af_err af_info_string(char **str, const bool verbose)
Gets the output of af_info() as a string.
af::info
AFAPI void info()
af_info
AFAPI af_err af_info()
af_init
AFAPI af_err af_init()
af::setMemStepSize
AFAPI void setMemStepSize(const size_t size)
Set the resolution of memory chunks.
af_unlock_array
AFAPI af_err af_unlock_array(const af_array arr)
Unlock device buffer in the memory manager.
af_get_kernel_cache_directory
AFAPI af_err af_get_kernel_cache_directory(size_t *length, char *path)
Gets the path where the kernels generated at runtime will be cached.
af_device_gc
AFAPI af_err af_device_gc()
Call the garbage collection routine.
af_unlock_device_ptr
AFAPI af_err af_unlock_device_ptr(const af_array arr)
Unlock 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_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_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::printMemInfo
AFAPI void printMemInfo(const char *msg=NULL, const int device_id=-1)
Prints buffer details from the ArrayFire Device Manager.
af_print_mem_info
AFAPI af_err af_print_mem_info(const char *msg, const int device_id)
Prints buffer details from the ArrayFire Device Manager.
af_lock_array
AFAPI af_err af_lock_array(const af_array arr)
Lock the device buffer in the memory manager.
af_set_kernel_cache_directory
AFAPI af_err af_set_kernel_cache_directory(const char *path, int override_env)
Sets the path where the kernels generated at runtime will be cached.
af::getMemStepSize
AFAPI size_t getMemStepSize()
Get the resolution of memory chunks.
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_is_locked_array
AFAPI af_err af_is_locked_array(bool *res, const af_array arr)
Query if the array has been locked by the user.
af_lock_device_ptr
AFAPI af_err af_lock_device_ptr(const af_array arr)
Lock the device buffer in the memory manager.
af::deviceGC
AFAPI void deviceGC()
Call the garbage collection function in the memory manager.
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_alloc_pinned
AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes)
af::pinned
AFAPI void * pinned(const size_t elements, const dtype type)
Allocate pinned memory using ArrayFire's memory manager.
af_device_info
AFAPI af_err af_device_info(char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
Gets the information about device and platform as strings
af::deviceInfo
AFAPI void deviceInfo(char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
Gets the information about device and platform as strings
af_set_device
AFAPI af_err af_set_device(const int device)
af_get_device
AFAPI af_err af_get_device(int *device)
af::setDevice
AFAPI void setDevice(const int device)
Sets the current device.
af::sync
AFAPI void sync(const int device=-1)
Blocks until the device is finished processing.
af_sync
AFAPI af_err af_sync(const int device)
af
Definition algorithm.h:15