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:
-
Integer Real Complex "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" Automatic OpenCL device used in computation "Platform" Automatic OpenCL platform used in computation "TargetPrecision" Automatic precision used in computation
范例
打开所有单元关闭所有单元基本范例 (2)
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 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:
Scope (1)
Options (3)
"Device" (1)
"Platform" (1)
"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", set the "TargetPrecision" to "Single":
Applications (1)
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 "DeviceStatus" is "Synchronized":
This gets the memory from the GPU:
This shows information about the memory; note that the "DeviceStatus" and "HostStatus" are "Synchronized":
文本
Wolfram Research (2010),OpenCLMemoryAllocate,Wolfram 语言函数,https://reference.wolfram.com/language/OpenCLLink/ref/OpenCLMemoryAllocate.html.
CMS
Wolfram 语言. 2010. "OpenCLMemoryAllocate." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/OpenCLLink/ref/OpenCLMemoryAllocate.html.
APA
Wolfram 语言. (2010). OpenCLMemoryAllocate. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/OpenCLLink/ref/OpenCLMemoryAllocate.html 年