Platform and Device managing
- Selecting Platform
- getDeviceCount()
- getDevices()
- getDevice()
- setDevice()
- deviceInfo()
- isDoubleAvailable()
- sync()
- wait()
- alloc()
- pinned()
Selecting Platform
Fire.js platform can be selected by calling the root function with the appropriate platform ID as an argument.
Supported platform IDs:
CPU
(cpu fallback)OpenCL
CUDA
Example:
var af = require("arrayfire-js");
var cpuPlatform = af("CPU");
getDeviceCount()
Gets the number of devices on the given platform.
getDeviceCount()
: -> ArrayFire Documentation
Result: Number - number of devices
Example:
var af = require("arrayfire-js");
var cpuPlatform = af("CPU");
var deviceCount = cpuPlatform.getDeviceCount();
getDevices()
Gets available device descriptors on the given platform.
getDevices()
Result: Array - array of device descriptors
getDevice()
Get the current device ID.
getDevice()
: -> ArrayFire Documentation
Result: Number - current device ID
setDevice()
Change current device to specified device.
setDevice(id)
: -> ArrayFire Documentation
deviceInfo()
Get the current device's descriptor.
deviceInfo()
: -> ArrayFire Documentation
Result: object - fields
- name: String - device's vendor specified name
- platform: String - ID of the platform (CPU, OpenCL, CUDA)
- toolkit: String - device's vendor specified platform name
- compute: String - device's vendor specified version
- isDoubleAvailable: Boolean - is double precision supported
isDoubleAvailable()
Check if double precision support is available for specified device.
isDoubleAvailable(deviceID)
: -> ArrayFire Documentation
Argments:
- deviceID: Number - device's ID
Result: Booean - is double precision supported
sync()
asynchronous, counterparts: syncAsync
, syncSync
Waits until all operations on device are finished.
sync()
: -> ArrayFire Documentation
wait()
alias of sync()
alloc()
Allocates memory on the device.
alloc(elements, type)
: -> ArrayFire Documentation
Arguments:
- elements: Number - number of elements to allocate
- type: value of dType - type of the elements, can be one of the values of dType object (eg.
dType.f32
)
Result: Buffer - device memory pointer
Remarks: Deallocation is handled by the GC automatically
pinned()
Allocates pinned memory on the host by using ArrayFire's memory manager.
pinned(elements, type)
: -> ArrayFire Documentation
Arguments:
- elements: Number - number of elements to allocate
- type: value of dType - type of the elements, can be one of the values of dType object (eg.
dType.f32
)
Result: Buffer - memory pointer
Remarks: Deallocation is handled by the GC automatically