device.h (2022-02-24 14:07:56 -0500, (build 8c2561559))
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
14namespace 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
65
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
280
285 AFAPI void setMemStepSize(const size_t size);
286
292}
293#endif
294
295#ifdef __cplusplus
296extern "C" {
297#endif
298
303
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
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")
392
393#if AF_API_VERSION >= 38
410 AFAPI af_err af_alloc_device_v2(void **ptr, const dim_t bytes);
411
424#endif
428 AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes);
429
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
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
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
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
534#endif
535
536#if AF_API_VERSION >= 33
544#endif
545
546#if AF_API_VERSION >= 33
554#endif
555
556#if AF_API_VERSION >= 34
566#endif
567
576 AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr);
577
578#if AF_API_VERSION >= 38
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
af_dtype
Definition: defines.h:210
long long dim_t
Definition: defines.h:56
af_err
Definition: defines.h:71
void * af_array
Definition: defines.h:240
#define AF_DEPRECATED(msg)
Definition: defines.h:44
#define AFAPI
Definition: defines.h:38
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.
AFAPI af_err af_alloc_host(void **ptr, const dim_t bytes)
AFAPI void * allocHost(const size_t elements, const dtype type)
Allocate memory on host.
AFAPI void * alloc(const size_t elements, const dtype type)
Allocates memory using ArrayFire's memory manager.
AFAPI af_err af_alloc_device(void **ptr, const dim_t bytes)
Allocates memory using ArrayFire's memory manager.
AFAPI af_err af_alloc_device_v2(void **ptr, const dim_t bytes)
Allocates memory using ArrayFire's memory manager.
AFAPI void * allocV2(const size_t bytes)
Allocates memory using ArrayFire's memory manager.
AFAPI af_err af_get_device_count(int *num_of_devices)
AFAPI int getDeviceCount()
Gets the number of devices.
AFAPI bool isDoubleAvailable(const int device)
Queries the current device for double precision floating point support.
AFAPI af_err af_get_dbl_support(bool *available, const int device)
AFAPI void freeHost(const void *ptr)
Free memory allocated internally by ArrayFire.
AFAPI af_err af_free_host(void *ptr)
AFAPI void freePinned(const void *ptr)
Free pinned memory allocated by ArrayFire's memory manager.
AFAPI af_err af_free_pinned(void *ptr)
AFAPI void free(const void *ptr)
Returns memory to ArrayFire's memory manager.
AFAPI af_err af_free_device(void *ptr)
Returns memory to ArrayFire's memory manager.
AFAPI void freeV2(const void *ptr)
AFAPI af_err af_free_device_v2(void *ptr)
Returns memory to ArrayFire's memory manager.
AFAPI int getDevice()
Gets the current device ID.
AFAPI af_err af_get_half_support(bool *available, const int device)
AFAPI bool isHalfAvailable(const int device)
Queries the current device for half precision floating point support.
AFAPI const char * infoString(const bool verbose=false)
AFAPI af_err af_info_string(char **str, const bool verbose)
Gets the output of af_info() as a string.
AFAPI void info()
AFAPI af_err af_info()
AFAPI af_err af_init()
AFAPI af_err af_unlock_array(const af_array arr)
Unlock device buffer in the memory manager.
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.
AFAPI af_err af_device_gc()
Call the garbage collection routine.
AFAPI void deviceGC()
Call the garbage collection function in the memory manager.
AFAPI af_err af_unlock_device_ptr(const af_array arr)
Unlock device buffer in the memory manager.
AFAPI af_err af_set_mem_step_size(const size_t step_bytes)
Set the minimum memory chunk size.
AFAPI af_err af_get_mem_step_size(size_t *step_bytes)
Get the minimum memory chunk size.
AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr)
Get the device pointer and lock the buffer in memory manager.
AFAPI void printMemInfo(const char *msg=NULL, const int device_id=-1)
Prints buffer details from the ArrayFire Device Manager.
AFAPI size_t getMemStepSize()
Get the resolution of memory chunks.
AFAPI af_err af_print_mem_info(const char *msg, const int device_id)
Prints buffer details from the ArrayFire Device Manager.
AFAPI af_err af_lock_array(const af_array arr)
Lock the device buffer in the memory manager.
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.
AFAPI void setMemStepSize(const size_t size)
Set the resolution of memory chunks.
AFAPI af_err af_is_locked_array(bool *res, const af_array arr)
Query if the array has been locked by the user.
AFAPI af_err af_lock_device_ptr(const af_array arr)
Lock the device buffer in the memory manager.
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.
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.
AFAPI af_err af_alloc_pinned(void **ptr, const dim_t bytes)
AFAPI void * pinned(const size_t elements, const dtype type)
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.
AFAPI void deviceInfo(char *d_name, char *d_platform, char *d_toolkit, char *d_compute)
AFAPI af_err af_set_device(const int device)
AFAPI af_err af_get_device(int *device)
AFAPI void setDevice(const int device)
Sets the current device.
AFAPI void sync(const int device=-1)
Blocks until the device is finished processing.
AFAPI af_err af_sync(const int device)
Definition: algorithm.h:15