ComputationalResources.ComputationalResources
— ModuleComputationalResources makes it possible to dispatch to different methods that employ different computational resources. The exported resources are:
CPU1
(single-threaded computation)CPUThreads
(multi-threaded computation)CPUProcesses
(multi-process computation)ArrayFireLibs
(using the ArrayFire packageCUDALibs
(GPU computation using NVIDIA's CUDA libraries)OpenCLLibs
(GPU computation using the OpenCL libraries)
There are also functions that interact with package initialization machinery to control the availability of supported methods:
addresource(T)
: request newly-loaded packages to support resourceT
rmresource(T)
: stop asking newly-loaded packages to support resourceT
haveresource(T)
: test whether resourceT
has been requested
ComputationalResources.AbstractCPU
— TypeAbstractCPU
An abstract type indicating that computation should be performed using the CPU.
ComputationalResources.AbstractResource
— TypeAbstractResource
The abstract supertype of all computational resources.
ComputationalResources.ArrayFireLibs
— TypeArrayFireLibs()
ArrayFireLibs(settings)
Indicate that computation should be performing using the ArrayFire libraries. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(ArrayFireLibs(), image, kernel)
filter(ArrayFireLibs(backend), image, kernel)
ComputationalResources.CPU1
— TypeCPU1()
CPU1(settings)
Indicate that a computation should be performed using the CPU in single-threaded mode. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(CPU1(), image, kernel)
filter(CPU1(TileSize(64,8)), image, kernel)
ComputationalResources.CPUProcesses
— TypeCPUProcesses()
CPUProcesses(settings)
Indicate that a computation should be performed using the CPU in multi-process mode. Processes should be added with addprocs() or julia started with julia -p N
. Processes must communicate using distributed memory operations such as remote refrences. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(CPUProcesses(), image, kernel)
filter(CPUProcesses(TileSize(64,8)), image, kernel)
ComputationalResources.CPUThreads
— TypeCPUThreads()
CPUThreads(settings)
Indicate that a computation should be performed using the CPU in multi-threaded mode. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(CPUThreads(), image, kernel)
filter(CPUThreads(TileSize(64,8)), image, kernel)
ComputationalResources.CUDALibs
— TypeCUDALibs()
CUDALibs(settings)
Indicate that computation should be performing using the CUDA libraries. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(CUDALibs(), image, kernel)
filter(CUDALibs(backend), image, kernel)
ComputationalResources.OpenCLLibs
— TypeOpenCLLibs()
OpenCLLibs(settings)
Indicate that computation should be performing using the OpenCL libraries. Optionally pass in an object specifying algorithmic settings.
Examples:
filter(OpenCLLibs(), image, kernel)
filter(OpenCLLibs(backend), image, kernel)
ComputationalResources.TileSize
— TypeTileSize(dims)
Request that an array computation be performed using tiles (blocks) of size dims
.
ComputationalResources.addresource
— Methodaddresource(T)
Add T
to the list of available resources. For example, addresource(OpenCLLibs)
would indicate that you have a GPU and the OpenCL libraries installed.
ComputationalResources.haveresource
— Methodhaveresource(T)
Returns true
if T
is an available resource. For example, haveresource(OpenCLLibs)
tests whether the OpenCLLibs
have been added as an available resource. This function is typically used inside a module's __init__
function.
Example:
# The __init__ function for MyPackage:
function __init__()
... # other initialization code, possibly setting the LOAD_PATH
if haveresource(OpenCLLibs)
@eval using MyPackageCL # a separate module containing OpenCL implementations
end
# Put additional resource checks here
... # other initialization code, possibly cleaning up the LOAD_PATH
end
ComputationalResources.rmresource
— Methodrmresource(T)
Remove T
from the list of available resources. For example, rmresource(OpenCLLibs)
would indicate that any future package loads should avoid loading their specializations for OpenCL.