Class DriverAPINativeMethods.ModuleManagement
Combines all API calls for module management
Inheritance
Inherited Members
Namespace: ManagedCuda
Assembly: ManagedCuda.dll
Syntax
public static class ModuleManagement
Methods
cuLinkAddData(CUlinkState, CUJITInputType, Byte[], SizeT, String, UInt32, CUJITOption[], IntPtr[])
Add an input to a pending linker invocation.
Ownership of data
data is retained by the caller. No reference is retained to any inputs after this call returns.
This method accepts only compiler options, which are used if the data must be compiled from PTX, and does not accept any of ::CU_JIT_WALL_TIME, ::CU_JIT_INFO_LOG_BUFFER, ::CU_JIT_ERROR_LOG_BUFFER, ::CU_JIT_TARGET_FROM_CUCONTEXT, or ::CU_JIT_TARGET.
Declaration
public static CUResult cuLinkAddData(CUlinkState state, CUJITInputType type, byte[] data, SizeT size, string name, uint numOptions, CUJITOption[] options, IntPtr[] optionValues)
Parameters
Type | Name | Description |
---|---|---|
CUlinkState | state | A pending linker action. |
CUJITInputType | type | The type of the input data. |
System.Byte[] | data | The input data. PTX must be NULL-terminated. |
SizeT | size | The length of the input data. |
System.String | name | An optional name for this input in log messages. |
System.UInt32 | numOptions | Size of options. |
CUJITOption[] | options | Options to be applied only for this input (overrides options from ::cuLinkCreate). |
System.IntPtr[] | optionValues | Array of option values, each cast to void *. |
Returns
Type | Description |
---|---|
CUResult |
cuLinkAddFile(CUlinkState, CUJITInputType, String, UInt32, CUJITOption[], IntPtr[])
Add a file input to a pending linker invocation.
No reference is retained to any inputs after this call returns.
This method accepts only compiler options, which are used if the data must be compiled from PTX, and does not accept any of ::CU_JIT_WALL_TIME, ::CU_JIT_INFO_LOG_BUFFER, ::CU_JIT_ERROR_LOG_BUFFER, ::CU_JIT_TARGET_FROM_CUCONTEXT, or ::CU_JIT_TARGET.
This method is equivalent to invoking ::cuLinkAddData on the contents of the file.
Declaration
public static CUResult cuLinkAddFile(CUlinkState state, CUJITInputType type, string path, uint numOptions, CUJITOption[] options, IntPtr[] optionValues)
Parameters
Type | Name | Description |
---|---|---|
CUlinkState | state | A pending linker action. |
CUJITInputType | type | The type of the input data. |
System.String | path | Path to the input file. |
System.UInt32 | numOptions | Size of options. |
CUJITOption[] | options | Options to be applied only for this input (overrides options from ::cuLinkCreate). |
System.IntPtr[] | optionValues | Array of option values, each cast to void *. |
Returns
Type | Description |
---|---|
CUResult |
cuLinkComplete(CUlinkState, ref IntPtr, ref SizeT)
Complete a pending linker invocation.
Completes the pending linker action and returns the cubin image for the linked device code, which can be used with ::cuModuleLoadData.
The cubin is owned by
state
, so it should be loaded before state
is destroyed via ::cuLinkDestroy.
This call does not destroy state
.
Declaration
public static CUResult cuLinkComplete(CUlinkState state, ref IntPtr cubinOut, ref SizeT sizeOut)
Parameters
Type | Name | Description |
---|---|---|
CUlinkState | state | A pending linker invocation |
System.IntPtr | cubinOut | On success, this will point to the output image |
SizeT | sizeOut | Optional parameter to receive the size of the generated image |
Returns
Type | Description |
---|---|
CUResult |
cuLinkCreate(UInt32, CUJITOption[], IntPtr[], ref CUlinkState)
Creates a pending JIT linker invocation.
If the call is successful, the caller owns the returned CUlinkState, which should eventually be destroyed with ::cuLinkDestroy. The device code machine size (32 or 64 bit) will match the calling application.
Both linker and compiler options may be specified. Compiler options will be applied to inputs to this linker action which must be compiled from PTX. The options ::CU_JIT_WALL_TIME, ::CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES, and ::CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES will accumulate data until the CUlinkState is destroyed.
optionValues
must remain valid for the life of the CUlinkState if output options are used. No other references to inputs are maintained after this call returns.
Declaration
public static CUResult cuLinkCreate(uint numOptions, CUJITOption[] options, IntPtr[] optionValues, ref CUlinkState stateOut)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | numOptions | Size of options arrays |
CUJITOption[] | options | Array of linker and compiler options |
System.IntPtr[] | optionValues | Array of option values, each cast to void * |
CUlinkState | stateOut | On success, this will contain a CUlinkState to specify and complete this action |
Returns
Type | Description |
---|---|
CUResult |
cuLinkDestroy(CUlinkState)
Destroys state for a JIT linker invocation.
Declaration
public static CUResult cuLinkDestroy(CUlinkState state)
Parameters
Type | Name | Description |
---|---|---|
CUlinkState | state | State object for the linker invocation |
Returns
Type | Description |
---|---|
CUResult |
cuModuleGetFunction(ref CUfunction, CUmodule, String)
Returns in hfunc
the handle of the function of name name
located in module hmod
. If no function of that name
exists, cuModuleGetFunction(ref CUfunction, CUmodule, String) returns ErrorNotFound.
Declaration
public static CUResult cuModuleGetFunction(ref CUfunction hfunc, CUmodule hmod, string name)
Parameters
Type | Name | Description |
---|---|---|
CUfunction | hfunc | Returned function handle |
CUmodule | hmod | Module to retrieve function from |
System.String | name | Name of function to retrieve |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound.
|
cuModuleGetGlobal_v2(ref CUdeviceptr, ref SizeT, CUmodule, String)
Returns in dptr
and bytes
the base pointer and size of the global of name name
located in module hmod
. If no
variable of that name exists, cuModuleGetGlobal_v2(ref CUdeviceptr, ref SizeT, CUmodule, String) returns ErrorNotFound. Both parameters dptr
and bytes
are optional. If one of them is null
, it is ignored.
Declaration
public static CUResult cuModuleGetGlobal_v2(ref CUdeviceptr dptr, ref SizeT bytes, CUmodule hmod, string name)
Parameters
Type | Name | Description |
---|---|---|
CUdeviceptr | dptr | Returned global device pointer |
SizeT | bytes | Returned global size in bytes |
CUmodule | hmod | Module to retrieve global from |
System.String | name | Name of global to retrieve |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound.
|
cuModuleGetSurfRef(ref CUsurfref, CUmodule, String)
Returns in pSurfRef
the handle of the surface reference of name name
in the module hmod
. If no surface reference
of that name exists, cuModuleGetSurfRef(ref CUsurfref, CUmodule, String) returns ErrorNotFound.
Declaration
public static CUResult cuModuleGetSurfRef(ref CUsurfref pSurfRef, CUmodule hmod, string name)
Parameters
Type | Name | Description |
---|---|---|
CUsurfref | pSurfRef | Returned surface reference |
CUmodule | hmod | Module to retrieve surface reference from |
System.String | name | Name of surface reference to retrieve |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound.
|
cuModuleGetTexRef(ref CUtexref, CUmodule, String)
Returns in pTexRef
the handle of the texture reference of name name
in the module hmod
. If no texture reference
of that name exists, cuModuleGetSurfRef(ref CUsurfref, CUmodule, String) returns ErrorNotFound. This texture reference handle
should not be destroyed, since it will be destroyed when the module is unloaded.
Declaration
public static CUResult cuModuleGetTexRef(ref CUtexref pTexRef, CUmodule hmod, string name)
Parameters
Type | Name | Description |
---|---|---|
CUtexref | pTexRef | Returned texture reference |
CUmodule | hmod | Module to retrieve texture reference from |
System.String | name | Name of texture reference to retrieve |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound.
|
cuModuleLoad(ref CUmodule, String)
Takes a filename fname
and loads the corresponding module module
into the current context. The CUDA driver API
does not attempt to lazily allocate the resources needed by a module; if the memory for functions and data (constant
and global) needed by the module cannot be allocated, cuModuleLoad(ref CUmodule, String) fails. The file should be a cubin
file as output
by nvcc
or a PTX
file, either as output by nvcc
or handwrtten.
Declaration
public static CUResult cuModuleLoad(ref CUmodule module, string fname)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | module | Returned module |
System.String | fname | Filename of module to load |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound,
ErrorOutOfMemory, ErrorFileNotFound, ErrorSharedObjectSymbolNotFound,
ErrorSharedObjectInitFailed.
|
cuModuleLoadData(ref CUmodule, Byte[])
Takes a byte[] as image
and loads the corresponding module module
into the current context. The byte array may be obtained
by mapping a cubin
or PTX
file, passing a cubin
or PTX
file as a null
-terminated text string.
The byte[] is a replacement for the original pointer.
Declaration
public static CUResult cuModuleLoadData(ref CUmodule module, byte[] image)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | module | Returned module |
System.Byte[] | image | Module data to load |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue,
ErrorOutOfMemory, ErrorSharedObjectSymbolNotFound,
ErrorSharedObjectInitFailed.
|
cuModuleLoadDataEx(ref CUmodule, Byte[], UInt32, CUJITOption[], IntPtr[])
Takes a byte[] as image
and loads the corresponding module module
into the current context. The byte array may be obtained
by mapping a cubin
or PTX
file, passing a cubin
or PTX
file as a null
-terminated text string.
Options are passed as an array via options
and any corresponding parameters are passed
in optionValues
. The number of total options is supplied via numOptions
. Any outputs will be returned via
optionValues
. Supported options are definen in CUJITOption.
The options values are currently passed in IntPtr
-type and should then be cast into their real type. This might change in future.
Declaration
public static CUResult cuModuleLoadDataEx(ref CUmodule module, byte[] image, uint numOptions, CUJITOption[] options, IntPtr[] optionValues)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | module | Returned module |
System.Byte[] | image | Module data to load |
System.UInt32 | numOptions | Number of options |
CUJITOption[] | options | Options for JIT |
System.IntPtr[] | optionValues | Option values for JIT |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorOutOfMemory
ErrorNoBinaryForGPU, ErrorSharedObjectSymbolNotFound,
ErrorSharedObjectInitFailed.
|
cuModuleLoadFatBinary(ref CUmodule, Byte[])
Takes a byte[] as fatCubin
and loads the corresponding module module
into the current context. The byte[]
represents a fat binary
object, which is a collection of different cubin
files, all representing the same device code, but
compiled and optimized for different architectures. Prior to CUDA 4.0, there was no documented API for constructing and using
fat binary objects by programmers. Starting with CUDA 4.0, fat binary objects can be constructed by providing the -fatbin option to nvcc.
More information can be found in the nvcc
document.
Declaration
public static CUResult cuModuleLoadFatBinary(ref CUmodule module, byte[] fatCubin)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | module | Returned module |
System.Byte[] | fatCubin | Fat binary to load |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorNotFound, ErrorOutOfMemory
ErrorNoBinaryForGPU, ErrorSharedObjectSymbolNotFound,
ErrorSharedObjectInitFailed.
|
cuModuleUnload(CUmodule)
Unloads a module hmod
from the current context.
Declaration
public static CUResult cuModuleUnload(CUmodule hmod)
Parameters
Type | Name | Description |
---|---|---|
CUmodule | hmod | Module to unload |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue.
|