A high-performance general-purpose compute library

Returns an integer indicating the backends loaded successfully. More...

Functions

AFAPI af_err af_get_available_backends (int *backends)
 Returns a flag of all available backends. More...
 
AFAPI int getAvailableBackends ()
 Returns a flag of all available backends. More...
 

Detailed Description

Returns an integer indicating the backends loaded successfully.

The number returned denotes the backends available according to the table:

Return Value Backends Available
0 None
1 CPU
2 CUDA
3 CPU and CUDA
4 OpenCL
5 CPU and OpenCL
6 CUDA and OpenCL
7 CPU, CUDA and OpenCL

To convert the integer back into bools for each device, use the following code

int backends = af::getAvailableBackends();
bool cpu = backends & AF_BACKEND_CPU;
bool cuda = backends & AF_BACKEND_CUDA;
bool opencl = backends & AF_BACKEND_OPENCL;
@ AF_BACKEND_CUDA
CUDA Compute Backend.
Definition: defines.h:416
@ AF_BACKEND_OPENCL
OpenCL Compute Backend.
Definition: defines.h:417
@ AF_BACKEND_CPU
CPU a.k.a sequential algorithms.
Definition: defines.h:415
AFAPI int getAvailableBackends()
Returns a flag of all available backends.

Function Documentation

◆ af_get_available_backends()

AFAPI af_err af_get_available_backends ( int *  backends)

Returns a flag of all available backends.

int backends = 0;
if(backends & AF_BACKEND_CUDA) {
// The CUDA backend is available
}
AFAPI af_err af_get_available_backends(int *backends)
Returns a flag of all available backends.
Parameters
[out]backendsA flag of all available backends. Use the &(and) operator to check if a particular backend is available
Returns
af_err error code

◆ getAvailableBackends()

AFAPI int getAvailableBackends ( )

Returns a flag of all available backends.

int backends = getAvailableBackends();
if(backends & AF_BACKEND_CUDA) {
// The CUDA backend is available
}
Returns
A flag of available backends