Class CudaKernelLibrary
Owns a CUDA runtime kernel library and exposes only copied metadata. 拥有 CUDA runtime kernel library,并且只公开复制型元数据。
public sealed class CudaKernelLibrary : IDisposable
- Inheritance
-
CudaKernelLibrary
- Implements
- Inherited Members
Properties
Inventory
Gets a copied validation snapshot produced by count/enumerate calls. 获取由 count/enumerate 调用产生的复制型校验快照。
public CudaKernelLibraryInventorySnapshot Inventory { get; }
Property Value
KernelCount
Gets the CUDA-reported kernel count. 获取 CUDA 报告的 kernel 数量。
public uint KernelCount { get; }
Property Value
Methods
ContainsKernel(string)
Determines whether the library contains a named kernel without exposing its borrowed handle. 判断 library 是否包含指定 kernel,不暴露 borrowed handle。
public bool ContainsKernel(string name)
Parameters
namestring
Returns
ContainsUnifiedFunction(string)
Determines whether a named unified function exists without exposing its function pointer. 判断指定 unified function 是否存在,不暴露其 function pointer。
public bool ContainsUnifiedFunction(string name)
Parameters
namestring
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Launch(string, CudaKernelLaunchConfiguration, CudaStream, params CudaKernelArgument[])
Launches a named kernel with copied scalar arguments and owner-bound device-memory arguments. 使用复制型标量参数和 owner-bound device-memory 参数启动 named kernel。
public CudaKernelLaunch Launch(string kernelName, CudaKernelLaunchConfiguration configuration, CudaStream stream, params CudaKernelArgument[] arguments)
Parameters
kernelNamestringconfigurationCudaKernelLaunchConfigurationstreamCudaStreamargumentsCudaKernelArgument[]
Returns
Remarks
The returned owner retains this library, the stream, and every device-memory allocation until disposal. Dispose or synchronize the launch before reading results. 返回 owner 会租用 library、stream 与全部 device-memory allocation;读取结果前必须同步或释放 launch。
Load(byte[])
Loads CUDA cubin, fatbin, or PTX bytes while the native owner retains its own copy. 加载 CUDA cubin、fatbin 或 PTX 字节,native owner 会保留独立副本。
public static CudaKernelLibrary Load(byte[] code)
Parameters
codebyte[]
Returns
LoadFromFile(string)
Loads a CUDA cubin, fatbin, or null-terminated PTX file. 加载 CUDA cubin、fatbin 或以 null 结尾的 PTX 文件。
public static CudaKernelLibrary LoadFromFile(string path)
Parameters
pathstring
Returns
SetAttributeForDevice(string, CudaKernelAttribute, int, int)
Sets a mutable attribute on a named kernel for one device without exposing the borrowed kernel handle. 为指定设备上的 named kernel 设置可变属性,不暴露 borrowed kernel handle。
public void SetAttributeForDevice(string kernelName, CudaKernelAttribute attribute, int value, int deviceOrdinal)
Parameters
kernelNamestringattributeCudaKernelAttributevalueintdeviceOrdinalint
TryGetGlobalSymbolSize(string, out ulong)
Tries to copy the size of a named global symbol without retrieving its device pointer. 尝试复制指定 global symbol 的大小,不获取其 device pointer。
public bool TryGetGlobalSymbolSize(string name, out ulong sizeInBytes)
Parameters
Returns
TryGetManagedSymbolSize(string, out ulong)
Tries to copy the size of a named managed symbol without retrieving its pointer. 尝试复制指定 managed symbol 的大小,不获取其 pointer。
public bool TryGetManagedSymbolSize(string name, out ulong sizeInBytes)