CUDALink`
CUDALink`

CUDAMemoryAllocate

CUDAMemoryAllocate[type,dim]

gives CUDAMemory with specified type and single dimension.

CUDAMemoryAllocate[type,{dim1,dim2,}]

gives CUDAMemory with specified type and dimensions.

更多信息和选项更多信息
  • The CUDALink application must be loaded using Needs["CUDALink`"].
  • Possible types for CUDAMemoryAllocate are:
  • IntegerRealComplex
    "Byte""Bit16""Integer32"
    "Byte[2]""Bit16[2]""Integer32[2]"
    "Byte[3]""Bit16[3]""Integer32[3]"
    "Byte[4]""Bit16[4]""Integer32[4]"
    "UnsignedByte""UnsignedBit16""UnsignedInteger"
    "UnsignedByte[2]""UnsignedBit16[2]""UnsignedInteger[2]"
    "UnsignedByte[3]""UnsignedBit16[3]""UnsignedInteger[3]"
    "UnsignedByte[4]""UnsignedBit16[4]""UnsignedInteger[4]"
    "Double""Float""Integer64"
    "Double[2]""Float[2]""Integer64[2]"
    "Double[3]""Float[3]""Integer64[3]"
    "Double[4]""Float[4]""Integer64[4]"
  • The following options can be given:
  • "Device"$CUDADeviceCUDA device used in computation
    "TargetPrecision"Automaticprecision used in computation
  • 范例

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

    基本范例  (4)

    First, load the CUDALink application:

    In[1]:=
    Click for copyable input

    This allocates a rank 3 tensor with each dimension 10:

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

    Information about memory can be retrieved via CUDAMemoryInformation:

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

    This unloads the memory:

    In[4]:=
    Click for copyable input

    For a single dimension, the length can be an integer:

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

    Link CUDAMemoryLoad; different types are supported:

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

    Adding memory as Real or Complex gets the type based on whether the device supports double precision or not:

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

    In this case, the CUDA device has double-precision support:

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

    The behavior can be forced to change by setting the "TargetPrecision":

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

    Applications  (1)

    Possible Issues  (1)

    参见

    CUDAMemoryLoad  CUDAMemory  CUDAMemoryGet  CUDAMemoryUnload  CUDAMemoryInformation

    教程