ComputationalResources.ComputationalResourcesModule

ComputationalResources 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 package
  • CUDALibs (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 resource T
  • rmresource(T): stop asking newly-loaded packages to support resource T
  • haveresource(T): test whether resource T has been requested
ComputationalResources.ArrayFireLibsType
ArrayFireLibs()
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.CPU1Type
CPU1()
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.CPUProcessesType
CPUProcesses()
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.CPUThreadsType
CPUThreads()
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.CUDALibsType
CUDALibs()
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.OpenCLLibsType
OpenCLLibs()
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.addresourceMethod
addresource(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.haveresourceMethod
haveresource(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.rmresourceMethod
rmresource(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.