OpenCLLink`
OpenCLLink`

OpenCLMemoryLoad

OpenCLMemoryLoad[list]

loads list into OpenCLMemory manager, returning an OpenCLMemory.

OpenCLMemoryLoad[list,type]

loads list with specified type into OpenCLMemory manager, returning an OpenCLMemory.

Details

  • The OpenCLLink application must be loaded using Needs["OpenCLLink`"].
  • Valid OpenCLMemoryLoad types are:
  • IntegerRealComplex
    "Byte""Bit16""Integer"
    "Byte[2]""Bit16[2]""Integer32[2]"
    "Byte[4]""Bit16[4]""Integer32[4]"
    "Byte[8]""Bit16[8]""Integer32[8]"
    "Byte[16]""Bit16[16]""Integer32[16]"
    "UnsignedByte""UnsignedBit16""UnsignedInteger"
    "UnsignedByte[2]""UnsignedBit16[2]""UnsignedInteger[2]"
    "UnsignedByte[4]""UnsignedBit16[4]""UnsignedInteger[4]"
    "UnsignedByte[8]""UnsignedBit16[8]""UnsignedInteger[8]"
    "UnsignedByte[16]""UnsignedBit16[16]""UnsignedInteger[16]"
    "Double""Float""Integer64"
    "Double[2]""Float[2]""Integer64[2]"
    "Double[4]""Float[4]""Integer64[4]"
    "Double[8]""Float[8]""Integer64[8]"
    "Double[16]""Float[16]""Integer64[16]"
  • OpenCLMemory can be queried using OpenCLMemoryInformation.
  • OpenCLMemory is retrieved using OpenCLMemoryGet.
  • OpenCLMemory is unloaded using OpenCLMemoryUnload.
  • OpenCLMemoryAllocate is used when memory needs to be allocated to be written to, such as output memory.
  • The following options can be given:
  • "Device"AutomaticOpenCL device used in computation
    "Platform"AutomaticOpenCL platform used in computation
    "TargetPrecision"Automaticprecision used in computation

Examples

open allclose all

Basic Examples  (5)

First, load the OpenCLLink application:

This registers the list ConstantArray[0,10] into the OpenCLLink memory manager:

Vector types can be loaded, but they must obey the width requirement of the type ("Byte[16]" has a width of 16, for example):

An error is returned otherwise:

Images can be loaded as OpenCLMemory:

By default, images are represented as a list of integers; different types can be used, however:

When adding graphics objects, the object is rasterized:

When getting the memory, an image is returned:

When using the type Real, whether it is a "Float" or "Double" is based on the OpenCL device:

In this case, the system supports double precision. This can be overridden using the "TargetPrecision" option:

Options  (3)

"Device"  (1)

The devices used in computation can be chosen, but cannot be changed once set by any other OpenCL call:

"Platform"  (1)

The platform used in computation can be chosen, but cannot be changed once set by any other OpenCL call:

"TargetPrecision"  (1)

The target precision can be used to tell OpenCLLink how to interpret the Real type. By default, it is determined by detecting whether the system has double-precision support:

This system has double-precision support:

The Real type is interpreted as a "Double". To force the use of "Float", one sets the "TargetPrecision" to "Single":

Applications  (2)

This adds two to an input list:

This loads the function using OpenCLFunctionLoad:

This runs OpenCLFunction:

This gets the memory using OpenCLMemoryGet:

This unloads the memory using OpenCLMemoryUnload:

Internally, OpenCLMemoryLoad is used to load memory behind the scenes. This color negates an input image:

This loads the function using OpenCLFunctionLoad:

This defines input parameters:

This runs OpenCLFunction: