My Project

Accessing ArrayFire's stream, and native device id with other CUDA code. More...

Functions

AFAPI af_err afcu_get_stream (cudaStream_t *stream, int id)
 Get the stream for the CUDA device with id in ArrayFire context. More...
 
AFAPI af_err afcu_get_native_id (int *nativeid, int id)
 Get the native device id of the CUDA device with id in ArrayFire context. More...
 
AFAPI af_err afcu_set_native_id (int nativeid)
 Set the CUDA device with given native id as the active device for ArrayFire. More...
 
static cudaStream_t getStream (int id)
 Get the stream for the CUDA device with id in ArrayFire context. More...
 
static int getNativeId (int id)
 Get the native device id of the CUDA device with id in ArrayFire context. More...
 
static void setNativeId (int nativeId)
 Set the CUDA device with given native id as the active device for ArrayFire. More...
 

Detailed Description

Accessing ArrayFire's stream, and native device id with other CUDA code.

If your software is using ArrayFire's CUDA backend, you can also write custom kernels and do custom memory operations using native CUDA commands. The functions contained in the afcu namespace provide methods to get the stream and native device id that ArrayFire is using.

Function Documentation

◆ afcu_get_native_id()

AFAPI af_err afcu_get_native_id ( int *  nativeid,
int  id 
)

Get the native device id of the CUDA device with id in ArrayFire context.

Parameters
[out]nativeidnative device id of the CUDA device with id in ArrayFire context
[in]idArrayFire device id
Returns
af_err error code

◆ afcu_get_stream()

AFAPI af_err afcu_get_stream ( cudaStream_t *  stream,
int  id 
)

Get the stream for the CUDA device with id in ArrayFire context.

Parameters
[out]streamCUDA Stream of device with id in ArrayFire context
[in]idArrayFire device id
Returns
af_err error code

◆ afcu_set_native_id()

AFAPI af_err afcu_set_native_id ( int  nativeid)

Set the CUDA device with given native id as the active device for ArrayFire.

Parameters
[in]nativeidnative device id of the CUDA device
Returns
af_err error code

◆ getNativeId()

static int afcu::getNativeId ( int  id)
inlinestatic

Get the native device id of the CUDA device with id in ArrayFire context.

Parameters
[in]idArrayFire device id
Returns
cuda native id of device

Definition at line 95 of file cuda.h.

96 {
97  int retVal;
98  af_err err = afcu_get_native_id(&retVal, id);
99  if (err!=AF_SUCCESS)
100  throw af::exception("Failed to get CUDA device native id from ArrayFire");
101  return retVal;
102 }
The function returned successfully.
Definition: defines.h:69
AFAPI af_err afcu_get_native_id(int *nativeid, int id)
Get the native device id of the CUDA device with id in ArrayFire context.
af_err
Definition: defines.h:65

◆ getStream()

static cudaStream_t afcu::getStream ( int  id)
inlinestatic

Get the stream for the CUDA device with id in ArrayFire context.

Parameters
[in]idArrayFire device id
Returns
cuda stream used by CUDA device

Definition at line 76 of file cuda.h.

77 {
78  cudaStream_t retVal;
79  af_err err = afcu_get_stream(&retVal, id);
80  if (err!=AF_SUCCESS)
81  throw af::exception("Failed to get CUDA stream from ArrayFire");
82  return retVal;
83 }
The function returned successfully.
Definition: defines.h:69
AFAPI af_err afcu_get_stream(cudaStream_t *stream, int id)
Get the stream for the CUDA device with id in ArrayFire context.
af_err
Definition: defines.h:65

◆ setNativeId()

static void afcu::setNativeId ( int  nativeId)
inlinestatic

Set the CUDA device with given native id as the active device for ArrayFire.

Parameters
[in]nativeIdnative device id of the CUDA device

Definition at line 113 of file cuda.h.

114 {
115  af_err err = afcu_set_native_id(nativeId);
116  if (err!=AF_SUCCESS)
117  throw af::exception("Failed to change active CUDA device to the device with given native id");
118 }
The function returned successfully.
Definition: defines.h:69
af_err
Definition: defines.h:65
AFAPI af_err afcu_set_native_id(int nativeid)
Set the CUDA device with given native id as the active device for ArrayFire.