OpenCLLink`
OpenCLLink`

OpenCLMemoryAllocate

OpenCLMemoryAllocate[t,len]

allocates a new one-dimensional list of type t returning OpenCLMemory.

OpenCLMemoryAllocate[t,{d1,d2,}]

allocates a new list of dimensions {d1,d2,} type t returning OpenCLMemory.

更多信息和选项更多信息
  • The OpenCLLink application must be loaded using Needs["OpenCLLink`"].
  • Valid OpenCLMemoryAllocate 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""Float"
    "UnsignedByte[2]""UnsignedBit16[2]""Float[2]"
    "UnsignedByte[4]""UnsignedBit16[4]""Float[4]"
    "UnsignedByte[8]""UnsignedBit16[8]""Float[8]"
    "UnsignedByte[16]""UnsignedBit16[16]""Float[16]"
    "Double""Double[2]""Double[4]"
    "Double[8]""Double[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
  • 范例

    打开所有单元关闭所有单元

    基本范例  (2)

    First, load the OpenCLLink application:

    In[1]:=
    Click for copyable input

    This allocates memory and registers it with the OpenCLLink memory manager:

    In[2]:=
    Click for copyable input
    Out[2]=

    This allocates a rank-3 tensor into the OpenCLLink memory manager:

    In[3]:=
    Click for copyable input
    Out[3]=

    This returns information on the memory allocated:

    In[4]:=
    Click for copyable input
    Out[4]=

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

    In[1]:=
    Click for copyable input
    Out[1]=

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

    In[2]:=
    Click for copyable input
    Out[2]=

    Scope  (1)

    Options  (3)

    Applications  (1)

    Possible Issues  (1)

    参见

    OpenCLMemory  OpenCLMemoryLoad  OpenCLMemoryInformation  OpenCLMemoryUnload

    教程