此为 Mathematica 8 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

OpenCLMemoryAllocate


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

allocates a new list of dimensions type t returning OpenCLMemory.
  • The OpenCLLink application must be loaded using Needs.
  • Valid 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]"
  • 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
First, load the OpenCLLink application:
This allocates memory and registers it with the OpenCLLink memory manager:
This allocates a rank-3 tensor into the OpenCLLink memory manager:
This returns information on the memory allocated:
When using the type , whether it is a or is based on the OpenCL device:
In this case, the system supports double precision. This can be overridden using the option:
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 , whether it is a or 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 option:
In[2]:=
Click for copyable input
Out[2]=
Input dimensions cannot be 0. This is not allowed in the one-dimensional case:
Nor the two-dimensional case:
The devices used in computation can be chosen, but cannot be changed once set by any other OpenCL call:
The device used in computation can be chosen, but cannot be changed once set by any other OpenCL call:
The target precision can be used to tell OpenCLLink how to interpret the type. By default it is determined by detecting whether the system has double-precision support:
This system has double-precision support:
The type is interpreted as a . To force the use of , set the to :
This sets all elements in a list to 0:
This allocates the required memory:
This loads the function using OpenCLFunctionLoad:
This runs the OpenCLFunction:
This shows information about the memory; note that the is :
This gets the memory from the GPU:
This shows information about the memory; note that the and are :
does not set the memory elements allocated:
This gets whatever the memory location has stored:
Further allocations are likely to return different values:
This gets the memory allocated; note that it is different from the values allocated before: