跳到主要内容

MUSA Runtime API Reference

Supported APIs

The following table lists the Runtime APIs supported in MUSA SDK 5.1.0.

APIHeader
__musaPushCallConfigurationdevice_functions.h
__musaPopCallConfigurationhost_runtime.h
__musaRegisterFatBinaryhost_runtime.h
__musaRegisterFatBinaryEndhost_runtime.h
__musaRegisterFunctionhost_runtime.h
__musaRegisterVarhost_runtime.h
__musaRegisterTexturehost_runtime.h
__musaRegisterSurfacehost_runtime.h
__musaUnregisterFatBinaryhost_runtime.h
musaThreadExitmusa_runtime_api.h
musaThreadSynchronizemusa_runtime_api.h
musaThreadSetLimitmusa_runtime_api.h
musaThreadGetLimitmusa_runtime_api.h
musaThreadGetCacheConfigmusa_runtime_api.h
musaThreadSetCacheConfigmusa_runtime_api.h
musaBindTexturemusa_runtime_api.h
musaUnbindTexturemusa_runtime_api.h
musaBindTexture2Dmusa_runtime_api.h
musaBindTextureToArraymusa_runtime_api.h
musaGetTextureAlignmentOffsetmusa_runtime_api.h
musaBindTextureToMipmappedArraymusa_runtime_api.h
musaGetTextureReferencemusa_runtime_api.h
musaBindSurfaceToArraymusa_runtime_api.h
musaGetSurfaceReferencemusa_runtime_api.h
musaMemcpyFromArraymusa_runtime_api.h
musaMemcpyFromArrayAsyncmusa_runtime_api.h
musaMemcpyToArraymusa_runtime_api.h
musaMemcpyToArrayAsyncmusa_runtime_api.h
musaDeviceGetPCIBusIdmusa_runtime_api.h
musaDeviceGetByPCIBusIdmusa_runtime_api.h
musaDeviceGetLimitmusa_runtime_api.h
musaDeviceSetLimitmusa_runtime_api.h
musaDeviceGetP2PAttributemusa_runtime_api.h
musaDeviceGetSharedMemConfigmusa_runtime_api.h
musaDeviceSetSharedMemConfigmusa_runtime_api.h
musaDeviceGetStreamPriorityRangemusa_runtime_api.h
musaDeviceResetmusa_runtime_api.h
musaDeviceSynchronizemusa_runtime_api.h
musaGetDevicemusa_runtime_api.h
musaGetDeviceCountmusa_runtime_api.h
musaSetDevicemusa_runtime_api.h
musaGetDeviceFlagsmusa_runtime_api.h
musaSetDeviceFlagsmusa_runtime_api.h
musaGetDeviceProperties_v2musa_runtime_api.h
musaGetDevicePropertiesmusa_runtime_api.h
musaInitDevicemusa_runtime_api.h
musaDeviceGetTexture1DLinearMaxWidthmusa_runtime_api.h
musaDeviceGetCacheConfigmusa_runtime_api.h
musaDeviceSetCacheConfigmusa_runtime_api.h
musaChooseDevicemusa_runtime_api.h
musaDeviceGetAttributemusa_runtime_api.h
musaGetExportTablemusa_runtime_api.h
musaGetDriverEntryPointmusa_runtime_api.h
musaGetDriverEntryPointByVersionmusa_runtime_api.h
musaGetLastErrormusa_runtime_api.h
musaGetErrorNamemusa_runtime_api.h
musaGetErrorStringmusa_runtime_api.h
musaPeekAtLastErrormusa_runtime_api.h
musaEventCreatemusa_runtime_api.h
musaEventCreateWithFlagsmusa_runtime_api.h
musaEventDestroymusa_runtime_api.h
musaEventQuerymusa_runtime_api.h
musaEventRecordmusa_runtime_api.h
musaEventRecordWithFlagsmusa_runtime_api.h
musaEventSynchronizemusa_runtime_api.h
musaEventElapsedTimemusa_runtime_api.h
musaEventElapsedTime_v2musa_runtime_api.h
musaIpcGetEventHandlemusa_runtime_api.h
musaIpcOpenEventHandlemusa_runtime_api.h
musaGraphicsMapResourcesmusa_runtime_api.h
musaGraphicsResourceGetMappedPointermusa_runtime_api.h
musaGraphicsResourceSetMapFlagsmusa_runtime_api.h
musaGraphicsUnmapResourcesmusa_runtime_api.h
musaGraphicsUnregisterResourcemusa_runtime_api.h
musaGraphAddHostNodemusa_runtime_api.h
musaGraphAddKernelNodemusa_runtime_api.h
musaGraphAddMemcpyNode1Dmusa_runtime_api.h
musaGraphAddMemcpyNodemusa_runtime_api.h
musaGraphAddMemcpyNodeFromSymbolmusa_runtime_api.h
musaGraphAddMemcpyNodeToSymbolmusa_runtime_api.h
musaGraphAddMemsetNodemusa_runtime_api.h
musaGraphAddChildGraphNodemusa_runtime_api.h
musaGraphAddDependenciesmusa_runtime_api.h
musaGraphRemoveDependenciesmusa_runtime_api.h
musaGraphAddEmptyNodemusa_runtime_api.h
musaGraphAddEventRecordNodemusa_runtime_api.h
musaGraphAddEventWaitNodemusa_runtime_api.h
musaGraphAddMemAllocNodemusa_runtime_api.h
musaGraphAddMemFreeNodemusa_runtime_api.h
musaGraphClonemusa_runtime_api.h
musaGraphCreatemusa_runtime_api.h
musaGraphDestroymusa_runtime_api.h
musaGraphDestroyNodemusa_runtime_api.h
musaGraphEventRecordNodeGetEventmusa_runtime_api.h
musaGraphEventRecordNodeSetEventmusa_runtime_api.h
musaGraphEventWaitNodeGetEventmusa_runtime_api.h
musaGraphEventWaitNodeSetEventmusa_runtime_api.h
musaGraphExecDestroymusa_runtime_api.h
musaGraphGetNodesmusa_runtime_api.h
musaGraphGetRootNodesmusa_runtime_api.h
musaGraphNodeGetDependenciesmusa_runtime_api.h
musaGraphGetEdgesmusa_runtime_api.h
musaGraphNodeGetDependentNodesmusa_runtime_api.h
musaGraphHostNodeGetParamsmusa_runtime_api.h
musaGraphHostNodeSetParamsmusa_runtime_api.h
musaGraphInstantiatemusa_runtime_api.h
musaGraphInstantiateWithFlagsmusa_runtime_api.h
musaGraphExecGetFlagsmusa_runtime_api.h
musaGraphKernelNodeGetParamsmusa_runtime_api.h
musaGraphKernelNodeSetParamsmusa_runtime_api.h
musaGraphKernelNodeSetAttributemusa_runtime_api.h
musaGraphKernelNodeGetAttributemusa_runtime_api.h
musaGraphKernelNodeCopyAttributesmusa_runtime_api.h
musaGraphLaunchmusa_runtime_api.h
musaGraphUploadmusa_runtime_api.h
musaGraphMemcpyNodeGetParamsmusa_runtime_api.h
musaGraphMemcpyNodeSetParamsmusa_runtime_api.h
musaGraphMemcpyNodeSetParams1Dmusa_runtime_api.h
musaGraphMemsetNodeGetParamsmusa_runtime_api.h
musaGraphMemsetNodeSetParamsmusa_runtime_api.h
musaGraphNodeFindInClonemusa_runtime_api.h
musaGraphNodeGetTypemusa_runtime_api.h
musaGraphExecUpdatemusa_runtime_api.h
musaGraphExecKernelNodeSetParamsmusa_runtime_api.h
musaGraphExecMemcpyNodeSetParamsmusa_runtime_api.h
musaGraphExecMemcpyNodeSetParams1Dmusa_runtime_api.h
musaGraphExecMemsetNodeSetParamsmusa_runtime_api.h
musaGraphExecHostNodeSetParamsmusa_runtime_api.h
musaGraphNodeSetEnabledmusa_runtime_api.h
musaGraphNodeGetEnabledmusa_runtime_api.h
musaGraphAddMemAtomicNodemusa_runtime_api.h
musaGraphAddMemAtomicValueNodemusa_runtime_api.h
musaGraphAddMemWaitWriteNodemusa_runtime_api.h
musaGraphAddMemTransferNodemusa_runtime_api.h
musaGraphMemAtomicNodeGetParamsmusa_runtime_api.h
musaGraphMemAtomicNodeSetParamsmusa_runtime_api.h
musaGraphMemAtomicValueNodeGetParamsmusa_runtime_api.h
musaGraphMemAtomicValueNodeSetParamsmusa_runtime_api.h
musaGraphMemWaitWriteNodeGetParamsmusa_runtime_api.h
musaGraphMemWaitWriteNodeSetParamsmusa_runtime_api.h
musaGraphMemTransferNodeGetParamsmusa_runtime_api.h
musaGraphMemTransferNodeSetParamsmusa_runtime_api.h
musaGraphExecMemAtomicNodeSetParamsmusa_runtime_api.h
musaGraphExecMemAtomicValueNodeSetParamsmusa_runtime_api.h
musaGraphExecMemWaitWriteNodeSetParamsmusa_runtime_api.h
musaGraphExecMemTransferNodeSetParamsmusa_runtime_api.h
musaGraphNodeSetParamsmusa_runtime_api.h
musaGraphAddNodemusa_runtime_api.h
musaGraphExecNodeSetParamsmusa_runtime_api.h
musaGraphConditionalHandleCreatemusa_runtime_api.h
musaUserObjectCreatemusa_runtime_api.h
musaUserObjectRetainmusa_runtime_api.h
musaUserObjectReleasemusa_runtime_api.h
musaGraphRetainUserObjectmusa_runtime_api.h
musaGraphReleaseUserObjectmusa_runtime_api.h
musaGraphDebugDotPrintmusa_runtime_api.h
musaMallocmusa_runtime_api.h
musaMallocPitchmusa_runtime_api.h
musaMalloc3Dmusa_runtime_api.h
musaMallocHostmusa_runtime_api.h
musaMallocManagedmusa_runtime_api.h
musaFreemusa_runtime_api.h
musaFreeArraymusa_runtime_api.h
musaFreeHostmusa_runtime_api.h
musaHostAllocmusa_runtime_api.h
musaHostGetDevicePointermusa_runtime_api.h
musaHostGetFlagsmusa_runtime_api.h
musaPointerGetAttributesmusa_runtime_api.h
musaMemcpymusa_runtime_api.h
musaMemcpyAsyncmusa_runtime_api.h
musaMemcpyBatchAsyncmusa_runtime_api.h
musaMemcpy3DBatchAsyncmusa_runtime_api.h
musaMemcpy2Dmusa_runtime_api.h
musaMemcpy2DAsyncmusa_runtime_api.h
musaMemcpy2DFromArraymusa_runtime_api.h
musaMemcpy2DFromArrayAsyncmusa_runtime_api.h
musaMemcpy2DToArraymusa_runtime_api.h
musaMemcpy2DToArrayAsyncmusa_runtime_api.h
musaMemcpy2DArrayToArraymusa_runtime_api.h
musaMemcpy3Dmusa_runtime_api.h
musaMemcpy3DPeermusa_runtime_api.h
musaMemcpy3DAsyncmusa_runtime_api.h
musaMemcpy3DPeerAsyncmusa_runtime_api.h
musaHostRegistermusa_runtime_api.h
musaHostUnregistermusa_runtime_api.h
musaMemGetInfomusa_runtime_api.h
musaArrayGetInfomusa_runtime_api.h
musaMemsetmusa_runtime_api.h
musaMemsetAsyncmusa_runtime_api.h
musaMemset2Dmusa_runtime_api.h
musaMemset2DAsyncmusa_runtime_api.h
musaMemset3Dmusa_runtime_api.h
musaMemset3DAsyncmusa_runtime_api.h
musaIpcCloseMemHandlemusa_runtime_api.h
musaIpcGetMemHandlemusa_runtime_api.h
musaIpcOpenMemHandlemusa_runtime_api.h
musaMallocMipmappedArraymusa_runtime_api.h
musaFreeMipmappedArraymusa_runtime_api.h
musaGetMipmappedArrayLevelmusa_runtime_api.h
musaMalloc3DArraymusa_runtime_api.h
musaMallocArraymusa_runtime_api.h
musaMemAdvisemusa_runtime_api.h
musaMemAdvise_v2musa_runtime_api.h
musaMemPrefetchAsyncmusa_runtime_api.h
musaMemPrefetchAsync_v2musa_runtime_api.h
musaMemRangeGetAttributemusa_runtime_api.h
musaMemRangeGetAttributesmusa_runtime_api.h
musaMemcpyFromSymbolmusa_runtime_api.h
musaMemcpyFromSymbolAsyncmusa_runtime_api.h
musaMemcpyToSymbolmusa_runtime_api.h
musaMemcpyToSymbolAsyncmusa_runtime_api.h
musaMemcpyPeermusa_runtime_api.h
musaMemcpyPeerAsyncmusa_runtime_api.h
musaMallocFromPoolAsyncmusa_runtime_api.h
musaMemoryAtomicAsyncmusa_runtime_api.h
musaMemoryAtomicValueAsyncmusa_runtime_api.h
musaMemoryTransfermusa_runtime_api.h
musaMemoryTransferAsyncmusa_runtime_api.h
musaLaunchHostFuncmusa_runtime_api.h
musaLaunchKernelmusa_runtime_api.h
musaLaunchKernelExCmusa_runtime_api.h
musaLaunchCooperativeKernelmusa_runtime_api.h
musaLaunchCooperativeKernelMultiDevicemusa_runtime_api.h
musaGetSymbolAddressmusa_runtime_api.h
musaGetSymbolSizemusa_runtime_api.h
musaFuncGetAttributesmusa_runtime_api.h
musaFuncGetNamemusa_runtime_api.h
musaFuncGetParamInfomusa_runtime_api.h
musaFuncSetAttributemusa_runtime_api.h
musaFuncSetCacheConfigmusa_runtime_api.h
musaFuncSetSharedMemConfigmusa_runtime_api.h
musaGetFuncBySymbolmusa_runtime_api.h
musaDeviceRegisterAsyncNotificationmusa_runtime_api.h
musaDeviceUnregisterAsyncNotificationmusa_runtime_api.h
musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlagsmusa_runtime_api.h
musaGraphicsGLRegisterBuffermusa_gl_interop.h
musaGLSetGLDevicemusa_gl_interop.h
musaDeviceCanAccessPeermusa_runtime_api.h
musaDeviceEnablePeerAccessmusa_runtime_api.h
musaDeviceDisablePeerAccessmusa_runtime_api.h
musaProfilerStartmusa_profiler_api.h
musaProfilerStopmusa_profiler_api.h
musaMemPoolCreatemusa_runtime_api.h
musaMemPoolDestroymusa_runtime_api.h
musaMallocAsyncmusa_runtime_api.h
musaFreeAsyncmusa_runtime_api.h
musaMemPoolGetAttributemusa_runtime_api.h
musaMemPoolSetAttributemusa_runtime_api.h
musaMemPoolSetAccessmusa_runtime_api.h
musaMemPoolGetAccessmusa_runtime_api.h
musaMemPoolTrimTomusa_runtime_api.h
musaMemPoolImportFromShareableHandlemusa_runtime_api.h
musaMemPoolExportToShareableHandlemusa_runtime_api.h
musaMemPoolImportPointermusa_runtime_api.h
musaMemPoolExportPointermusa_runtime_api.h
musaDeviceGetDefaultMemPoolmusa_runtime_api.h
musaDeviceGetMemPoolmusa_runtime_api.h
musaDeviceSetMemPoolmusa_runtime_api.h
musaDeviceGraphMemTrimmusa_runtime_api.h
musaDeviceGetGraphMemAttributemusa_runtime_api.h
musaDeviceSetGraphMemAttributemusa_runtime_api.h
musaStreamAddCallbackmusa_runtime_api.h
musaStreamCreatemusa_runtime_api.h
musaStreamBeginCapturemusa_runtime_api.h
musaStreamBeginCaptureToGraphmusa_runtime_api.h
musaThreadExchangeStreamCaptureModemusa_runtime_api.h
musaStreamEndCapturemusa_runtime_api.h
musaStreamIsCapturingmusa_runtime_api.h
musaStreamGetCaptureInfo_v2musa_runtime_api.h
musaStreamGetCaptureInfo_v3musa_runtime_api.h
musaStreamGetCaptureInfomusa_runtime_api.h
musaStreamUpdateCaptureDependenciesmusa_runtime_api.h
musaStreamCreateWithFlagsmusa_runtime_api.h
musaStreamCreateWithPrioritymusa_runtime_api.h
musaStreamDestroymusa_runtime_api.h
musaStreamQuerymusa_runtime_api.h
musaStreamSynchronizemusa_runtime_api.h
musaStreamWaitEventmusa_runtime_api.h
musaStreamGetFlagsmusa_runtime_api.h
musaStreamGetPrioritymusa_runtime_api.h
musaStreamGetIdmusa_runtime_api.h
musaStreamGetDevicemusa_runtime_api.h
musaStreamAttachMemAsyncmusa_runtime_api.h
musaStreamSetAttributemusa_runtime_api.h
musaStreamGetAttributemusa_runtime_api.h
musaStreamCopyAttributesmusa_runtime_api.h
musaCtxResetPersistingL2Cachemusa_runtime_api.h
musaCreateTextureObjectmusa_runtime_api.h
musaDestroyTextureObjectmusa_runtime_api.h
musaGetTextureObjectResourceDescmusa_runtime_api.h
musaGetTextureObjectTextureDescmusa_runtime_api.h
musaGetTextureObjectResourceViewDescmusa_runtime_api.h
musaCreateChannelDescmusa_runtime_api.h
musaGetChannelDescmusa_runtime_api.h
musaCreateSurfaceObjectmusa_runtime_api.h
musaDestroySurfaceObjectmusa_runtime_api.h
musaGetSurfaceObjectResourceDescmusa_runtime_api.h
musaDriverGetVersionmusa_runtime_api.h
musaRuntimeGetVersionmusa_runtime_api.h
musaImportExternalSemaphoremusa_runtime_api.h
musaSignalExternalSemaphoresAsync_v2musa_runtime_api.h
musaWaitExternalSemaphoresAsync_v2musa_runtime_api.h
musaDestroyExternalSemaphoremusa_runtime_api.h
musaImportExternalMemorymusa_runtime_api.h
musaExternalMemoryGetMappedBuffermusa_runtime_api.h
musaExternalMemoryGetMappedMipmappedArraymusa_runtime_api.h
musaDestroyExternalMemorymusa_runtime_api.h
musaGraphicsGLRegisterImagemusa_gl_interop.h
musaGraphicsSubResourceGetMappedArraymusa_runtime_api.h
musaGraphAddNode_v2musa_runtime_api.h
musaGraphGetEdges_v2musa_runtime_api.h
musaGraphNodeGetDependentNodes_v2musa_runtime_api.h
musaGraphAddDependencies_v2musa_runtime_api.h
musaGraphRemoveDependencies_v2musa_runtime_api.h
musaGraphInstantiateWithParamsmusa_runtime_api.h
musaGraphicsResourceGetMappedMipmappedArraymusa_runtime_api.h
musaGraphAddExternalSemaphoresSignalNodemusa_runtime_api.h
musaGraphExternalSemaphoresSignalNodeGetParamsmusa_runtime_api.h
musaGraphExternalSemaphoresSignalNodeSetParamsmusa_runtime_api.h
musaGraphAddExternalSemaphoresWaitNodemusa_runtime_api.h
musaGraphExternalSemaphoresWaitNodeGetParamsmusa_runtime_api.h
musaGraphExternalSemaphoresWaitNodeSetParamsmusa_runtime_api.h
musaGraphExecExternalSemaphoresSignalNodeSetParamsmusa_runtime_api.h
musaGraphExecExternalSemaphoresWaitNodeSetParamsmusa_runtime_api.h
musaKernelSetAttributeForDevicemusa_runtime_api.h
musaLibraryEnumerateKernelsmusa_runtime_api.h
musaLibraryGetGlobalmusa_runtime_api.h
musaLibraryGetKernelmusa_runtime_api.h
musaLibraryGetKernelCountmusa_runtime_api.h
musaLibraryGetManagedmusa_runtime_api.h
musaLibraryGetUnifiedFunctionmusa_runtime_api.h
musaLibraryLoadDatamusa_runtime_api.h
musaLibraryLoadFromFilemusa_runtime_api.h
musaLibraryUnloadmusa_runtime_api.h

API Function Reference

__musaPushCallConfiguration

Header: device_functions.h

unsigned __musaPushCallConfiguration(dim3 gridDim, dim3 blockDim, size_t sharedMem, void *stream)

Pushes a kernel launch configuration for the MUSA runtime.

This exported runtime helper records the grid, block, shared-memory, and stream configuration used by the runtime launch path. gridDim Grid dimensions for the launch. blockDim Block dimensions for the launch. sharedMem Dynamic shared memory size in bytes. stream Stream used for the launch. Runtime launch-configuration status.

Parameters:

  • dim3 gridDim: Grid dimensions for the launch.
  • dim3 blockDim: Block dimensions for the launch.
  • size_t sharedMem: Dynamic shared memory size in bytes.
  • void * stream: Stream used for the launch.

Returns:

Runtime launch-configuration status.

__musaPopCallConfiguration

Header: host_runtime.h

musaError_t MUSARTAPI __musaPopCallConfiguration(dim3 *gridDim, dim3 *blockDim, size_t *sharedMem, void *stream)

Pops a kernel launch configuration for the MUSA runtime.

gridDim Returned grid dimensions. blockDim Returned block dimensions. sharedMem Returned dynamic shared memory size in bytes. stream Returned stream. musaSuccess or a Runtime error code.

Parameters:

  • dim3 * gridDim: Returned grid dimensions.
  • dim3 * blockDim: Returned block dimensions.
  • size_t * sharedMem: Returned dynamic shared memory size in bytes.
  • void * stream: Returned stream.

Returns:

musaSuccess or a Runtime error code.

__musaRegisterFatBinary

Header: host_runtime.h

void **MUSARTAPI __musaRegisterFatBinary(void *fatMubin)

Registers a fat binary with the MUSA runtime.

fatMubin Fat binary data. Runtime fat-binary handle.

Parameters:

  • void * fatMubin: Fat binary data.

Returns:

Runtime fat-binary handle.

__musaRegisterFatBinaryEnd

Header: host_runtime.h

void MUSARTAPI __musaRegisterFatBinaryEnd(void **fatMubinHandle)

Completes fat binary registration with the MUSA runtime.

fatMubinHandle Runtime fat-binary handle.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.

__musaRegisterFunction

Header: host_runtime.h

void MUSARTAPI __musaRegisterFunction(void **fatMubinHandle, const char *hostFun, char *deviceFun, const char *deviceName, int thread_limit, uint3 *tid, uint3 *bid, dim3 *bDim, dim3 *gDim, int *wSize)

Registers a kernel function with the MUSA runtime.

fatMubinHandle Runtime fat-binary handle. hostFun Host function pointer. deviceFun Device function pointer. deviceName Device-side function name. thread_limit Thread limit. tid Thread index metadata. bid Block index metadata. bDim Block dimension metadata. gDim Grid dimension metadata. wSize Warp-size metadata.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.
  • const char * hostFun: Host function pointer.
  • char * deviceFun: Device function pointer.
  • const char * deviceName: Device-side function name.
  • int thread_limit: Thread limit.
  • uint3 * tid: Thread index metadata.
  • uint3 * bid: Block index metadata.
  • dim3 * bDim: Block dimension metadata.
  • dim3 * gDim: Grid dimension metadata.
  • int * wSize: Warp-size metadata.

__musaRegisterVar

Header: host_runtime.h

void MUSARTAPI __musaRegisterVar(void **fatMubinHandle, char *hostVar, char *deviceAddress, const char *deviceName, int ext, size_t size, int constant, int global)

Registers a device variable with the MUSA runtime.

fatMubinHandle Runtime fat-binary handle. hostVar Host variable address. deviceAddress Device variable address. deviceName Device-side variable name. ext External linkage flag. size Variable size in bytes. constant Constant-memory flag. global Global-memory flag.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.
  • char * hostVar: Host variable address.
  • char * deviceAddress: Device variable address.
  • const char * deviceName: Device-side variable name.
  • int ext: External linkage flag.
  • size_t size: Variable size in bytes.
  • int constant: Constant-memory flag.
  • int global: Global-memory flag.

__musaRegisterTexture

Header: host_runtime.h

void MUSARTAPI __musaRegisterTexture(void **fatMubinHandle, const struct textureReference *hostVar, const void **deviceAddress, const char *deviceName, int dim, int norm, int ext)

Registers a texture reference with the MUSA runtime.

fatMubinHandle Runtime fat-binary handle. hostVar Host texture reference. deviceAddress Device texture address. deviceName Device-side texture name. dim Texture dimensionality. norm Normalization flag. ext External linkage flag.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.
  • const struct textureReference * hostVar: Host texture reference.
  • const void ** deviceAddress: Device texture address.
  • const char * deviceName: Device-side texture name.
  • int dim: Texture dimensionality.
  • int norm: Normalization flag.
  • int ext: External linkage flag.

__musaRegisterSurface

Header: host_runtime.h

void MUSARTAPI __musaRegisterSurface(void **fatMubinHandle, const struct surfaceReference *hostVar, const void **deviceAddress, const char *deviceName, int dim, int ext)

Registers a surface reference with the MUSA runtime.

fatMubinHandle Runtime fat-binary handle. hostVar Host surface reference. deviceAddress Device surface address. deviceName Device-side surface name. dim Surface dimensionality. ext External linkage flag.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.
  • const struct surfaceReference * hostVar: Host surface reference.
  • const void ** deviceAddress: Device surface address.
  • const char * deviceName: Device-side surface name.
  • int dim: Surface dimensionality.
  • int ext: External linkage flag.

__musaUnregisterFatBinary

Header: host_runtime.h

void MUSARTAPI __musaUnregisterFatBinary(void **fatMubinHandle)

Unregisters a fat binary from the MUSA runtime.

fatMubinHandle Runtime fat-binary handle.

Parameters:

  • void ** fatMubinHandle: Runtime fat-binary handle.

musaThreadExit

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadExit(void)

Exit and clean up from MUSA launches.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceReset(), which should be used instead. Explicitly destroys all cleans up all resources associated with the current device in the current process. Any subsequent API call to this device will reinitialize the device. Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called. musaSuccess musaDeviceReset

Returns:

musaSuccess

See also:

musaDeviceReset

musaThreadSynchronize

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadSynchronize(void)

Wait for compute device to finish.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is similar to the non-deprecated function musaDeviceSynchronize(), which should be used instead. Blocks until the device has completed all preceding requested tasks. musaThreadSynchronize() returns an error if one of the preceding tasks has failed. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the device has finished its work. musaSuccess musaDeviceSynchronize

Returns:

musaSuccess

See also:

musaDeviceSynchronize

musaThreadSetLimit

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadSetLimit(enum musaLimit limit, size_t value)

Set resource limits.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceSetLimit(), which should be used instead. Setting limit to value is a request by the application to update the current limit maintained by the device. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can use musaThreadGetLimit() to find out exactly what the limit has been set to. Setting each musaLimit has its own specific restrictions, so each is discussed here. musaLimitStackSize controls the stack size of each GPU thread. musaLimitPrintfFifoSize controls the size of the shared FIFO used by the printf() device system call. Setting musaLimitPrintfFifoSize must be performed before launching any kernel that uses the printf() device system call, otherwise musaErrorInvalidValue will be returned. musaLimitMallocHeapSize controls the size of the heap used by the malloc() and free() device system calls. Setting musaLimitMallocHeapSize must be performed before launching any kernel that uses the malloc() or free() device system calls, otherwise musaErrorInvalidValue will be returned. limit - Limit to set value - Size in bytes of limit musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue musaDeviceSetLimit

Parameters:

  • enum musaLimit limit: - Limit to set
  • size_t value: - Size in bytes of limit

Returns:

musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue

See also:

musaDeviceSetLimit

musaThreadGetLimit

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadGetLimit(size_t *pValue, enum musaLimit limit)

Returns resource limits.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceGetLimit(), which should be used instead. Returns in *pValue the current size of limit. The supported musaLimit values are: musaLimitStackSize: stack size of each GPU thread; musaLimitPrintfFifoSize: size of the shared FIFO used by the printf() device system call. musaLimitMallocHeapSize: size of the heap used by the malloc() and free() device system calls; limit - Limit to query pValue - Returned size in bytes of limit musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue musaDeviceGetLimit

Parameters:

  • size_t * pValue: - Returned size in bytes of limit
  • enum musaLimit limit: - Limit to query

Returns:

musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue

See also:

musaDeviceGetLimit

musaThreadGetCacheConfig

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadGetCacheConfig(enum musaFuncCache *pCacheConfig)

Returns the preferred cache configuration for the current device.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceGetCacheConfig(), which should be used instead. On devices where the L1 cache and shared memory use the same hardware resources, this returns through pCacheConfig the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute functions. This will return a pCacheConfig of musaFuncCachePreferNone on devices where the size of the L1 cache and shared memory are fixed. The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory pCacheConfig - Returned cache configuration musaSuccess musaDeviceGetCacheConfig

Parameters:

  • enum musaFuncCache * pCacheConfig: - Returned cache configuration

Returns:

musaSuccess

See also:

musaDeviceGetCacheConfig

musaThreadSetCacheConfig

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaThreadSetCacheConfig(enum musaFuncCache cacheConfig)

Sets the preferred cache configuration for the current device.

Deprecated Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function musaDeviceSetCacheConfig(), which should be used instead. On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute the function. Any function preference set via musaFuncSetCacheConfig (C API) or musaFuncSetCacheConfig (C++ API) will be preferred over this device-wide setting. Setting the device-wide cache configuration to musaFuncCachePreferNone will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel. This setting does nothing on devices where the size of the L1 cache and shared memory are fixed. Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point. The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory cacheConfig - Requested cache configuration musaSuccess musaDeviceSetCacheConfig

Parameters:

  • enum musaFuncCache cacheConfig: - Requested cache configuration

Returns:

musaSuccess

See also:

musaDeviceSetCacheConfig

musaBindTexture

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaBindTexture(size_t *offset, const struct textureReference *texref, const void *devPtr, const struct musaChannelFormatDesc *desc, size_t size __dv(UINT_MAX))

Binds a memory area to a texture.

Deprecated Binds size bytes of the memory area pointed to by devPtr to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any memory previously bound to texref is unbound. Since the hardware enforces an alignment requirement on texture base addresses, musaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function. If the device memory pointer was returned from musaMalloc(), the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. The total number of elements (or texels) in the linear address range cannot exceed musaDevicePropmaxTexture1DLinear[0]. The number of elements is computed as (size / elementSize), where elementSize is determined from desc. offset - Offset in bytes texref - Texture to bind devPtr - Memory area on device desc - Channel format size - Size of the memory area pointed to by devPtr musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C++ API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetAddress, muTexRefSetAddressMode, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetBorderColor

Parameters:

  • size_t * offset: - Offset in bytes
  • const struct textureReference * texref: - Texture to bind
  • const void * devPtr: - Memory area on device
  • const struct musaChannelFormatDesc * desc: - Channel format
  • size_t size __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C++ API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetAddress, muTexRefSetAddressMode, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetBorderColor

musaUnbindTexture

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaUnbindTexture(const struct textureReference *texref)

Unbinds a texture.

Deprecated Unbinds the texture bound to texref. If texref is not currently bound, no operation is performed. texref - Texture to unbind musaSuccess, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C++ API), musaGetTextureAlignmentOffset (C API)

Parameters:

  • const struct textureReference * texref: - Texture to unbind

Returns:

musaSuccess, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C++ API), musaGetTextureAlignmentOffset (C API)

musaBindTexture2D

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaBindTexture2D(size_t *offset, const struct textureReference *texref, const void *devPtr, const struct musaChannelFormatDesc *desc, size_t width, size_t height, size_t pitch)

Binds a 2D memory area to a texture.

Deprecated Binds the 2D memory area pointed to by devPtr to the texture reference texref. The size of the area is constrained by width in texel units, height in texel units, and pitch in byte units. desc describes how the memory is interpreted when fetching values from the texture. Any memory previously bound to texref is unbound. Since the hardware enforces an alignment requirement on texture base addresses, musaBindTexture2D() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex2D() function. If the device memory pointer was returned from musaMalloc(), the offset is guaranteed to be 0 and NULL may be passed as the offset parameter. width and height, which are specified in elements (or texels), cannot exceed musaDevicePropmaxTexture2DLinear[0] and musaDevicePropmaxTexture2DLinear[1] respectively. pitch, which is specified in bytes, cannot exceed musaDevicePropmaxTexture2DLinear[2]. The driver returns musaErrorInvalidValue if pitch is not a multiple of musaDeviceProptexturePitchAlignment. offset - Offset in bytes texref - Texture reference to bind devPtr - 2D memory area on device desc - Channel format width - Width in texel units height - Height in texel units pitch - Pitch in bytes musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C++ API), musaBindTexture2D (C++ API, inherited channel descriptor), musaBindTextureToArray (C API), musaBindTextureToArray (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetAddress2D, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetBorderColor

Parameters:

  • size_t * offset: - Offset in bytes
  • const struct textureReference * texref: - Texture reference to bind
  • const void * devPtr: - 2D memory area on device
  • const struct musaChannelFormatDesc * desc: - Channel format
  • size_t width: - Width in texel units
  • size_t height: - Height in texel units
  • size_t pitch: - Pitch in bytes

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C++ API), musaBindTexture2D (C++ API, inherited channel descriptor), musaBindTextureToArray (C API), musaBindTextureToArray (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetAddress2D, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetBorderColor

musaBindTextureToArray

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaBindTextureToArray(const struct textureReference *texref, musaArray_const_t array, const struct musaChannelFormatDesc *desc)

Binds an array to a texture.

Deprecated Binds the MUSA array array to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any MUSA array previously bound to texref is unbound. texref - Texture to bind array - Memory array on device desc - Channel format musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C++ API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetArray, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetFilterMode, muTexRefSetBorderColor, muTexRefSetMaxAnisotropy

Parameters:

  • const struct textureReference * texref: - Texture to bind
  • musaArray_const_t array: - Memory array on device
  • const struct musaChannelFormatDesc * desc: - Channel format

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C++ API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetArray, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetFilterMode, muTexRefSetBorderColor, muTexRefSetMaxAnisotropy

musaGetTextureAlignmentOffset

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaGetTextureAlignmentOffset(size_t *offset, const struct textureReference *texref)

Get the alignment offset of a texture.

Deprecated Returns in *offset the offset that was returned when texture reference texref was bound. offset - Offset of texture reference in bytes texref - Texture to get offset of musaSuccess, musaErrorInvalidTexture, musaErrorInvalidTextureBinding musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C++ API)

Parameters:

  • size_t * offset: - Offset of texture reference in bytes
  • const struct textureReference * texref: - Texture to get offset of

Returns:

musaSuccess, musaErrorInvalidTexture, musaErrorInvalidTextureBinding

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C++ API)

musaBindTextureToMipmappedArray

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaBindTextureToMipmappedArray(const struct textureReference *texref, musaMipmappedArray_const_t mipmappedArray, const struct musaChannelFormatDesc *desc)

Binds a mipmapped array to a texture.

Deprecated Binds the MUSA mipmapped array mipmappedArray to the texture reference texref. desc describes how the memory is interpreted when fetching values from the texture. Any MUSA mipmapped array previously bound to texref is unbound. texref - Texture to bind mipmappedArray - Memory mipmapped array on device desc - Channel format musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C++ API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetMipmappedArray, muTexRefSetMipmapFilterMode, muTexRefSetMipmapLevelClamp, muTexRefSetMipmapLevelBias, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetBorderColor, muTexRefSetMaxAnisotropy

Parameters:

  • const struct textureReference * texref: - Texture to bind
  • musaMipmappedArray_const_t mipmappedArray: - Memory mipmapped array on device
  • const struct musaChannelFormatDesc * desc: - Channel format

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureReference, musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C++ API), musaUnbindTexture (C API), musaGetTextureAlignmentOffset (C API), muTexRefSetMipmappedArray, muTexRefSetMipmapFilterMode, muTexRefSetMipmapLevelClamp, muTexRefSetMipmapLevelBias, muTexRefSetFormat, muTexRefSetFlags, muTexRefSetAddressMode, muTexRefSetBorderColor, muTexRefSetMaxAnisotropy

musaGetTextureReference

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaGetTextureReference(const struct textureReference **texref, const void *symbol)

Get the texture reference associated with a symbol.

Deprecated Returns in *texref the structure associated to the texture reference defined by symbol symbol. texref - Texture reference associated with symbol symbol - Texture to get reference for musaSuccess, musaErrorInvalidTexture musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureAlignmentOffset (C API), musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), muModuleGetTexRef

Parameters:

  • const struct textureReference ** texref: - Texture reference associated with symbol
  • const void * symbol: - Texture to get reference for

Returns:

musaSuccess, musaErrorInvalidTexture

See also:

musaCreateChannelDesc (C API), musaGetChannelDesc, musaGetTextureAlignmentOffset (C API), musaBindTexture (C API), musaBindTexture2D (C API), musaBindTextureToArray (C API), musaUnbindTexture (C API), muModuleGetTexRef

musaBindSurfaceToArray

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaBindSurfaceToArray(const struct surfaceReference *surfref, musaArray_const_t array, const struct musaChannelFormatDesc *desc)

Binds an array to a surface.

Deprecated Binds the MUSA array array to the surface reference surfref. desc describes how the memory is interpreted when fetching values from the surface. Any MUSA array previously bound to surfref is unbound. surfref - Surface to bind array - Memory array on device desc - Channel format musaSuccess, musaErrorInvalidValue, musaErrorInvalidSurface musaBindSurfaceToArray (C++ API), musaBindSurfaceToArray (C++ API, inherited channel descriptor), musaGetSurfaceReference, muSurfRefSetArray

Parameters:

  • const struct surfaceReference * surfref: - Surface to bind
  • musaArray_const_t array: - Memory array on device
  • const struct musaChannelFormatDesc * desc: - Channel format

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidSurface

See also:

musaBindSurfaceToArray (C++ API), musaBindSurfaceToArray (C++ API, inherited channel descriptor), musaGetSurfaceReference, muSurfRefSetArray

musaGetSurfaceReference

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaGetSurfaceReference(const struct surfaceReference **surfref, const void *symbol)

Get the surface reference associated with a symbol.

Deprecated Returns in *surfref the structure associated to the surface reference defined by symbol symbol. surfref - Surface reference associated with symbol symbol - Surface to get reference for musaSuccess, musaErrorInvalidSurface musaBindSurfaceToArray (C API), muModuleGetSurfRef

Parameters:

  • const struct surfaceReference ** surfref: - Surface reference associated with symbol
  • const void * symbol: - Surface to get reference for

Returns:

musaSuccess, musaErrorInvalidSurface

See also:

musaBindSurfaceToArray (C API), muModuleGetSurfRef

musaMemcpyFromArray

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaMemcpyFromArray(void *dst, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum musaMemcpyKind kind)

Copies data between host and device.

Deprecated Copies count bytes from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dst - Destination memory address src - Source memory address wOffset - Source starting X offset (columns in bytes) hOffset - Source starting Y offset (rows) count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoH, muMemcpyAtoD

Parameters:

  • void * dst: - Destination memory address
  • musaArray_const_t src: - Source memory address
  • size_t wOffset: - Source starting X offset (columns in bytes)
  • size_t hOffset: - Source starting Y offset (rows)
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoH, muMemcpyAtoD

musaMemcpyFromArrayAsync

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaMemcpyFromArrayAsync(void *dst, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t count, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Deprecated Copies count bytes from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. musaMemcpyFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. dst - Destination memory address src - Source memory address wOffset - Source starting X offset (columns in bytes) hOffset - Source starting Y offset (rows) count - Size in bytes to copy kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoHAsync, muMemcpy2DAsync

Parameters:

  • void * dst: - Destination memory address
  • musaArray_const_t src: - Source memory address
  • size_t wOffset: - Source starting X offset (columns in bytes)
  • size_t hOffset: - Source starting Y offset (rows)
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoHAsync, muMemcpy2DAsync

musaMemcpyToArray

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaMemcpyToArray(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum musaMemcpyKind kind)

Copies data between host and device.

Deprecated Copies count bytes from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dst - Destination memory address wOffset - Destination starting X offset (columns in bytes) hOffset - Destination starting Y offset (rows) src - Source memory address count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyHtoA, muMemcpyDtoA

Parameters:

  • musaArray_t dst: - Destination memory address
  • size_t wOffset: - Destination starting X offset (columns in bytes)
  • size_t hOffset: - Destination starting Y offset (rows)
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyHtoA, muMemcpyDtoA

musaMemcpyToArrayAsync

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaMemcpyToArrayAsync(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t count, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Deprecated Copies count bytes from the MUSA array src starting at hOffsetSrc rows and wOffsetSrc bytes from the upper left corner to the MUSA array dst starting at hOffsetDst rows and wOffsetDst bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dst - Destination memory address wOffsetDst - Destination starting X offset (columns in bytes) hOffsetDst - Destination starting Y offset (rows) src - Source memory address wOffsetSrc - Source starting X offset (columns in bytes) hOffsetSrc - Source starting Y offset (rows) count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoA Copies data between host and device Deprecated Copies count bytes from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. musaMemcpyToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. dst - Destination memory address wOffset - Destination starting X offset (columns in bytes) hOffset - Destination starting Y offset (rows) src - Source memory address count - Size in bytes to copy kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyHtoAAsync, muMemcpy2DAsync

Parameters:

  • musaArray_t dst: - Destination memory address
  • size_t wOffset: - Destination starting X offset (columns in bytes)
  • size_t hOffset: - Destination starting Y offset (rows)
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpyToArrayAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAtoA musaMemcpy, musaMemcpy2D, musaMemcpyToArray, musaMemcpy2DToArray, musaMemcpyFromArray, musaMemcpy2DFromArray, musaMemcpyArrayToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpyFromArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyHtoAAsync, muMemcpy2DAsync

musaDeviceGetPCIBusId

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGetPCIBusId(char *pciBusId, int len, int device)

Returns a PCI Bus Id string for the device.

Returns an ASCII string identifying the device dev in the NULL-terminated string pointed to by pciBusId. len specifies the maximum length of the string that may be returned. pciBusId - Returned identifier string for the device in the following format where domain, bus, device, and function are all hexadecimal values. pciBusId should be large enough to store 13 characters including the NULL-terminator. len - Maximum length of string to store in name device - Device to get identifier string for musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaDeviceGetByPCIBusId, muDeviceGetPCIBusId

Parameters:

  • char * pciBusId: - Returned identifier string for the device in the following format
  • int len: - Maximum length of string to store in name
  • int device: - Device to get identifier string for

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaDeviceGetByPCIBusId, muDeviceGetPCIBusId

musaDeviceGetByPCIBusId

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGetByPCIBusId(int *device, const char *pciBusId)

Returns a handle to a compute device.

Returns in *device a device ordinal given a PCI bus ID string. device - Returned device ordinal pciBusId - String in one of the following forms: where domain, bus, device, and function are all hexadecimal values musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaDeviceGetPCIBusId, muDeviceGetByPCIBusId

Parameters:

  • int * device: - Returned device ordinal
  • const char * pciBusId: - String in one of the following forms:

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaDeviceGetPCIBusId, muDeviceGetByPCIBusId

musaDeviceGetLimit

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetLimit(size_t *pValue, enum musaLimit limit)

Return resource limits.

Returns in *pValue the current size of limit. The following musaLimit values are supported. musaLimitStackSize is the stack size in bytes of each GPU thread. musaLimitPrintfFifoSize is the size in bytes of the shared FIFO used by the printf() device system call. musaLimitMallocHeapSize is the size in bytes of the heap used by the malloc() and free() device system calls. musaLimitDevRuntimeSyncDepth is the maximum grid depth at which a thread can isssue the device runtime call musaDeviceSynchronize() to wait on child grid launches to complete. This functionality is removed for devices of compute capability >= 9.0, and hence will return error musaErrorUnsupportedLimit on such devices. musaLimitDevRuntimePendingLaunchCount is the maximum number of outstanding device runtime launches. musaLimitMaxL2FetchGranularity is the L2 cache fetch granularity. musaLimitPersistingL2CacheSize is the persisting L2 cache size in bytes. limit - Limit to query pValue - Returned size of the limit musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue musaDeviceSetLimit, muCtxGetLimit

Parameters:

  • size_t * pValue: - Returned size of the limit
  • enum musaLimit limit: - Limit to query

Returns:

musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue

See also:

musaDeviceSetLimit, muCtxGetLimit

musaDeviceSetLimit

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceSetLimit(enum musaLimit limit, size_t value)

Set resource limits.

Setting limit to value is a request by the application to update the current limit maintained by the device. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can use musaDeviceGetLimit() to find out exactly what the limit has been set to. Setting each musaLimit has its own specific restrictions, so each is discussed here. musaLimitStackSize controls the stack size in bytes of each GPU thread. musaLimitPrintfFifoSize controls the size in bytes of the shared FIFO used by the printf() device system call. Setting musaLimitPrintfFifoSize must not be performed after launching any kernel that uses the printf() device system call - in such case musaErrorInvalidValue will be returned. musaLimitMallocHeapSize controls the size in bytes of the heap used by the malloc() and free() device system calls. Setting musaLimitMallocHeapSize must not be performed after launching any kernel that uses the malloc() or free() device system calls - in such case musaErrorInvalidValue will be returned. musaLimitDevRuntimeSyncDepth controls the maximum nesting depth of a grid at which a thread can safely call musaDeviceSynchronize(). Setting this limit must be performed before any launch of a kernel that uses the device runtime and calls musaDeviceSynchronize() above the default sync depth, two levels of grids. Calls to musaDeviceSynchronize() will fail with error code musaErrorSyncDepthExceeded if the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When setting this limit, keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory which can no longer be used for user allocations. If these reservations of device memory fail, musaDeviceSetLimit will return musaErrorMemoryAllocation, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting to set this limit on devices of other compute capability will results in error musaErrorUnsupportedLimit being returned. musaLimitDevRuntimePendingLaunchCount controls the maximum number of outstanding device runtime launches that can be made from the current device. A grid is outstanding from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation fail and return musaErrorLaunchPendingCountExceeded when musaGetLastError() is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the runtime to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations fail, musaDeviceSetLimit will return musaErrorMemoryAllocation, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher. Attempting to set this limit on devices of compute capability less than 3.5 will result in the error musaErrorUnsupportedLimit being returned. musaLimitMaxL2FetchGranularity controls the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be ignored or clamped depending on the platform. musaLimitPersistingL2CacheSize controls size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped depending on the platform. limit - Limit to set value - Size of limit musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue, musaErrorMemoryAllocation musaDeviceGetLimit, muCtxSetLimit

Parameters:

  • enum musaLimit limit: - Limit to set
  • size_t value: - Size of limit

Returns:

musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaDeviceGetLimit, muCtxSetLimit

musaDeviceGetP2PAttribute

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetP2PAttribute(int *value, enum musaDeviceP2PAttr attr, int srcDevice, int dstDevice)

Return MtSciSync attributes that this device can support.

Returns in mtSciSyncAttrList, the properties of MtSciSync that this MUSA device, dev can support. The returned mtSciSyncAttrList can be used to create an MtSciSync that matches this device's capabilities. If MtSciSyncAttrKey_RequiredPerm field in mtSciSyncAttrList is already set this API will return musaErrorInvalidValue. The applications should set mtSciSyncAttrList to a valid MtSciSyncAttrList failing which this API will return musaErrorInvalidHandle. The flags controls how applications intends to use the MtSciSync created from the mtSciSyncAttrList. The valid flags are: musaMtSciSyncAttrSignal, specifies that the applications intends to signal an MtSciSync on this MUSA device. musaMtSciSyncAttrWait, specifies that the applications intends to wait on an MtSciSync on this MUSA device. At least one of these flags must be set, failing which the API returns musaErrorInvalidValue. Both the flags are orthogonal to one another: a developer may set both these flags that allows to set both wait and signal specific attributes in the same mtSciSyncAttrList. Note that this API updates the input mtSciSyncAttrList with values equivalent to the following public attribute key-values: MtSciSyncAttrKey_RequiredPerm is set to MtSciSyncAccessPerm_SignalOnly if musaMtSciSyncAttrSignal is set in flags. MtSciSyncAccessPerm_WaitOnly if musaMtSciSyncAttrWait is set in flags. MtSciSyncAccessPerm_WaitSignal if both musaMtSciSyncAttrWait and musaMtSciSyncAttrSignal are set in flags. MtSciSyncAttrKey_PrimitiveInfo is set to MtSciSyncAttrValPrimitiveType_SysmemSemaphore on any valid device. MtSciSyncAttrValPrimitiveType_Syncpoint if device is a Tegra device. MtSciSyncAttrValPrimitiveType_SysmemSemaphorePayload64b if device is GA10X+. MtSciSyncAttrKey_GpuId is set to the same UUID that is returned in musaDeviceProp.uuid from musaDeviceGetProperties for this device. mtSciSyncAttrList - Return MtSciSync attributes supported. device - Valid Musa Device to get MtSciSync attributes for. flags - flags describing MtSciSync usage. musaSuccess, musaErrorDeviceUninitialized, musaErrorInvalidValue, musaErrorInvalidHandle, musaErrorInvalidDevice, musaErrorNotSupported, musaErrorMemoryAllocation musaImportExternalSemaphore, musaDestroyExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync Queries attributes of the link between two devices. Returns in *value the value of the requested attribute attrib of the link between srcDevice and dstDevice. The supported attributes are: musaDevP2PAttrPerformanceRank: A relative value indicating the performance of the link between two devices. Lower value means better performance (0 being the value used for most performant link). musaDevP2PAttrAccessSupported: 1 if peer access is enabled. musaDevP2PAttrNativeAtomicSupported: 1 if native atomic operations over the link are supported. musaDevP2PAttrMusaArrayAccessSupported: 1 if accessing MUSA arrays over the link is supported. Returns musaErrorInvalidDevice if srcDevice or dstDevice are not valid or if they represent the same device. Returns musaErrorInvalidValue if attrib is not valid or if value is a null pointer. value - Returned value of the requested attribute attrib - The requested attribute of the link between srcDevice and dstDevice. srcDevice - The source device of the target link. dstDevice - The destination device of the target link. musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaDeviceEnablePeerAccess, musaDeviceDisablePeerAccess, musaDeviceCanAccessPeer, muDeviceGetP2PAttribute

Parameters:

  • int * value: - Returned value of the requested attribute
  • enum musaDeviceP2PAttr attr
  • int srcDevice: - The source device of the target link.
  • int dstDevice: - The destination device of the target link.

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue

See also:

musaImportExternalSemaphore, musaDestroyExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync musaDeviceEnablePeerAccess, musaDeviceDisablePeerAccess, musaDeviceCanAccessPeer, muDeviceGetP2PAttribute

musaDeviceGetSharedMemConfig

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetSharedMemConfig(enum musaSharedMemConfig *pConfig)

Returns the shared memory configuration for the current device.

Deprecated This function will return in pConfig the current size of shared memory banks on the current device. On devices with configurable shared memory banks, musaDeviceSetSharedMemConfig can be used to change this setting, so that all subsequent kernel launches will by default use the new bank size. When musaDeviceGetSharedMemConfig is called on devices without configurable shared memory, it will return the fixed bank size of the hardware. The returned bank configurations can be either: musaSharedMemBankSizeFourByte - shared memory bank width is four bytes. musaSharedMemBankSizeEightByte - shared memory bank width is eight bytes. pConfig - Returned cache configuration musaSuccess, musaErrorInvalidValue musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceSetSharedMemConfig, musaFuncSetCacheConfig, muCtxGetSharedMemConfig

Parameters:

  • enum musaSharedMemConfig * pConfig: - Returned cache configuration

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceSetSharedMemConfig, musaFuncSetCacheConfig, muCtxGetSharedMemConfig

musaDeviceSetSharedMemConfig

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaDeviceSetSharedMemConfig(enum musaSharedMemConfig config)

Sets the shared memory configuration for the current device.

Deprecated On devices with configurable shared memory banks, this function will set the shared memory bank size which is used for all subsequent kernel launches. Any per-function setting of shared memory set via musaFuncSetSharedMemConfig will override the device wide setting. Changing the shared memory configuration between launches may introduce a device side synchronization point. Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts. This function will do nothing on devices with fixed shared memory bank size. The supported bank configurations are: musaSharedMemBankSizeDefault: set bank width the device default (currently, four bytes) musaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively. musaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively. config - Requested cache configuration musaSuccess, musaErrorInvalidValue musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceGetSharedMemConfig, musaFuncSetCacheConfig, muCtxSetSharedMemConfig

Parameters:

  • enum musaSharedMemConfig config: - Requested cache configuration

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaDeviceGetSharedMemConfig, musaFuncSetCacheConfig, muCtxSetSharedMemConfig

musaDeviceGetStreamPriorityRange

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetStreamPriorityRange(int *leastPriority, int *greatestPriority)

Returns numerical values that correspond to the least and greatest stream priorities.

Returns in *leastPriority and *greatestPriority the numerical values that correspond to the least and greatest stream priorities respectively. Stream priorities follow a convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by [ *greatestPriority, *leastPriority ]. If the user attempts to create a stream with a priority value that is outside the the meaningful range as specified by this API, the priority is automatically clamped down or up to either *leastPriority or *greatestPriority respectively. See musaStreamCreateWithPriority for details on creating a priority stream. A NULL may be passed in for *leastPriority or *greatestPriority if the value is not desired. This function will return '0' in both *leastPriority and *greatestPriority if the current context's device does not support stream priorities (see musaDeviceGetAttribute). leastPriority - Pointer to an int in which the numerical value for least stream priority is returned greatestPriority - Pointer to an int in which the numerical value for greatest stream priority is returned musaSuccess musaStreamCreateWithPriority, musaStreamGetPriority, muCtxGetStreamPriorityRange

Parameters:

  • int * leastPriority: - Pointer to an int in which the numerical value for least stream priority is returned
  • int * greatestPriority: - Pointer to an int in which the numerical value for greatest stream priority is returned

Returns:

musaSuccess

See also:

musaStreamCreateWithPriority, musaStreamGetPriority, muCtxGetStreamPriorityRange

musaDeviceReset

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceReset(void)

Destroy all allocations and reset all state on the current device in the current process.

Explicitly destroys and cleans up all resources associated with the current device in the current process. It is the caller's responsibility to ensure that the resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include MUSA types musaStream_t, musaEvent_t, musaArray_t, musaMipmappedArray_t, musaPitchedPtr, musaTextureObject_t, musaSurfaceObject_t, textureReference, surfaceReference, musaExternalMemory_t, musaExternalSemaphore_t and musaGraphicsResource_t. These resources also include memory allocations by musaMalloc, musaMallocHost, musaMallocManaged and musaMallocPitch. Any subsequent API call to this device will reinitialize the device. Note that this function will reset the device immediately. It is the caller's responsibility to ensure that the device is not being accessed by any other host threads from the process when this function is called. musaDeviceReset() will not destroy memory allocations by musaMallocAsync() and musaMallocFromPoolAsync(). These memory allocations need to be destroyed explicitly. If a non-primary MUcontext is current to the thread, musaDeviceReset() will destroy only the internal MUSA RT state for that MUcontext. musaSuccess musaDeviceSynchronize

Returns:

musaSuccess

See also:

musaDeviceSynchronize

musaDeviceSynchronize

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceSynchronize(void)

Wait for compute device to finish.

Blocks until the device has completed all preceding requested tasks. musaDeviceSynchronize() returns an error if one of the preceding tasks has failed. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the device has finished its work. musaSuccess musaDeviceReset, muCtxSynchronize

Returns:

musaSuccess

See also:

musaDeviceReset, muCtxSynchronize

musaGetDevice

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaGetDevice(int *device)

Returns which device is currently being used.

Returns in *device the current device for the calling host thread. device - Returns the device on which the active host thread executes the device code. musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable, musaGetDeviceCount, musaSetDevice, musaGetDeviceProperties, musaChooseDevice, muCtxGetCurrent

Parameters:

  • int * device: - Returns the device on which the active host thread executes the device code.

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable,

See also:

musaGetDeviceCount, musaSetDevice, musaGetDeviceProperties, musaChooseDevice, muCtxGetCurrent

musaGetDeviceCount

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaGetDeviceCount(int *count)

Returns the number of compute-capable devices.

Returns in *count the number of devices with compute capability greater or equal to 2.0 that are available for execution. count - Returns the number of devices with compute capability greater or equal to 2.0 musaSuccess musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muDeviceGetCount

Parameters:

  • int * count: - Returns the number of devices with compute capability greater or equal to 2.0

Returns:

musaSuccess

See also:

musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muDeviceGetCount

musaSetDevice

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaSetDevice(int device)

Set device to be used for GPU executions.

Sets device as the current device for the calling host thread. Valid device id's are 0 to (musaGetDeviceCount() - 1). Any device memory subsequently allocated from this host thread using musaMalloc(), musaMallocPitch() or musaMallocArray() will be physically resident on device. Any host memory allocated from this host thread using musaMallocHost() or musaHostAlloc() or musaHostRegister() will have its lifetime associated with device. Any streams or events created from this host thread will be associated with device. Any kernels launched from this host thread using the &lt;&lt;&lt;&gt;&gt;&gt; operator or musaLaunchKernel() will be executed on device. This call may be made from any host thread, to any device, and at any time. This function will do no synchronization with the previous or new device, and should only take significant time when it initializes the runtime's context state. This call will bind the primary context of the specified device to the calling thread and all the subsequent memory allocations, stream and event creations, and kernel launches will be associated with the primary context. This function will also immediately initialize the runtime state on the primary context, and the context will be current on device immediately. This function will return an error if the device is in musaComputeModeExclusiveProcess and is occupied by another process or if the device is in musaComputeModeProhibited. It is not required to call musaInitDevice before using this function. device - Device on which the active host thread should execute the device code. musaSuccess, musaErrorInvalidDevice, musaErrorDeviceUnavailable, musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muCtxSetCurrent

Parameters:

  • int device: - Device on which the active host thread should execute the device code.

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorDeviceUnavailable,

See also:

musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaInitDevice, muCtxSetCurrent

musaGetDeviceFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetDeviceFlags(unsigned int *flags)

Gets the flags for the current device.

Returns in flags the flags for the current device. If there is a current device for the calling thread, the flags for the device are returned. If there is no current device, the flags for the first device are returned, which may be the default flags. Compare to the behavior of musaSetDeviceFlags. Typically, the flags returned should match the behavior that will be seen if the calling thread uses a device after this call, without any change to the flags or current device inbetween by this or another thread. Note that if the device is not initialized, it is possible for another thread to change the flags for the current device before it is initialized. Additionally, when using exclusive mode, if this thread has not requested a specific device, it may use a device other than the first device, contrary to the assumption made by this function. If a context has been created via the driver API and is current to the calling thread, the flags for that context are always returned. Flags returned by this function may specifically include musaDeviceMapHost even though it is not accepted by musaSetDeviceFlags because it is implicit in runtime API flags. The reason for this is that the current context may have been created via the driver API in which case the flag is not implicit and may be unset. flags - Pointer to store the device flags musaSuccess, musaErrorInvalidDevice musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetDeviceFlags, musaInitDevice, muCtxGetFlags, muDevicePrimaryCtxGetState

Parameters:

  • unsigned int * flags: - Pointer to store the device flags

Returns:

musaSuccess, musaErrorInvalidDevice

See also:

musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetDeviceFlags, musaInitDevice, muCtxGetFlags, muDevicePrimaryCtxGetState

musaSetDeviceFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaSetDeviceFlags(unsigned int flags)

Set a list of devices that can be used for MUSA.

Sets a list of devices for MUSA execution in priority order using device_arr. The parameter len specifies the number of elements in the list. MUSA will try devices from the list sequentially until it finds one that works. If this function is not called, or if it is called with a len of 0, then MUSA will go back to its default behavior of trying devices sequentially from a default list containing all of the available MUSA devices in the system. If a specified device ID in the list does not exist, this function will return musaErrorInvalidDevice. If len is not 0 and device_arr is NULL or if len exceeds the number of devices in the system, then musaErrorInvalidValue is returned. device_arr - List of devices to try len - Number of devices in specified list musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaGetDeviceCount, musaSetDevice, musaGetDeviceProperties, musaSetDeviceFlags, musaChooseDevice Sets flags to be used for device executions Records flags as the flags for the current device. If the current device has been set and that device has already been initialized, the previous flags are overwritten. If the current device has not been initialized, it is initialized with the provided flags. If no device has been made current to the calling thread, a default device is selected and initialized with the provided flags. The three LSBs of the flags parameter can be used to control how the CPU thread interacts with the OS scheduler when waiting for results from the device. musaDeviceScheduleAuto: The default value if the flags parameter is zero, uses a heuristic based on the number of active MUSA contexts in the process C and the number of logical processors in the system P. If C > P, then MUSA will yield to other OS threads when waiting for the device, otherwise MUSA will not yield while waiting for results and actively spin on the processor. Additionally, on Tegra devices, musaDeviceScheduleAuto uses a heuristic based on the power profile of the platform and may choose musaDeviceScheduleBlockingSync for low-powered devices. musaDeviceScheduleSpin: Instruct MUSA to actively spin when waiting for results from the device. This can decrease latency when waiting for the device, but may lower the performance of CPU threads if they are performing work in parallel with the MUSA thread. musaDeviceScheduleYield: Instruct MUSA to yield its thread when waiting for results from the device. This can increase latency when waiting for the device, but can increase the performance of CPU threads performing work in parallel with the device. musaDeviceScheduleBlockingSync: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. musaDeviceBlockingSync: Instruct MUSA to block the CPU thread on a synchronization primitive when waiting for the device to finish work. Deprecated: This flag was deprecated as of MUSA 4.0 and replaced with musaDeviceScheduleBlockingSync. musaDeviceMapHost: This flag enables allocating pinned host memory that is accessible to the device. It is implicit for the runtime but may be absent if a context is created using the driver API. If this flag is not set, musaHostGetDevicePointer() will always return a failure code. musaDeviceLmemResizeToMax: Instruct MUSA to not reduce local memory after resizing local memory for a kernel. This can prevent thrashing by local memory allocations when launching many kernels with high local memory usage at the cost of potentially increased memory usage. Deprecated: This flag is deprecated and the behavior enabled by this flag is now the default and cannot be disabled. musaDeviceSyncMemops: Ensures that synchronous memory operations initiated on this context will always synchronize. See further documentation in the section titled "API Synchronization behavior" to learn more about cases when synchronous memory operations can exhibit asynchronous behavior. flags - for device operation musaSuccess, musaErrorInvalidValue musaGetDeviceFlags, musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetValidDevices, musaInitDevice, musaChooseDevice, muDevicePrimaryCtxSetFlags

Parameters:

  • unsigned int flags: - Parameters for device operation

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaSuccess, musaErrorInvalidValue

See also:

musaGetDeviceCount, musaSetDevice, musaGetDeviceProperties, musaSetDeviceFlags, musaChooseDevice musaGetDeviceFlags, musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaSetDevice, musaSetValidDevices, musaInitDevice, musaChooseDevice, muDevicePrimaryCtxSetFlags

musaGetDeviceProperties_v2

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaGetDeviceProperties_v2(struct musaDeviceProp *prop, int device)

Returns information about the device.

Versioned exported form of musaGetDeviceProperties. prop Properties for the specified device. device Device number to get properties for. musaSuccess or musaErrorInvalidDevice.

Parameters:

  • struct musaDeviceProp * prop: Properties for the specified device.
  • int device: Device number to get properties for.

Returns:

musaSuccess or musaErrorInvalidDevice.

musaGetDeviceProperties

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaGetDeviceProperties(struct musaDeviceProp *prop, int device)

Returns information about the compute-device.

Returns in *prop the properties of device dev. The musaDeviceProp structure is defined as: struct musaDeviceProp { char name[256]; musaUUID_t uuid; size_t totalGlobalMem; size_t sharedMemPerBlock; int regsPerBlock; int warpSize; size_t memPitch; int maxThreadsPerBlock; int maxThreadsDim[3]; int maxGridSize[3]; int clockRate; size_t totalConstMem; int major; int minor; size_t textureAlignment; size_t texturePitchAlignment; int deviceOverlap; int multiProcessorCount; int kernelExecTimeoutEnabled; int integrated; int canMapHostMemory; int computeMode; int maxTexture1D; int maxTexture1DMipmap; int maxTexture1DLinear; int maxTexture2D[2]; int maxTexture2DMipmap[2]; int maxTexture2DLinear[3]; int maxTexture2DGather[2]; int maxTexture3D[3]; int maxTexture3DAlt[3]; int maxTextureCubemap; int maxTexture1DLayered[2]; int maxTexture2DLayered[3]; int maxTextureCubemapLayered[2]; int maxSurface1D; int maxSurface2D[2]; int maxSurface3D[3]; int maxSurface1DLayered[2]; int maxSurface2DLayered[3]; int maxSurfaceCubemap; int maxSurfaceCubemapLayered[2]; size_t surfaceAlignment; int concurrentKernels; int ECCEnabled; int pciBusID; int pciDeviceID; int pciDomainID; int tccDriver; int asyncEngineCount; int unifiedAddressing; int memoryClockRate; int memoryBusWidth; int l2CacheSize; int persistingL2CacheMaxSize; int maxThreadsPerMultiProcessor; int streamPrioritiesSupported; int globalL1CacheSupported; int localL1CacheSupported; size_t sharedMemPerMultiprocessor; int regsPerMultiprocessor; int managedMemory; int isMultiGpuBoard; int multiGpuBoardGroupID; int singleToDoublePrecisionPerfRatio; int pageableMemoryAccess; int concurrentManagedAccess; int computePreemptionSupported; int canUseHostPointerForRegisteredMem; int cooperativeLaunch; int cooperativeMultiDeviceLaunch; int pageableMemoryAccessUsesHostPageTables; int directManagedMemAccessFromHost; int accessPolicyMaxWindowSize; } where: name[256] is an ASCII string identifying the device. uuid is a 16-byte unique identifier. totalGlobalMem is the total amount of global memory available on the device in bytes. sharedMemPerBlock is the maximum amount of shared memory available to a thread block in bytes. regsPerBlock is the maximum number of 32-bit registers available to a thread block. warpSize is the warp size in threads. memPitch is the maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through musaMallocPitch(). maxThreadsPerBlock is the maximum number of threads per block. maxThreadsDim[3] contains the maximum size of each dimension of a block. maxGridSize[3] contains the maximum size of each dimension of a grid. clockRate is the clock frequency in kilohertz. totalConstMem is the total amount of constant memory available on the device in bytes. major, minor are the major and minor revision numbers defining the device's compute capability. textureAlignment is the alignment requirement; texture base addresses that are aligned to textureAlignment bytes do not need an offset applied to texture fetches. texturePitchAlignment is the pitch alignment requirement for 2D texture references that are bound to pitched memory. deviceOverlap is 1 if the device can concurrently copy memory between host and device while executing a kernel, or 0 if not. Deprecated, use instead asyncEngineCount. multiProcessorCount is the number of multiprocessors on the device. kernelExecTimeoutEnabled is 1 if there is a run time limit for kernels executed on the device, or 0 if not. integrated is 1 if the device is an integrated (motherboard) GPU and 0 if it is a discrete (card) component. canMapHostMemory is 1 if the device can map host memory into the MUSA address space for use with musaHostAlloc() / musaHostGetDevicePointer(), or 0 if not. computeMode is the compute mode that the device is currently in. Available modes are as follows: musaComputeModeDefault: Default mode - Device is not restricted and multiple threads can use musaSetDevice() with this device. musaComputeModeProhibited: Compute-prohibited mode - No threads can use musaSetDevice() with this device. musaComputeModeExclusiveProcess: Compute-exclusive-process mode - Many threads in one process will be able to use musaSetDevice() with this device. When an occupied exclusive mode device is chosen with musaSetDevice, all subsequent non-device management runtime functions will return musaErrorDevicesUnavailable. maxTexture1D is the maximum 1D texture size. maxTexture1DMipmap is the maximum 1D mipmapped texture texture size. maxTexture1DLinear is the maximum 1D texture size for textures bound to linear memory. maxTexture2D[2] contains the maximum 2D texture dimensions. maxTexture2DMipmap[2] contains the maximum 2D mipmapped texture dimensions. maxTexture2DLinear[3] contains the maximum 2D texture dimensions for 2D textures bound to pitch linear memory. maxTexture2DGather[2] contains the maximum 2D texture dimensions if texture gather operations have to be performed. maxTexture3D[3] contains the maximum 3D texture dimensions. maxTexture3DAlt[3] contains the maximum alternate 3D texture dimensions. maxTextureCubemap is the maximum cubemap texture width or height. maxTexture1DLayered[2] contains the maximum 1D layered texture dimensions. maxTexture2DLayered[3] contains the maximum 2D layered texture dimensions. maxTextureCubemapLayered[2] contains the maximum cubemap layered texture dimensions. maxSurface1D is the maximum 1D surface size. maxSurface2D[2] contains the maximum 2D surface dimensions. maxSurface3D[3] contains the maximum 3D surface dimensions. maxSurface1DLayered[2] contains the maximum 1D layered surface dimensions. maxSurface2DLayered[3] contains the maximum 2D layered surface dimensions. maxSurfaceCubemap is the maximum cubemap surface width or height. maxSurfaceCubemapLayered[2] contains the maximum cubemap layered surface dimensions. surfaceAlignment specifies the alignment requirements for surfaces. concurrentKernels is 1 if the device supports executing multiple kernels within the same context simultaneously, or 0 if not. It is not guaranteed that multiple kernels will be resident on the device concurrently so this feature should not be relied upon for correctness. ECCEnabled is 1 if the device has ECC support turned on, or 0 if not. pciBusID is the PCI bus identifier of the device. pciDeviceID is the PCI device (sometimes called slot) identifier of the device. pciDomainID is the PCI domain identifier of the device. tccDriver is 1 if the device is using a TCC driver or 0 if not. asyncEngineCount is 1 when the device can concurrently copy memory between host and device while executing a kernel. It is 2 when the device can concurrently copy memory between host and device in both directions and execute a kernel at the same time. It is 0 if neither of these is supported. unifiedAddressing is 1 if the device shares a unified address space with the host and 0 otherwise. memoryClockRate is the peak memory clock frequency in kilohertz. memoryBusWidth is the memory bus width in bits. l2CacheSize is L2 cache size in bytes. persistingL2CacheMaxSize is L2 cache's maximum persisting lines size in bytes. maxThreadsPerMultiProcessor is the number of maximum resident threads per multiprocessor. streamPrioritiesSupported is 1 if the device supports stream priorities, or 0 if it is not supported. globalL1CacheSupported is 1 if the device supports caching of globals in L1 cache, or 0 if it is not supported. localL1CacheSupported is 1 if the device supports caching of locals in L1 cache, or 0 if it is not supported. sharedMemPerMultiprocessor is the maximum amount of shared memory available to a multiprocessor in bytes; this amount is shared by all thread blocks simultaneously resident on a multiprocessor. regsPerMultiprocessor is the maximum number of 32-bit registers available to a multiprocessor; this number is shared by all thread blocks simultaneously resident on a multiprocessor. managedMemory is 1 if the device supports allocating managed memory on this system, or 0 if it is not supported. isMultiGpuBoard is 1 if the device is on a multi-GPU board (e.g. Gemini cards), and 0 if not; multiGpuBoardGroupID is a unique identifier for a group of devices associated with the same board. Devices on the same multi-GPU board will share the same identifier. hostNativeAtomicSupported is 1 if the link between the device and the host supports native atomic operations, or 0 if it is not supported. singleToDoublePrecisionPerfRatio is the ratio of single precision performance (in floating-point operations per second) to double precision performance. pageableMemoryAccess is 1 if the device supports coherently accessing pageable memory without calling musaHostRegister on it, and 0 otherwise. concurrentManagedAccess is 1 if the device can coherently access managed memory concurrently with the CPU, and 0 otherwise. computePreemptionSupported is 1 if the device supports Compute Preemption, and 0 otherwise. canUseHostPointerForRegisteredMem is 1 if the device can access host registered memory at the same virtual address as the CPU, and 0 otherwise. cooperativeLaunch is 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernel, and 0 otherwise. cooperativeMultiDeviceLaunch is 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernelMultiDevice, and 0 otherwise. sharedMemPerBlockOptin is the per device maximum shared memory per block usable by special opt in pageableMemoryAccessUsesHostPageTables is 1 if the device accesses pageable memory via the host's page tables, and 0 otherwise. directManagedMemAccessFromHost is 1 if the host can directly access managed memory on the device without migration, and 0 otherwise. maxBlocksPerMultiProcessor is the maximum number of thread blocks that can reside on a multiprocessor. accessPolicyMaxWindowSize is the maximum value of musaAccessPolicyWindownum_bytes. reservedSharedMemPerBlock is the shared memory reserved by MUSA driver per block in bytes hostRegisterSupported is 1 if the device supports host memory registration via musaHostRegister, and 0 otherwise. sparseMusaArraySupported is 1 if the device supports sparse MUSA arrays and sparse MUSA mipmapped arrays, 0 otherwise hostRegisterReadOnlySupported is 1 if the device supports using the musaHostRegister flag musaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU timelineSemaphoreInteropSupported is 1 if external timeline semaphore interop is supported on the device, 0 otherwise memoryPoolsSupported is 1 if the device supports using the musaMallocAsync and musaMemPool family of APIs, 0 otherwise gpuDirectRDMASupported is 1 if the device supports GPUDirect RDMA APIs, 0 otherwise gpuDirectRDMAFlushWritesOptions is a bitmask to be interpreted according to the musaFlushGPUDirectRDMAWritesOptions enum gpuDirectRDMAWritesOrdering See the musaGPUDirectRDMAWritesOrdering enum for numerical values memoryPoolSupportedHandleTypes is a bitmask of handle types supported with mempool-based IPC deferredMappingMusaArraySupported is 1 if the device supports deferred mapping MUSA arrays and MUSA mipmapped arrays ipcEventSupported is 1 if the device supports IPC Events, and 0 otherwise unifiedFunctionPointers is 1 if the device support unified pointers, and 0 otherwise prop - Properties for the specified device device - Device number to get properties for musaSuccess, musaErrorInvalidDevice musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaDeviceGetAttribute, musaInitDevice, muDeviceGetAttribute, muDeviceGetName

Parameters:

  • struct musaDeviceProp * prop: - Properties for the specified device
  • int device: - Device number to get properties for

Returns:

musaSuccess, musaErrorInvalidDevice

See also:

musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaDeviceGetAttribute, musaInitDevice, muDeviceGetAttribute, muDeviceGetName

musaInitDevice

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaInitDevice(int device, unsigned int deviceFlags, unsigned int flags)

Initialize device to be used for GPU executions.

This function will initialize the MUSA Runtime structures and primary context on device when called, but the context will not be made current to device. When musaInitDeviceFlagsAreValid is set in flags, deviceFlags are applied to the requested device. The values of deviceFlags match those of the flags parameters in musaSetDeviceFlags. The effect may be verified by musaGetDeviceFlags. This function will return an error if the device is in musaComputeModeExclusiveProcess and is occupied by another process or if the device is in musaComputeModeProhibited. device - Device on which the runtime will initialize itself. deviceFlags - for device operation. flags - Flags for controlling the device initialization. musaSuccess, musaErrorInvalidDevice, musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaSetDevice muCtxSetCurrent

Parameters:

  • int device: - Device on which the runtime will initialize itself.
  • unsigned int deviceFlags: - Parameters for device operation.
  • unsigned int flags: - Flags for controlling the device initialization.

Returns:

musaSuccess, musaErrorInvalidDevice,

See also:

musaGetDeviceCount, musaGetDevice, musaGetDeviceProperties, musaChooseDevice, musaSetDevice muCtxSetCurrent

musaDeviceGetTexture1DLinearMaxWidth

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetTexture1DLinearMaxWidth(size_t *maxWidthInElements, const struct musaChannelFormatDesc *fmtDesc, int device)

Returns the maximum number of elements allocatable in a 1D linear texture for a given element size.

Returns in maxWidthInElements the maximum number of elements allocatable in a 1D linear texture for given format descriptor fmtDesc. maxWidthInElements - Returns maximum number of texture elements allocatable for given fmtDesc. fmtDesc - Texture format description. musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue muDeviceGetTexture1DLinearMaxWidth

Parameters:

  • size_t * maxWidthInElements: - Returns maximum number of texture elements allocatable for given fmtDesc.
  • const struct musaChannelFormatDesc * fmtDesc: - Texture format description.
  • int device

Returns:

musaSuccess, musaErrorUnsupportedLimit, musaErrorInvalidValue

See also:

muDeviceGetTexture1DLinearMaxWidth

musaDeviceGetCacheConfig

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetCacheConfig(enum musaFuncCache *pCacheConfig)

Returns the preferred cache configuration for the current device.

On devices where the L1 cache and shared memory use the same hardware resources, this returns through pCacheConfig the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute functions. This will return a pCacheConfig of musaFuncCachePreferNone on devices where the size of the L1 cache and shared memory are fixed. The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory musaFuncCachePreferEqual: prefer equal size L1 cache and shared memory pCacheConfig - Returned cache configuration musaSuccess musaDeviceSetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxGetCacheConfig

Parameters:

  • enum musaFuncCache * pCacheConfig: - Returned cache configuration

Returns:

musaSuccess

See also:

musaDeviceSetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxGetCacheConfig

musaDeviceSetCacheConfig

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceSetCacheConfig(enum musaFuncCache cacheConfig)

Sets the preferred cache configuration for the current device.

On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the current device. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute the function. Any function preference set via musaFuncSetCacheConfig (C API) or musaFuncSetCacheConfig (C++ API) will be preferred over this device-wide setting. Setting the device-wide cache configuration to musaFuncCachePreferNone will cause subsequent kernel launches to prefer to not change the cache configuration unless required to launch the kernel. This setting does nothing on devices where the size of the L1 cache and shared memory are fixed. Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point. The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory musaFuncCachePreferEqual: prefer equal size L1 cache and shared memory cacheConfig - Requested cache configuration musaSuccess musaDeviceGetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxSetCacheConfig

Parameters:

  • enum musaFuncCache cacheConfig: - Requested cache configuration

Returns:

musaSuccess

See also:

musaDeviceGetCacheConfig, musaFuncSetCacheConfig (C API), musaFuncSetCacheConfig (C++ API), muCtxSetCacheConfig

musaChooseDevice

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaChooseDevice(int *device, const struct musaDeviceProp *prop)

Select compute-device which best matches criteria.

Returns in *device the device which has properties that best match *prop. device - Device with best match prop - Desired device properties musaSuccess, musaErrorInvalidValue musaGetDeviceCount, musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaInitDevice

Parameters:

  • int * device: - Device with best match
  • const struct musaDeviceProp * prop: - Desired device properties

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGetDeviceCount, musaGetDevice, musaSetDevice, musaGetDeviceProperties, musaInitDevice

musaDeviceGetAttribute

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaDeviceGetAttribute(int *value, enum musaDeviceAttr attr, int device)

Returns information about the device.

Returns in *value the integer value of the attribute attr on device device. The supported attributes are: musaDevAttrMaxThreadsPerBlock: Maximum number of threads per block musaDevAttrMaxBlockDimX: Maximum x-dimension of a block musaDevAttrMaxBlockDimY: Maximum y-dimension of a block musaDevAttrMaxBlockDimZ: Maximum z-dimension of a block musaDevAttrMaxGridDimX: Maximum x-dimension of a grid musaDevAttrMaxGridDimY: Maximum y-dimension of a grid musaDevAttrMaxGridDimZ: Maximum z-dimension of a grid musaDevAttrMaxSharedMemoryPerBlock: Maximum amount of shared memory available to a thread block in bytes musaDevAttrTotalConstantMemory: Memory available on device for constant variables in a MUSA C kernel in bytes musaDevAttrWarpSize: Warp size in threads musaDevAttrMaxPitch: Maximum pitch in bytes allowed by the memory copy functions that involve memory regions allocated through musaMallocPitch() musaDevAttrMaxTexture1DWidth: Maximum 1D texture width musaDevAttrMaxTexture1DLinearWidth: Maximum width for a 1D texture bound to linear memory musaDevAttrMaxTexture1DMipmappedWidth: Maximum mipmapped 1D texture width musaDevAttrMaxTexture2DWidth: Maximum 2D texture width musaDevAttrMaxTexture2DHeight: Maximum 2D texture height musaDevAttrMaxTexture2DLinearWidth: Maximum width for a 2D texture bound to linear memory musaDevAttrMaxTexture2DLinearHeight: Maximum height for a 2D texture bound to linear memory musaDevAttrMaxTexture2DLinearPitch: Maximum pitch in bytes for a 2D texture bound to linear memory musaDevAttrMaxTexture2DMipmappedWidth: Maximum mipmapped 2D texture width musaDevAttrMaxTexture2DMipmappedHeight: Maximum mipmapped 2D texture height musaDevAttrMaxTexture3DWidth: Maximum 3D texture width musaDevAttrMaxTexture3DHeight: Maximum 3D texture height musaDevAttrMaxTexture3DDepth: Maximum 3D texture depth musaDevAttrMaxTexture3DWidthAlt: Alternate maximum 3D texture width, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTexture3DHeightAlt: Alternate maximum 3D texture height, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTexture3DDepthAlt: Alternate maximum 3D texture depth, 0 if no alternate maximum 3D texture size is supported musaDevAttrMaxTextureCubemapWidth: Maximum cubemap texture width or height musaDevAttrMaxTexture1DLayeredWidth: Maximum 1D layered texture width musaDevAttrMaxTexture1DLayeredLayers: Maximum layers in a 1D layered texture musaDevAttrMaxTexture2DLayeredWidth: Maximum 2D layered texture width musaDevAttrMaxTexture2DLayeredHeight: Maximum 2D layered texture height musaDevAttrMaxTexture2DLayeredLayers: Maximum layers in a 2D layered texture musaDevAttrMaxTextureCubemapLayeredWidth: Maximum cubemap layered texture width or height musaDevAttrMaxTextureCubemapLayeredLayers: Maximum layers in a cubemap layered texture musaDevAttrMaxSurface1DWidth: Maximum 1D surface width musaDevAttrMaxSurface2DWidth: Maximum 2D surface width musaDevAttrMaxSurface2DHeight: Maximum 2D surface height musaDevAttrMaxSurface3DWidth: Maximum 3D surface width musaDevAttrMaxSurface3DHeight: Maximum 3D surface height musaDevAttrMaxSurface3DDepth: Maximum 3D surface depth musaDevAttrMaxSurface1DLayeredWidth: Maximum 1D layered surface width musaDevAttrMaxSurface1DLayeredLayers: Maximum layers in a 1D layered surface musaDevAttrMaxSurface2DLayeredWidth: Maximum 2D layered surface width musaDevAttrMaxSurface2DLayeredHeight: Maximum 2D layered surface height musaDevAttrMaxSurface2DLayeredLayers: Maximum layers in a 2D layered surface musaDevAttrMaxSurfaceCubemapWidth: Maximum cubemap surface width musaDevAttrMaxSurfaceCubemapLayeredWidth: Maximum cubemap layered surface width musaDevAttrMaxSurfaceCubemapLayeredLayers: Maximum layers in a cubemap layered surface musaDevAttrMaxRegistersPerBlock: Maximum number of 32-bit registers available to a thread block musaDevAttrClockRate: Peak clock frequency in kilohertz musaDevAttrTextureAlignment: Alignment requirement; texture base addresses aligned to textureAlign bytes do not need an offset applied to texture fetches musaDevAttrTexturePitchAlignment: Pitch alignment requirement for 2D texture references bound to pitched memory musaDevAttrGpuOverlap: 1 if the device can concurrently copy memory between host and device while executing a kernel, or 0 if not musaDevAttrMultiProcessorCount: Number of multiprocessors on the device musaDevAttrKernelExecTimeout: 1 if there is a run time limit for kernels executed on the device, or 0 if not musaDevAttrIntegrated: 1 if the device is integrated with the memory subsystem, or 0 if not musaDevAttrCanMapHostMemory: 1 if the device can map host memory into the MUSA address space, or 0 if not musaDevAttrComputeMode: Compute mode is the compute mode that the device is currently in. Available modes are as follows: musaComputeModeDefault: Default mode - Device is not restricted and multiple threads can use musaSetDevice() with this device. musaComputeModeProhibited: Compute-prohibited mode - No threads can use musaSetDevice() with this device. musaComputeModeExclusiveProcess: Compute-exclusive-process mode - Many threads in one process will be able to use musaSetDevice() with this device. musaDevAttrConcurrentKernels: 1 if the device supports executing multiple kernels within the same context simultaneously, or 0 if not. It is not guaranteed that multiple kernels will be resident on the device concurrently so this feature should not be relied upon for correctness. musaDevAttrEccEnabled: 1 if error correction is enabled on the device, 0 if error correction is disabled or not supported by the device musaDevAttrPciBusId: PCI bus identifier of the device musaDevAttrPciDeviceId: PCI device (also known as slot) identifier of the device musaDevAttrTccDriver: 1 if the device is using a TCC driver. TCC is only available on Tesla hardware running Windows Vista or later. musaDevAttrMemoryClockRate: Peak memory clock frequency in kilohertz musaDevAttrGlobalMemoryBusWidth: Global memory bus width in bits musaDevAttrL2CacheSize: Size of L2 cache in bytes. 0 if the device doesn't have L2 cache. musaDevAttrMaxThreadsPerMultiProcessor: Maximum resident threads per multiprocessor musaDevAttrUnifiedAddressing: 1 if the device shares a unified address space with the host, or 0 if not musaDevAttrComputeCapabilityMajor: Major compute capability version number musaDevAttrComputeCapabilityMinor: Minor compute capability version number musaDevAttrStreamPrioritiesSupported: 1 if the device supports stream priorities, or 0 if not musaDevAttrGlobalL1CacheSupported: 1 if device supports caching globals in L1 cache, 0 if not musaDevAttrLocalL1CacheSupported: 1 if device supports caching locals in L1 cache, 0 if not musaDevAttrMaxSharedMemoryPerMultiprocessor: Maximum amount of shared memory available to a multiprocessor in bytes; this amount is shared by all thread blocks simultaneously resident on a multiprocessor musaDevAttrMaxRegistersPerMultiprocessor: Maximum number of 32-bit registers available to a multiprocessor; this number is shared by all thread blocks simultaneously resident on a multiprocessor musaDevAttrManagedMemory: 1 if device supports allocating managed memory, 0 if not musaDevAttrIsMultiGpuBoard: 1 if device is on a multi-GPU board, 0 if not musaDevAttrMultiGpuBoardGroupID: Unique identifier for a group of devices on the same multi-GPU board musaDevAttrHostNativeAtomicSupported: 1 if the link between the device and the host supports native atomic operations musaDevAttrSingleToDoublePrecisionPerfRatio: Ratio of single precision performance (in floating-point operations per second) to double precision performance musaDevAttrPageableMemoryAccess: 1 if the device supports coherently accessing pageable memory without calling musaHostRegister on it, and 0 otherwise musaDevAttrConcurrentManagedAccess: 1 if the device can coherently access managed memory concurrently with the CPU, and 0 otherwise musaDevAttrComputePreemptionSupported: 1 if the device supports Compute Preemption, 0 if not musaDevAttrCanUseHostPointerForRegisteredMem: 1 if the device can access host registered memory at the same virtual address as the CPU, and 0 otherwise musaDevAttrCooperativeLaunch: 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernel, and 0 otherwise musaDevAttrCooperativeMultiDeviceLaunch: 1 if the device supports launching cooperative kernels via musaLaunchCooperativeKernelMultiDevice, and 0 otherwise musaDevAttrCanFlushRemoteWrites: 1 if the device supports flushing of outstanding remote writes, and 0 otherwise musaDevAttrHostRegisterSupported: 1 if the device supports host memory registration via musaHostRegister, and 0 otherwise musaDevAttrPageableMemoryAccessUsesHostPageTables: 1 if the device accesses pageable memory via the host's page tables, and 0 otherwise musaDevAttrDirectManagedMemAccessFromHost: 1 if the host can directly access managed memory on the device without migration, and 0 otherwise musaDevAttrMaxSharedMemoryPerBlockOptin: Maximum per block shared memory size on the device. This value can be opted into when using musaFuncSetAttribute musaDevAttrMaxBlocksPerMultiprocessor: Maximum number of thread blocks that can reside on a multiprocessor musaDevAttrMaxPersistingL2CacheSize: Maximum L2 persisting lines capacity setting in bytes musaDevAttrMaxAccessPolicyWindowSize: Maximum value of musaAccessPolicyWindownum_bytes musaDevAttrReservedSharedMemoryPerBlock: Shared memory reserved by MUSA driver per block in bytes musaDevAttrSparseMusaArraySupported: 1 if the device supports sparse MUSA arrays and sparse MUSA mipmapped arrays. musaDevAttrHostRegisterReadOnlySupported: Device supports using the musaHostRegister flag musaHostRegisterReadOnly to register memory that must be mapped as read-only to the GPU musaDevAttrMemoryPoolsSupported: 1 if the device supports using the musaMallocAsync and musaMemPool family of APIs, and 0 otherwise musaDevAttrGPUDirectRDMASupported: 1 if the device supports GPUDirect RDMA APIs, and 0 otherwise musaDevAttrGPUDirectRDMAFlushWritesOptions: bitmask to be interpreted according to the musaFlushGPUDirectRDMAWritesOptions enum musaDevAttrGPUDirectRDMAWritesOrdering: see the musaGPUDirectRDMAWritesOrdering enum for numerical values musaDevAttrMemoryPoolSupportedHandleTypes: Bitmask of handle types supported with mempool based IPC musaDevAttrDeferredMappingMusaArraySupported: 1 if the device supports deferred mapping MUSA arrays and MUSA mipmapped arrays. musaDevAttrIpcEventSupport: 1 if the device supports IPC Events. musaDevAttrNumaConfig: NUMA configuration of a device: value is of type musaDeviceNumaConfig enum musaDevAttrNumaId: NUMA node ID of the GPU memory musaDevAttrGpuPciDeviceId: The combined 16-bit PCI device ID and 16-bit PCI vendor ID. musaDevAttrGpuPciSubsystemId: The combined 16-bit PCI subsystem ID and 16-bit PCI vendor subsystem ID. value - Returned device attribute value attr - Device attribute to query device - Device number to query musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaGetDeviceProperties, musaInitDevice, muDeviceGetAttribute

Parameters:

  • int * value: - Returned device attribute value
  • enum musaDeviceAttr attr: - Device attribute to query
  • int device: - Device number to query

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue

See also:

musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaGetDeviceProperties, musaInitDevice, muDeviceGetAttribute

musaGetExportTable

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetExportTable(const void **ppExportTable, const musaUUID_t *pExportTableId)

Gets a Runtime export table.

ppExportTable Returned export-table pointer. pExportTableId Export-table identifier. musaSuccess or a Runtime error code.

Parameters:

  • const void ** ppExportTable: Returned export-table pointer.
  • const musaUUID_t * pExportTableId: Export-table identifier.

Returns:

musaSuccess or a Runtime error code.

musaGetDriverEntryPoint

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetDriverEntryPoint(const char *symbol, void **funcPtr, unsigned long long flags, enum musaDriverEntryPointQueryResult *driverStatus)

Returns the requested driver API function pointer.

Returns in **funcPtr the address of the MUSA driver function for the requested flags. For a requested driver symbol, if the MUSA version in which the driver symbol was introduced is less than or equal to the MUSA runtime version, the API will return the function pointer to the corresponding versioned driver function. The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, musaTypedefs.h consists of function pointer typedefs for driver APIs defined in musa.h. The API will return musaSuccess and set the returned funcPtr if the requested driver function is valid and supported on the platform. The API will return musaSuccess and set the returned funcPtr to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the MUSA runtime version or if the driver symbol is invalid. It will also set the optional driverStatus to one of the values in musaDriverEntryPointQueryResult with the following meanings: musaDriverEntryPointSuccess - The requested symbol was succesfully found based on input arguments and pfn is valid musaDriverEntryPointSymbolNotFound - The requested symbol was not found musaDriverEntryPointVersionNotSufficent - The requested symbol was found but is not supported by the current runtime version (MUSART_VERSION) The requested flags can be: musaEnableDefault: This is the default mode. This is equivalent to musaEnablePerThreadDefaultStream if the code is compiled with default-stream per-thread compilation flag or the macro MUSA_API_PER_THREAD_DEFAULT_STREAM is defined; musaEnableLegacyStream otherwise. musaEnableLegacyStream: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. musaEnablePerThreadDefaultStream: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function. symbol - The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc. Note that the API will use the MUSA runtime version to return the address to the most recent ABI compatible driver symbol, muMemAlloc or muMemAlloc_v2. funcPtr - Location to return the function pointer to the requested driver function flags - Flags to specify search options. driverStatus - Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values. musaSuccess, musaErrorInvalidValue, musaErrorNotSupported muGetProcAddress

Parameters:

  • const char * symbol: - The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc. Note that the API will use the MUSA runtime version to return the address to the most recent ABI compatible driver symbol, muMemAlloc or muMemAlloc_v2.
  • void ** funcPtr: - Location to return the function pointer to the requested driver function
  • unsigned long long flags: - Flags to specify search options.
  • enum musaDriverEntryPointQueryResult * driverStatus: - Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values.

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

See also:

muGetProcAddress

musaGetDriverEntryPointByVersion

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetDriverEntryPointByVersion(const char *symbol, void **funcPtr, unsigned int musaVersion, unsigned long long flags, enum musaDriverEntryPointQueryResult *driverStatus)

Returns the requested driver API function pointer by MUSA version.

Returns in **funcPtr the address of the MUSA driver function for the requested flags and MUSA driver version. The MUSA version is specified as (1000 * major + 10 * minor), so MUSA 11.2 should be specified as 11020. For a requested driver symbol, if the specified MUSA version is greater than or equal to the MUSA version in which the driver symbol was introduced, this API will return the function pointer to the corresponding versioned function. The pointer returned by the API should be cast to a function pointer matching the requested driver function's definition in the API header file. The function pointer typedef can be picked up from the corresponding typedefs header file. For example, musaTypedefs.h consists of function pointer typedefs for driver APIs defined in musa.h. For the case where the MUSA version requested is greater than the MUSA Toolkit installed, there may not be an appropriate function pointer typedef in the corresponding header file and may need a custom typedef to match the driver function signature returned. This can be done by getting the typedefs from a later toolkit or creating appropriately matching custom function typedefs. The API will return musaSuccess and set the returned funcPtr if the requested driver function is valid and supported on the platform. The API will return musaSuccess and set the returned funcPtr to NULL if the requested driver function is not supported on the platform, no ABI compatible driver function exists for the requested version or if the driver symbol is invalid. It will also set the optional driverStatus to one of the values in musaDriverEntryPointQueryResult with the following meanings: musaDriverEntryPointSuccess - The requested symbol was succesfully found based on input arguments and pfn is valid musaDriverEntryPointSymbolNotFound - The requested symbol was not found musaDriverEntryPointVersionNotSufficent - The requested symbol was found but is not supported by the specified version musaVersion The requested flags can be: musaEnableDefault: This is the default mode. This is equivalent to musaEnablePerThreadDefaultStream if the code is compiled with default-stream per-thread compilation flag or the macro MUSA_API_PER_THREAD_DEFAULT_STREAM is defined; musaEnableLegacyStream otherwise. musaEnableLegacyStream: This will enable the search for all driver symbols that match the requested driver symbol name except the corresponding per-thread versions. musaEnablePerThreadDefaultStream: This will enable the search for all driver symbols that match the requested driver symbol name including the per-thread versions. If a per-thread version is not found, the API will return the legacy version of the driver function. symbol - The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc. funcPtr - Location to return the function pointer to the requested driver function musaVersion - The MUSA version to look for the requested driver symbol flags - Flags to specify search options. driverStatus - Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values. musaSuccess, musaErrorInvalidValue, musaErrorNotSupported muGetProcAddress

Parameters:

  • const char * symbol: - The base name of the driver API function to look for. As an example, for the driver API muMemAlloc_v2, symbol would be muMemAlloc.
  • void ** funcPtr: - Location to return the function pointer to the requested driver function
  • unsigned int musaVersion: - The MUSA version to look for the requested driver symbol
  • unsigned long long flags: - Flags to specify search options.
  • enum musaDriverEntryPointQueryResult * driverStatus: - Optional location to store the status of finding the symbol from the driver. See musaDriverEntryPointQueryResult for possible values.

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

See also:

muGetProcAddress

musaGetLastError

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaGetLastError(void)

Returns the last error from a runtime call.

Returns the last error that has been produced by any of the runtime calls in the same instance of the MUSA Runtime library in the host thread and resets it to musaSuccess. Note: Multiple instances of the MUSA Runtime library can be present in an application when using a library that statically links the MUSA Runtime. musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled musaPeekAtLastError, musaGetErrorName, musaGetErrorString, musaError

Returns:

musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled

See also:

musaPeekAtLastError, musaGetErrorName, musaGetErrorString, musaError

musaGetErrorName

Header: musa_runtime_api.h

__host__ __musart_builtin__ const char *MUSARTAPI musaGetErrorName(musaError_t error)

Returns the string representation of an error code enum name.

Returns a string containing the name of an error code in the enum. If the error code is not recognized, "unrecognized error code" is returned. error - Error code to convert to string char* pointer to a NULL-terminated string musaGetErrorString, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorName

Parameters:

  • musaError_t error: - Error code to convert to string

Returns:

char* pointer to a NULL-terminated string

See also:

musaGetErrorString, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorName

musaGetErrorString

Header: musa_runtime_api.h

__host__ __musart_builtin__ const char *MUSARTAPI musaGetErrorString(musaError_t error)

Returns the description string for an error code.

Returns the description string for an error code. If the error code is not recognized, "unrecognized error code" is returned. error - Error code to convert to string char* pointer to a NULL-terminated string musaGetErrorName, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorString

Parameters:

  • musaError_t error: - Error code to convert to string

Returns:

char* pointer to a NULL-terminated string

See also:

musaGetErrorName, musaGetLastError, musaPeekAtLastError, musaError, muGetErrorString

musaPeekAtLastError

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaPeekAtLastError(void)

Returns the last error from a runtime call.

Returns the last error that has been produced by any of the runtime calls in the same instance of the MUSA Runtime library in the host thread. This call does not reset the error to musaSuccess like musaGetLastError(). Note: Multiple instances of the MUSA Runtime library can be present in an application when using a library that statically links the MUSA Runtime. musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled musaGetLastError, musaGetErrorName, musaGetErrorString, musaError

Returns:

musaSuccess, musaErrorMissingConfiguration, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidSymbol, musaErrorUnmapBufferObjectFailed, musaErrorInvalidDevicePointer, musaErrorInvalidTexture, musaErrorInvalidTextureBinding, musaErrorInvalidChannelDescriptor, musaErrorInvalidMemcpyDirection, musaErrorInvalidFilterSetting, musaErrorInvalidNormSetting, musaErrorUnknown, musaErrorInvalidResourceHandle, musaErrorInsufficientDriver, musaErrorNoDevice, musaErrorSetOnActiveProcess, musaErrorStartupFailure, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled

See also:

musaGetLastError, musaGetErrorName, musaGetErrorString, musaError

musaEventCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaEventCreate(musaEvent_t *event)

Creates an event object.

Creates an event object for the current device using musaEventDefault. event - Newly created event musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure, musaErrorMemoryAllocation musaEventCreate (C++ API), musaEventCreateWithFlags, musaEventRecord, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, muEventCreate

Parameters:

  • musaEvent_t * event: - Newly created event

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure, musaErrorMemoryAllocation

See also:

musaEventCreate (C++ API), musaEventCreateWithFlags, musaEventRecord, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, muEventCreate

musaEventCreateWithFlags

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaEventCreateWithFlags(musaEvent_t *event, unsigned int flags)

Creates an event object with the specified flags.

Creates an event object for the current device with the specified flags. Valid flags include: musaEventDefault: Default event creation flag. musaEventBlockingSync: Specifies that event should use blocking synchronization. A host thread that uses musaEventSynchronize() to wait on an event created with this flag will block until the event actually completes. musaEventDisableTiming: Specifies that the created event does not need to record timing data. Events created with this flag specified and the musaEventBlockingSync flag not specified will provide the best performance when used with musaStreamWaitEvent() and musaEventQuery(). musaEventInterprocess: Specifies that the created event may be used as an interprocess event by musaIpcGetEventHandle(). musaEventInterprocess must be specified along with musaEventDisableTiming. event - Newly created event flags - Flags for new event musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure, musaErrorMemoryAllocation musaEventCreate (C API), musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, muEventCreate

Parameters:

  • musaEvent_t * event: - Newly created event
  • unsigned int flags: - Flags for new event

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure, musaErrorMemoryAllocation

See also:

musaEventCreate (C API), musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, muEventCreate

musaEventDestroy

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaEventDestroy(musaEvent_t event)

Destroys an event object.

Destroys the event specified by event. An event may be destroyed before it is complete (i.e., while musaEventQuery() would return musaErrorNotReady). In this case, the call does not block on completion of the event, and any associated resources will automatically be released asynchronously at completion. event - Event to destroy musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventRecord, musaEventElapsedTime, muEventDestroy

Parameters:

  • musaEvent_t event: - Event to destroy

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventRecord, musaEventElapsedTime, muEventDestroy

musaEventQuery

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaEventQuery(musaEvent_t event)

Queries an event's status.

Queries the status of all work currently captured by event. See musaEventRecord() for details on what is captured by an event. Returns musaSuccess if all captured work has been completed, or musaErrorNotReady if any captured work is incomplete. For the purposes of Unified Memory, a return value of musaSuccess is equivalent to having called musaEventSynchronize(). event - Event to query musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure musaEventCreate (C API), musaEventCreateWithFlags, musaEventRecord, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, muEventQuery

Parameters:

  • musaEvent_t event: - Event to query

Returns:

musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventRecord, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, muEventQuery

musaEventRecord

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaEventRecord(musaEvent_t event, musaStream_t stream __dv(0))

Records an event.

Captures in event the contents of stream at the time of this call. event and stream must be on the same MUSA context. Calls such as musaEventQuery() or musaStreamWaitEvent() will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case. musaEventRecord() can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as musaStreamWaitEvent() use the most recently captured state at the time of the API call, and are not affected by later calls to musaEventRecord(). Before the first call to musaEventRecord(), an event represents an empty set of work, so for example musaEventQuery() would return musaSuccess. event - Event to record stream - Stream in which to record event musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, musaEventRecordWithFlags, muEventRecord

Parameters:

  • musaEvent_t event: - Event to record
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, musaEventRecordWithFlags, muEventRecord

musaEventRecordWithFlags

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaEventRecordWithFlags(musaEvent_t event, musaStream_t stream __dv(0), unsigned int flags __dv(0))

Records an event.

Captures in event the contents of stream at the time of this call. event and stream must be on the same MUSA context. Calls such as musaEventQuery() or musaStreamWaitEvent() will then examine or wait for completion of the work that was captured. Uses of stream after this call do not modify event. See note on default stream behavior for what is captured in the default case. musaEventRecordWithFlags() can be called multiple times on the same event and will overwrite the previously captured state. Other APIs such as musaStreamWaitEvent() use the most recently captured state at the time of the API call, and are not affected by later calls to musaEventRecordWithFlags(). Before the first call to musaEventRecordWithFlags(), an event represents an empty set of work, so for example musaEventQuery() would return musaSuccess. flags include: musaEventRecordDefault: Default event creation flag. musaEventRecordExternal: Event is captured in the graph as an external event node when performing stream capture. event - Event to record stream - Stream in which to record event flags - for the operation(See above) musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, musaEventRecord, muEventRecord,

Parameters:

  • musaEvent_t event: - Event to record
  • musaStream_t stream __dv
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventElapsedTime, musaStreamWaitEvent, musaEventRecord, muEventRecord,

musaEventSynchronize

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaEventSynchronize(musaEvent_t event)

Waits for an event to complete.

Waits until the completion of all work currently captured in event. See musaEventRecord() for details on what is captured by an event. Waiting for an event that was created with the musaEventBlockingSync flag will cause the calling CPU thread to block until the event has been completed by the device. If the musaEventBlockingSync flag has not been set, then the CPU thread will busy-wait until the event has been completed by the device. event - Event to wait for musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure musaEventCreate (C API), musaEventCreateWithFlags, musaEventRecord, musaEventQuery, musaEventDestroy, musaEventElapsedTime, muEventSynchronize

Parameters:

  • musaEvent_t event: - Event to wait for

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventRecord, musaEventQuery, musaEventDestroy, musaEventElapsedTime, muEventSynchronize

musaEventElapsedTime

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaEventElapsedTime(float *ms, musaEvent_t start, musaEvent_t end)

Computes the elapsed time between events.

Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the musaEventRecord() operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way. If musaEventRecord() has not been called on either event, then musaErrorInvalidResourceHandle is returned. If musaEventRecord() has been called on both events but one or both of them has not yet been completed (that is, musaEventQuery() would return musaErrorNotReady on at least one of the events), musaErrorNotReady is returned. If either event was created with the musaEventDisableTiming flag, then this function will return musaErrorInvalidResourceHandle. ms - Time between start and end in ms start - Starting event end - Ending event musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, musaErrorUnknown musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventRecord, muEventElapsedTime

Parameters:

  • float * ms: - Time between start and end in ms
  • musaEvent_t start: - Starting event
  • musaEvent_t end: - Ending event

Returns:

musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, musaErrorUnknown

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventRecord, muEventElapsedTime

musaEventElapsedTime_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaEventElapsedTime_v2(float *ms, musaEvent_t start, musaEvent_t end)

Computes the elapsed time between events.

Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). Note this API is not guaranteed to return the latest errors for pending work. As such this API is intended to serve as a elapsed time calculation only and polling for completion on the events to be compared should be done with musaEventQuery instead. If either event was last recorded in a non-NULL stream, the resulting time may be greater than expected (even if both used the same stream handle). This happens because the musaEventRecord() operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events. Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way. If musaEventRecord() has not been called on either event, then musaErrorInvalidResourceHandle is returned. If musaEventRecord() has been called on both events but one or both of them has not yet been completed (that is, musaEventQuery() would return musaErrorNotReady on at least one of the events), musaErrorNotReady is returned. If either event was created with the musaEventDisableTiming flag, then this function will return musaErrorInvalidResourceHandle. ms - Time between start and end in ms start - Starting event end - Ending event musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, musaErrorUnknown musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventRecord, muEventElapsedTime

Parameters:

  • float * ms: - Time between start and end in ms
  • musaEvent_t start: - Starting event
  • musaEvent_t end: - Ending event

Returns:

musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorLaunchFailure, musaErrorUnknown

See also:

musaEventCreate (C API), musaEventCreateWithFlags, musaEventQuery, musaEventSynchronize, musaEventDestroy, musaEventRecord, muEventElapsedTime

musaIpcGetEventHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaIpcGetEventHandle(musaIpcEventHandle_t *handle, musaEvent_t event)

Gets an interprocess handle for a previously allocated event.

Takes as input a previously allocated event. This event must have been created with the musaEventInterprocess and musaEventDisableTiming flags set. This opaque handle may be copied into other processes and opened with musaIpcOpenEventHandle to allow efficient hardware synchronization between GPU work in different processes. After the event has been been opened in the importing process, musaEventRecord, musaEventSynchronize, musaStreamWaitEvent and musaEventQuery may be used in either process. Performing operations on the imported event after the exported event has been freed with musaEventDestroy will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport handle - Pointer to a user allocated musaIpcEventHandle in which to return the opaque event handle event - Event allocated with musaEventInterprocess and musaEventDisableTiming flags. musaSuccess, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetEventHandle

Parameters:

  • musaIpcEventHandle_t * handle: - Pointer to a user allocated musaIpcEventHandle in which to return the opaque event handle
  • musaEvent_t event: - Event allocated with musaEventInterprocess and musaEventDisableTiming flags.

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetEventHandle

musaIpcOpenEventHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaIpcOpenEventHandle(musaEvent_t *event, musaIpcEventHandle_t handle)

Opens an interprocess event handle for use in the current process.

Opens an interprocess event handle exported from another process with musaIpcGetEventHandle. This function returns a musaEvent_t that behaves like a locally created event with the musaEventDisableTiming flag specified. This event must be freed with musaEventDestroy. Performing operations on the imported event after the exported event has been freed with musaEventDestroy will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport event - Returns the imported event handle - Interprocess handle to open musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue, musaErrorDeviceUninitialized musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcGetEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcOpenEventHandle

Parameters:

  • musaEvent_t * event: - Returns the imported event
  • musaIpcEventHandle_t handle: - Interprocess handle to open

Returns:

musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue, musaErrorDeviceUninitialized

See also:

musaEventCreate, musaEventDestroy, musaEventSynchronize, musaEventQuery, musaStreamWaitEvent, musaIpcGetEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcOpenEventHandle

musaGraphicsMapResources

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsMapResources(int count, musaGraphicsResource_t *resources, musaStream_t stream __dv(0))

Map graphics resources for access by MUSA.

Maps the count graphics resources in resources for access by MUSA. The resources in resources may be accessed by MUSA until they are unmapped. The graphics API from which resources were registered should not access any resources while they are mapped by MUSA. If an application does so, the results are undefined. This function provides the synchronization guarantee that any graphics calls issued before musaGraphicsMapResources() will complete before any subsequent MUSA work issued in stream begins. If resources contains any duplicate entries then musaErrorInvalidResourceHandle is returned. If any of resources are presently mapped for access by MUSA then musaErrorUnknown is returned. count - Number of resources to map resources - Resources to map for MUSA stream - Stream for synchronization musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsResourceGetMappedPointer, musaGraphicsSubResourceGetMappedArray, musaGraphicsUnmapResources, muGraphicsMapResources

Parameters:

  • int count: - Number of resources to map
  • musaGraphicsResource_t * resources: - Resources to map for MUSA
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsResourceGetMappedPointer, musaGraphicsSubResourceGetMappedArray, musaGraphicsUnmapResources, muGraphicsMapResources

musaGraphicsResourceGetMappedPointer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsResourceGetMappedPointer(void **devPtr, size_t *size, musaGraphicsResource_t resource)

Get an device pointer through which to access a mapped graphics resource.

Returns in *devPtr a pointer through which the mapped graphics resource resource may be accessed. Returns in *size the size of the memory in bytes which may be accessed from that pointer. The value set in devPtr may change every time that resource is mapped. If resource is not a buffer then it cannot be accessed via a pointer and musaErrorUnknown is returned. If resource is not mapped then musaErrorUnknown is returned. devPtr - Returned pointer through which resource may be accessed size - Returned size of the buffer accessible starting at *devPtr resource - Mapped resource to access musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, muGraphicsResourceGetMappedPointer

Parameters:

  • void ** devPtr: - Returned pointer through which resource may be accessed
  • size_t * size: - Returned size of the buffer accessible starting at *devPtr
  • musaGraphicsResource_t resource: - Mapped resource to access

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, muGraphicsResourceGetMappedPointer

musaGraphicsResourceSetMapFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsResourceSetMapFlags(musaGraphicsResource_t resource, unsigned int flags)

Set usage flags for mapping a graphics resource.

Set flags for mapping the graphics resource resource. Changes to flags will take effect the next time resource is mapped. The flags argument may be any of the following: musaGraphicsMapFlagsNone: Specifies no hints about how resource will be used. It is therefore assumed that MUSA may read from or write to resource. musaGraphicsMapFlagsReadOnly: Specifies that MUSA will not write to resource. musaGraphicsMapFlagsWriteDiscard: Specifies MUSA will not read from resource and will write over the entire contents of resource, so none of the data previously stored in resource will be preserved. If resource is presently mapped for access by MUSA then musaErrorUnknown is returned. If flags is not one of the above values then musaErrorInvalidValue is returned. resource - Registered resource to set flags for flags - for resource mapping musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown, musaGraphicsMapResources, muGraphicsResourceSetMapFlags

Parameters:

  • musaGraphicsResource_t resource: - Registered resource to set flags for
  • unsigned int flags: - Parameters for resource mapping

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown,

See also:

musaGraphicsMapResources, muGraphicsResourceSetMapFlags

musaGraphicsUnmapResources

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsUnmapResources(int count, musaGraphicsResource_t *resources, musaStream_t stream __dv(0))

Unmap graphics resources.

Unmaps the count graphics resources in resources. Once unmapped, the resources in resources may not be accessed by MUSA until they are mapped again. This function provides the synchronization guarantee that any MUSA work issued in stream before musaGraphicsUnmapResources() will complete before any subsequently issued graphics work begins. If resources contains any duplicate entries then musaErrorInvalidResourceHandle is returned. If any of resources are not presently mapped for access by MUSA then musaErrorUnknown is returned. count - Number of resources to unmap resources - Resources to unmap stream - Stream for synchronization musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsMapResources, muGraphicsUnmapResources

Parameters:

  • int count: - Number of resources to unmap
  • musaGraphicsResource_t * resources: - Resources to unmap
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsMapResources, muGraphicsUnmapResources

musaGraphicsUnregisterResource

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsUnregisterResource(musaGraphicsResource_t resource)

Unregisters a graphics resource for access by MUSA.

Unregisters the graphics resource resource so it is not accessible by MUSA unless registered again. If resource is invalid then musaErrorInvalidResourceHandle is returned. resource - Resource to unregister musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsD3D9RegisterResource, musaGraphicsD3D10RegisterResource, musaGraphicsD3D11RegisterResource, musaGraphicsGLRegisterBuffer, musaGraphicsGLRegisterImage, muGraphicsUnregisterResource

Parameters:

  • musaGraphicsResource_t resource: - Resource to unregister

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsD3D9RegisterResource, musaGraphicsD3D10RegisterResource, musaGraphicsD3D11RegisterResource, musaGraphicsGLRegisterBuffer, musaGraphicsGLRegisterImage, muGraphicsUnregisterResource

musaGraphAddHostNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddHostNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaHostNodeParams *pNodeParams)

Creates a host execution node and adds it to a graph.

Creates a new CPU execution node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in pNodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will invoke the specified CPU function. Host nodes are not supported under MPS with pre-Volta GPUs. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pNodeParams - for the host node musaSuccess, musaErrorNotSupported, musaErrorInvalidValue musaGraphAddNode, musaLaunchHostFunc, musaGraphHostNodeGetParams, musaGraphHostNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaHostNodeParams * pNodeParams: - Parameters for the host node

Returns:

musaSuccess, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaGraphAddNode, musaLaunchHostFunc, musaGraphHostNodeGetParams, musaGraphHostNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddKernelNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddKernelNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaKernelNodeParams *pNodeParams)

Creates a kernel execution node and adds it to a graph.

Creates a new kernel execution node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in pNodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. The musaKernelNodeParams structure is defined as: struct musaKernelNodeParams { void* func; dim3 gridDim; dim3 blockDim; unsigned int sharedMemBytes; void **kernelParams; void **extra; }; When the graph is launched, the node will invoke kernel func on a (gridDim.x x gridDim.y x gridDim.z) grid of blocks. Each block contains (blockDim.x x blockDim.y x blockDim.z) threads. sharedMem sets the amount of dynamic shared memory that will be available to each thread block. Kernel parameters to func can be specified in one of two ways: 1) Kernel parameters can be specified via kernelParams. If the kernel has N parameters, then kernelParams needs to be an array of N pointers. Each pointer, from kernelParams [0] to kernelParams [N-1], points to the region of memory from which the actual parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel's image. 2) Kernel parameters can also be packaged by the application into a single buffer that is passed in via extra. This places the burden on the application of knowing each kernel parameter's size and alignment/padding within the buffer. The extra parameter exists to allow this function to take additional less commonly used arguments. extra specifies a list of names of extra settings and their corresponding values. Each extra setting name is immediately followed by the corresponding value. The list must be terminated with either NULL or MU_LAUNCH_PARAM_END. MU_LAUNCH_PARAM_END, which indicates the end of the extra array; MU_LAUNCH_PARAM_BUFFER_POINTER, which specifies that the next value in extra will be a pointer to a buffer containing all the kernel parameters for launching kernel func; MU_LAUNCH_PARAM_BUFFER_SIZE, which specifies that the next value in extra will be a pointer to a size_t containing the size of the buffer specified with MU_LAUNCH_PARAM_BUFFER_POINTER; The error musaErrorInvalidValue will be returned if kernel parameters are specified with both kernelParams and extra (i.e. both kernelParams and extra are non-NULL). The kernelParams or extra array, as well as the argument values it points to, are copied during this call. Kernels launched using graphs must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pNodeParams - for the GPU execution node musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction musaGraphAddNode, musaLaunchKernel, musaGraphKernelNodeGetParams, musaGraphKernelNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaKernelNodeParams * pNodeParams: - Parameters for the GPU execution node

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

See also:

musaGraphAddNode, musaLaunchKernel, musaGraphKernelNodeGetParams, musaGraphKernelNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddMemcpyNode1D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemcpyNode1D(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Creates a 1D memcpy node and adds it to a graph.

Creates a new 1D memcpy node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies dst - Destination memory address src - Source memory address count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue musaMemcpy, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParams1D, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • void * dst: - Destination memory address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemcpy, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParams1D, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

musaGraphAddMemcpyNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemcpyNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemcpy3DParms *pCopyParams)

Creates a memcpy node and adds it to a graph.

Creates a new memcpy node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will perform the memcpy described by pCopyParams. See musaMemcpy3D() for a description of the structure and its restrictions. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pCopyParams - for the memory copy musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaMemcpy3D, musaGraphAddMemcpyNodeToSymbol, musaGraphAddMemcpyNodeFromSymbol, musaGraphAddMemcpyNode1D, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemcpy3DParms * pCopyParams: - Parameters for the memory copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaMemcpy3D, musaGraphAddMemcpyNodeToSymbol, musaGraphAddMemcpyNodeFromSymbol, musaGraphAddMemcpyNode1D, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

musaGraphAddMemcpyNodeFromSymbol

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemcpyNodeFromSymbol(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dst, const void *symbol, size_t count, size_t offset, enum musaMemcpyKind kind)

Creates a memcpy node to copy from a symbol on the device and adds it to a graph.

Creates a new memcpy node to copy from symbol and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will copy count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies dst - Destination memory address symbol - Device symbol address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer musaSuccess, musaErrorInvalidValue musaMemcpyFromSymbol, musaGraphAddMemcpyNode, musaGraphAddMemcpyNodeToSymbol, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • void * dst: - Destination memory address
  • const void * symbol: - Device symbol address
  • size_t count: - Size in bytes to copy
  • size_t offset: - Offset from start of symbol in bytes
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemcpyFromSymbol, musaGraphAddMemcpyNode, musaGraphAddMemcpyNodeToSymbol, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

musaGraphAddMemcpyNodeToSymbol

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemcpyNodeToSymbol(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const void *symbol, const void *src, size_t count, size_t offset, enum musaMemcpyKind kind)

Creates a memcpy node to copy to a symbol on the device and adds it to a graph.

Creates a new memcpy node to copy to symbol and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Memcpy nodes have some additional restrictions with regards to managed memory, if the system contains at least one device which has a zero value for the device attribute musaDevAttrConcurrentManagedAccess. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies symbol - Device symbol address src - Source memory address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer musaSuccess, musaErrorInvalidValue musaMemcpyToSymbol, musaGraphAddMemcpyNode, musaGraphAddMemcpyNodeFromSymbol, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const void * symbol: - Device symbol address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • size_t offset: - Offset from start of symbol in bytes
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemcpyToSymbol, musaGraphAddMemcpyNode, musaGraphAddMemcpyNodeFromSymbol, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemsetNode

musaGraphAddMemsetNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemsetNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemsetParams *pMemsetParams)

Creates a memset node and adds it to a graph.

Creates a new memset node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. The element size must be 1, 2, or 4 bytes. When the graph is launched, the node will perform the memset described by pMemsetParams. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pMemsetParams - for the memory set musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaGraphAddNode, musaMemset2D, musaGraphMemsetNodeGetParams, musaGraphMemsetNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemsetParams * pMemsetParams: - Parameters for the memory set

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaGraphAddNode, musaMemset2D, musaGraphMemsetNodeGetParams, musaGraphMemsetNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode

musaGraphAddChildGraphNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddChildGraphNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaGraph_t childGraph)

Creates a child graph node and adds it to a graph.

Creates a new node which executes an embedded graph, and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. If hGraph contains allocation or free nodes, this call will return an error. The node executes an embedded child graph. The child graph is cloned in this call. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies childGraph - The graph to clone into this node musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphChildGraphNodeGetGraph, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphClone

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • musaGraph_t childGraph: - The graph to clone into this node

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphChildGraphNodeGetGraph, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphClone

musaGraphAddDependencies

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddDependencies(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, size_t numDependencies)

Adds dependency edges to a graph.

The number of dependencies to be added is defined by numDependencies Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph. If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an existing dependency will return an error. graph - Graph to which dependencies are added from - Array of nodes that provide the dependencies to - Array of dependent nodes numDependencies - Number of dependencies to be added musaSuccess, musaErrorInvalidValue musaGraphRemoveDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to which dependencies are added
  • const musaGraphNode_t * from: - Array of nodes that provide the dependencies
  • const musaGraphNode_t * to: - Array of dependent nodes
  • size_t numDependencies: - Number of dependencies to be added

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphRemoveDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphRemoveDependencies

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphRemoveDependencies(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, size_t numDependencies)

Removes dependency edges from a graph.

The number of pDependencies to be removed is defined by numDependencies. Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph. If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying a non-existing dependency will return an error. graph - Graph from which to remove dependencies from - Array of nodes that provide the dependencies to - Array of dependent nodes numDependencies - Number of dependencies to be removed musaSuccess, musaErrorInvalidValue musaGraphAddDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph from which to remove dependencies
  • const musaGraphNode_t * from: - Array of nodes that provide the dependencies
  • const musaGraphNode_t * to: - Array of dependent nodes
  • size_t numDependencies: - Number of dependencies to be removed

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphAddEmptyNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddEmptyNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies)

Creates an empty node and adds it to a graph.

Creates a new node which performs no operation, and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. An empty node performs no operation during execution, but can be used for transitive ordering. For example, a phased execution graph with 2 groups of n nodes with a barrier between them can be represented using an empty node and 2*n dependency edges, rather than no empty node and n^2 dependency edges. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddEventRecordNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddEventRecordNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaEvent_t event)

Creates an event record node and adds it to a graph.

Creates a new event record node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode. Each launch of the graph will record event to capture execution of the node's dependencies. These nodes may not be used in loops or conditionals. phGraphNode - Returns newly created node hGraph - Graph to which to add the node dependencies - Dependencies of the node numDependencies - Number of dependencies event - Event for the node musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphAddEventWaitNode, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode
  • musaGraph_t graph
  • const musaGraphNode_t * pDependencies
  • size_t numDependencies: - Number of dependencies
  • musaEvent_t event: - Event for the node

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphAddEventWaitNode, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddEventWaitNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddEventWaitNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, musaEvent_t event)

Creates an event wait node and adds it to a graph.

Creates a new event wait node and adds it to hGraph with numDependencies dependencies specified via dependencies and event specified in event. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in phGraphNode. The graph node will wait for all work captured in event. See muEventRecord() for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. event may be from a different context or device than the launch stream. These nodes may not be used in loops or conditionals. phGraphNode - Returns newly created node hGraph - Graph to which to add the node dependencies - Dependencies of the node numDependencies - Number of dependencies event - Event for the node musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphAddEventRecordNode, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode
  • musaGraph_t graph
  • const musaGraphNode_t * pDependencies
  • size_t numDependencies: - Number of dependencies
  • musaEvent_t event: - Event for the node

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphAddEventRecordNode, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddMemAllocNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemAllocNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, struct musaMemAllocNodeParams *nodeParams)

Creates an allocation node and adds it to a graph.

Creates a new allocation node and adds it to graph with numDependencies dependencies specified via pDependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies nodeParams - for the node When musaGraphAddMemAllocNode creates an allocation node, it returns the address of the allocation in nodeParams.dptr. The allocation's address remains fixed across instantiations and launches. If the allocation is freed in the same graph, by creating a free node using musaGraphAddMemFreeNode, the allocation can be accessed by nodes ordered after the allocation node but before the free node. These allocations cannot be freed outside the owning graph, and they can only be freed once in the owning graph. If the allocation is not freed in the same graph, then it can be accessed not only by nodes in the graph which are ordered after the allocation node, but also by stream operations ordered after the graph's execution but before the allocation is freed. Allocations which are not freed in the same graph can be freed by: passing the allocation to musaMemFreeAsync or musaMemFree; launching a graph with a free node for that allocation; or specifying musaGraphInstantiateFlagAutoFreeOnLaunch during instantiation, which makes each launch behave as though it called musaMemFreeAsync for every unfreed allocation. It is not possible to free an allocation in both the owning graph and another graph. If the allocation is freed in the same graph, a free node cannot be added to another graph. If the allocation is freed in another graph, a free node can no longer be added to the owning graph. The following restrictions apply to graphs which contain allocation and/or memory free nodes: Nodes and edges of the graph cannot be deleted. The graph cannot be used in a child node. Only one instantiation of the graph may exist at any point in time. The graph cannot be cloned. musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory musaGraphAddNode, musaGraphAddMemFreeNode, musaGraphMemAllocNodeGetParams, musaDeviceGraphMemTrim, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddExternalSemaphoresSignalNode, musaGraphAddExternalSemaphoresWaitNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • struct musaMemAllocNodeParams * nodeParams: - Parameters for the node

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory

See also:

musaGraphAddNode, musaGraphAddMemFreeNode, musaGraphMemAllocNodeGetParams, musaDeviceGraphMemTrim, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddExternalSemaphoresSignalNode, musaGraphAddExternalSemaphoresWaitNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphAddMemFreeNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemFreeNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, void *dptr)

Creates a memory free node and adds it to a graph.

Creates a new memory free node and adds it to graph with numDependencies dependencies specified via pDependencies and address specified in dptr. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies dptr - Address of memory to free musaGraphAddMemFreeNode will return musaErrorInvalidValue if the user attempts to free: an allocation twice in the same graph. an address that was not returned by an allocation node. an invalid address. The following restrictions apply to graphs which contain allocation and/or memory free nodes: Nodes and edges of the graph cannot be deleted. The graph cannot be used in a child node. Only one instantiation of the graph may exist at any point in time. The graph cannot be cloned. musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory musaGraphAddNode, musaGraphAddMemAllocNode, musaGraphMemFreeNodeGetParams, musaDeviceGraphMemTrim, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddExternalSemaphoresSignalNode, musaGraphAddExternalSemaphoresWaitNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • void * dptr: - Address of memory to free

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorNotSupported, musaErrorInvalidValue, musaErrorOutOfMemory

See also:

musaGraphAddNode, musaGraphAddMemAllocNode, musaGraphMemFreeNodeGetParams, musaDeviceGraphMemTrim, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddExternalSemaphoresSignalNode, musaGraphAddExternalSemaphoresWaitNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphClone

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphClone(musaGraph_t *pGraphClone, musaGraph_t originalGraph)

Clones a graph.

This function creates a copy of originalGraph and returns it in pGraphClone. All parameters are copied into the cloned graph. The original graph may be modified after this call without affecting the clone. Child graph nodes in the original graph are recursively copied into the clone. pGraphClone - Returns newly created cloned graph originalGraph - Graph to clone musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaGraphCreate, musaGraphNodeFindInClone

Parameters:

  • musaGraph_t * pGraphClone: - Returns newly created cloned graph
  • musaGraph_t originalGraph: - Graph to clone

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaGraphCreate, musaGraphNodeFindInClone

musaGraphCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphCreate(musaGraph_t *pGraph, unsigned int flags)

Creates a graph.

Creates an empty graph, which is returned via pGraph. pGraph - Returns newly created graph flags - Graph creation flags, must be 0 musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphInstantiate, musaGraphDestroy, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphClone

Parameters:

  • musaGraph_t * pGraph: - Returns newly created graph
  • unsigned int flags: - Graph creation flags, must be 0

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphInstantiate, musaGraphDestroy, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphClone

musaGraphDestroy

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphDestroy(musaGraph_t graph)

Destroys a graph.

Destroys the graph specified by graph, as well as all of its nodes. graph - Graph to destroy musaSuccess, musaErrorInvalidValue musaGraphCreate

Parameters:

  • musaGraph_t graph: - Graph to destroy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphCreate

musaGraphDestroyNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphDestroyNode(musaGraphNode_t node)

Remove a node from the graph.

Removes node from its graph. This operation also severs any dependencies of other nodes on node and vice versa. Dependencies cannot be removed from graphs which contain allocation or free nodes. Any attempt to do so will return an error. node - Node to remove musaSuccess, musaErrorInvalidValue musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t node: - Node to remove

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphEventRecordNodeGetEvent

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphEventRecordNodeGetEvent(musaGraphNode_t node, musaEvent_t *event_out)

Returns the event associated with an event record node.

Returns the event of event record node hNode in event_out. hNode - Node to get the event for event_out - Pointer to return the event musaSuccess, musaErrorInvalidValue musaGraphAddEventRecordNode, musaGraphEventRecordNodeSetEvent, musaGraphEventWaitNodeGetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

Parameters:

  • musaGraphNode_t node
  • musaEvent_t * event_out: - Pointer to return the event

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddEventRecordNode, musaGraphEventRecordNodeSetEvent, musaGraphEventWaitNodeGetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

musaGraphEventRecordNodeSetEvent

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphEventRecordNodeSetEvent(musaGraphNode_t node, musaEvent_t event)

Sets an event record node's event.

Sets the event of event record node hNode to event. hNode - Node to set the event for event - Event to use musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaGraphAddEventRecordNode, musaGraphEventRecordNodeGetEvent, musaGraphEventWaitNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

Parameters:

  • musaGraphNode_t node
  • musaEvent_t event: - Event to use

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaGraphAddEventRecordNode, musaGraphEventRecordNodeGetEvent, musaGraphEventWaitNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

musaGraphEventWaitNodeGetEvent

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphEventWaitNodeGetEvent(musaGraphNode_t node, musaEvent_t *event_out)

Returns the event associated with an event wait node.

Returns the event of event wait node hNode in event_out. hNode - Node to get the event for event_out - Pointer to return the event musaSuccess, musaErrorInvalidValue musaGraphAddEventWaitNode, musaGraphEventWaitNodeSetEvent, musaGraphEventRecordNodeGetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

Parameters:

  • musaGraphNode_t node
  • musaEvent_t * event_out: - Pointer to return the event

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddEventWaitNode, musaGraphEventWaitNodeSetEvent, musaGraphEventRecordNodeGetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

musaGraphEventWaitNodeSetEvent

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphEventWaitNodeSetEvent(musaGraphNode_t node, musaEvent_t event)

Sets an event wait node's event.

Sets the event of event wait node hNode to event. hNode - Node to set the event for event - Event to use musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaGraphAddEventWaitNode, musaGraphEventWaitNodeGetEvent, musaGraphEventRecordNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

Parameters:

  • musaGraphNode_t node
  • musaEvent_t event: - Event to use

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaGraphAddEventWaitNode, musaGraphEventWaitNodeGetEvent, musaGraphEventRecordNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent

musaGraphExecDestroy

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecDestroy(musaGraphExec_t graphExec)

Destroys an executable graph.

Destroys the executable graph specified by graphExec. graphExec - Executable graph to destroy musaSuccess, musaErrorInvalidValue musaGraphInstantiate, musaGraphUpload, musaGraphLaunch

Parameters:

  • musaGraphExec_t graphExec: - Executable graph to destroy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphInstantiate, musaGraphUpload, musaGraphLaunch

musaGraphGetNodes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphGetNodes(musaGraph_t graph, musaGraphNode_t *nodes, size_t *numNodes)

Returns a graph's nodes.

Returns a list of graph's nodes. nodes may be NULL, in which case this function will return the number of nodes in numNodes. Otherwise, numNodes entries will be filled in. If numNodes is higher than the actual number of nodes, the remaining entries in nodes will be set to NULL, and the number of nodes actually obtained will be returned in numNodes. graph - Graph to query nodes - Pointer to return the nodes numNodes - See description musaSuccess, musaErrorInvalidValue musaGraphCreate, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphNodeGetType, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to query
  • musaGraphNode_t * nodes: - Pointer to return the nodes
  • size_t * numNodes: - See description

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphCreate, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphNodeGetType, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphGetRootNodes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphGetRootNodes(musaGraph_t graph, musaGraphNode_t *pRootNodes, size_t *pNumRootNodes)

Returns a graph's root nodes.

Returns a list of graph's root nodes. pRootNodes may be NULL, in which case this function will return the number of root nodes in pNumRootNodes. Otherwise, pNumRootNodes entries will be filled in. If pNumRootNodes is higher than the actual number of root nodes, the remaining entries in pRootNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumRootNodes. graph - Graph to query pRootNodes - Pointer to return the root nodes pNumRootNodes - See description musaSuccess, musaErrorInvalidValue musaGraphCreate, musaGraphGetNodes, musaGraphGetEdges, musaGraphNodeGetType, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to query
  • musaGraphNode_t * pRootNodes: - Pointer to return the root nodes
  • size_t * pNumRootNodes: - See description

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphCreate, musaGraphGetNodes, musaGraphGetEdges, musaGraphNodeGetType, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphNodeGetDependencies

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeGetDependencies(musaGraphNode_t node, musaGraphNode_t *pDependencies, size_t *pNumDependencies)

Returns a node's dependencies.

Returns a list of node's dependencies. pDependencies may be NULL, in which case this function will return the number of dependencies in pNumDependencies. Otherwise, pNumDependencies entries will be filled in. If pNumDependencies is higher than the actual number of dependencies, the remaining entries in pDependencies will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependencies. node - Node to query pDependencies - Pointer to return the dependencies pNumDependencies - See description musaSuccess, musaErrorInvalidValue musaGraphNodeGetDependentNodes, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

Parameters:

  • musaGraphNode_t node: - Node to query
  • musaGraphNode_t * pDependencies: - Pointer to return the dependencies
  • size_t * pNumDependencies: - See description

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeGetDependentNodes, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

musaGraphGetEdges

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphGetEdges(musaGraph_t graph, musaGraphNode_t *from, musaGraphNode_t *to, size_t *numEdges)

Returns a graph's dependency edges.

Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from and to; that is, the node in to [i] has a dependency on the node in from [i]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. graph - Graph to get the edges from from - Location to return edge endpoints to - Location to return edge endpoints numEdges - See description musaSuccess, musaErrorInvalidValue musaGraphGetNodes, musaGraphGetRootNodes, musaGraphAddDependencies, musaGraphRemoveDependencies, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to get the edges from
  • musaGraphNode_t * from: - Location to return edge endpoints
  • musaGraphNode_t * to: - Location to return edge endpoints
  • size_t * numEdges: - See description

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphGetNodes, musaGraphGetRootNodes, musaGraphAddDependencies, musaGraphRemoveDependencies, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphNodeGetDependentNodes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeGetDependentNodes(musaGraphNode_t node, musaGraphNode_t *pDependentNodes, size_t *pNumDependentNodes)

Returns a node's dependent nodes.

Returns a list of node's dependent nodes. pDependentNodes may be NULL, in which case this function will return the number of dependent nodes in pNumDependentNodes. Otherwise, pNumDependentNodes entries will be filled in. If pNumDependentNodes is higher than the actual number of dependent nodes, the remaining entries in pDependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependentNodes. node - Node to query pDependentNodes - Pointer to return the dependent nodes pNumDependentNodes - See description musaSuccess, musaErrorInvalidValue musaGraphNodeGetDependencies, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

Parameters:

  • musaGraphNode_t node: - Node to query
  • musaGraphNode_t * pDependentNodes: - Pointer to return the dependent nodes
  • size_t * pNumDependentNodes: - See description

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeGetDependencies, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

musaGraphHostNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphHostNodeGetParams(musaGraphNode_t node, struct musaHostNodeParams *pNodeParams)

Returns a host node's parameters.

Returns the parameters of host node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaLaunchHostFunc, musaGraphAddHostNode, musaGraphHostNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaHostNodeParams * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaLaunchHostFunc, musaGraphAddHostNode, musaGraphHostNodeSetParams

musaGraphHostNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphHostNodeSetParams(musaGraphNode_t node, const struct musaHostNodeParams *pNodeParams)

Sets a host node's parameters.

Sets the parameters of host node node to nodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaLaunchHostFunc, musaGraphAddHostNode, musaGraphHostNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaHostNodeParams * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaLaunchHostFunc, musaGraphAddHostNode, musaGraphHostNodeGetParams

musaGraphInstantiate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphInstantiate(musaGraphExec_t *pGraphExec, musaGraph_t graph, unsigned long long flags __dv(0))

Creates an executable graph from a graph.

Instantiates graph as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec. The flags parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are: musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs: The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. If graph is not instantiated for launch on the device but contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error. pGraphExec - Returns instantiated graph graph - Graph to instantiate flags - Flags to control instantiation. See CUgraphInstantiate_flags. musaSuccess, musaErrorInvalidValue musaGraphInstantiateWithFlags, musaGraphCreate, musaGraphUpload, musaGraphLaunch, musaGraphExecDestroy

Parameters:

  • musaGraphExec_t * pGraphExec: - Returns instantiated graph
  • musaGraph_t graph: - Graph to instantiate
  • unsigned long long flags __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphInstantiateWithFlags, musaGraphCreate, musaGraphUpload, musaGraphLaunch, musaGraphExecDestroy

musaGraphInstantiateWithFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphInstantiateWithFlags(musaGraphExec_t *pGraphExec, musaGraph_t graph, unsigned long long flags __dv(0))

Creates an executable graph from a graph.

Instantiates graph as an executable graph. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec. The flags parameter controls the behavior of instantiation and subsequent graph launches. Valid flags are: musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes. If graph contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs: The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. pGraphExec - Returns instantiated graph graph - Graph to instantiate flags - Flags to control instantiation. See CUgraphInstantiate_flags. musaSuccess, musaErrorInvalidValue musaGraphInstantiate, musaGraphCreate, musaGraphUpload, musaGraphLaunch, musaGraphExecDestroy

Parameters:

  • musaGraphExec_t * pGraphExec: - Returns instantiated graph
  • musaGraph_t graph: - Graph to instantiate
  • unsigned long long flags __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphInstantiate, musaGraphCreate, musaGraphUpload, musaGraphLaunch, musaGraphExecDestroy

musaGraphExecGetFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecGetFlags(musaGraphExec_t graphExec, unsigned long long *flags)

Query the instantiation flags of an executable graph.

Returns the flags that were passed to instantiation for the given executable graph. musaGraphInstantiateFlagUpload will not be returned by this API as it does not affect the resulting executable graph. graphExec - The executable graph to query flags - Returns the instantiation flags musaSuccess, musaErrorInvalidValue musaGraphInstantiate, musaGraphInstantiateWithFlags, musaGraphInstantiateWithParams

Parameters:

  • musaGraphExec_t graphExec: - The executable graph to query
  • unsigned long long * flags: - Returns the instantiation flags

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphInstantiate, musaGraphInstantiateWithFlags, musaGraphInstantiateWithParams

musaGraphKernelNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphKernelNodeGetParams(musaGraphNode_t node, struct musaKernelNodeParams *pNodeParams)

Returns a kernel node's parameters.

Returns the parameters of kernel node node in pNodeParams. The kernelParams or extra array returned in pNodeParams, as well as the argument values it points to, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphKernelNodeSetParams to update the parameters of this node. The params will contain either kernelParams or extra, according to which of these was most recently set on the node. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction musaLaunchKernel, musaGraphAddKernelNode, musaGraphKernelNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaKernelNodeParams * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

See also:

musaLaunchKernel, musaGraphAddKernelNode, musaGraphKernelNodeSetParams

musaGraphKernelNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphKernelNodeSetParams(musaGraphNode_t node, const struct musaKernelNodeParams *pNodeParams)

Sets a kernel node's parameters.

Sets the parameters of kernel node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation musaGraphNodeSetParams, musaLaunchKernel, musaGraphAddKernelNode, musaGraphKernelNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaKernelNodeParams * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorMemoryAllocation

See also:

musaGraphNodeSetParams, musaLaunchKernel, musaGraphAddKernelNode, musaGraphKernelNodeGetParams

musaGraphKernelNodeSetAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphKernelNodeSetAttribute(musaGraphNode_t hNode, enum musaKernelNodeAttrID attr, const union musaKernelNodeAttrValue *value)

Sets node attribute.

Sets attribute attr on node hNode from corresponding attribute of value. hNode attr value musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaAccessPolicyWindow

Parameters:

  • musaGraphNode_t hNode
  • enum musaKernelNodeAttrID attr
  • const union musaKernelNodeAttrValue * value

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaAccessPolicyWindow

musaGraphKernelNodeGetAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphKernelNodeGetAttribute(musaGraphNode_t hNode, enum musaKernelNodeAttrID attr, union musaKernelNodeAttrValue *value_out)

Queries node attribute.

Queries attribute attr from node hNode and stores it in corresponding member of value_out. hNode attr value_out musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaAccessPolicyWindow

Parameters:

  • musaGraphNode_t hNode
  • enum musaKernelNodeAttrID attr
  • union musaKernelNodeAttrValue * value_out

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaAccessPolicyWindow

musaGraphKernelNodeCopyAttributes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphKernelNodeCopyAttributes(musaGraphNode_t hSrc, musaGraphNode_t hDst)

Copies attributes from source node to destination node.

Copies attributes from source node src to destination node dst. Both node must have the same context. dst Destination node src Source node For list of attributes see musaKernelNodeAttrID musaSuccess, musaErrorInvalidContext musaAccessPolicyWindow

Parameters:

  • musaGraphNode_t hSrc
  • musaGraphNode_t hDst

Returns:

musaSuccess, musaErrorInvalidContext

See also:

musaAccessPolicyWindow

musaGraphLaunch

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphLaunch(musaGraphExec_t graphExec, musaStream_t stream)

Launches an executable graph in a stream.

Executes graphExec in stream. Only one instance of graphExec may be executing at a time. Each launch is ordered behind both any previous work in stream and any previous launches of graphExec. To execute a graph concurrently, it must be instantiated multiple times into multiple executable graphs. If any allocations created by graphExec remain unfreed (from a previous launch) and graphExec was not instantiated with musaGraphInstantiateFlagAutoFreeOnLaunch, the launch will fail with musaErrorInvalidValue. graphExec - Executable graph to launch stream - Stream in which to launch the graph musaSuccess, musaErrorInvalidValue musaGraphInstantiate, musaGraphUpload, musaGraphExecDestroy

Parameters:

  • musaGraphExec_t graphExec: - Executable graph to launch
  • musaStream_t stream: - Stream in which to launch the graph

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphInstantiate, musaGraphUpload, musaGraphExecDestroy

musaGraphUpload

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphUpload(musaGraphExec_t graphExec, musaStream_t stream)

Uploads an executable graph in a stream.

Uploads hGraphExec to the device in hStream without executing it. Uploads of the same hGraphExec will be serialized. Each upload is ordered behind both any previous work in hStream and any previous launches of hGraphExec. Uses memory cached by stream to back the allocations owned by graphExec. hGraphExec - Executable graph to upload hStream - Stream in which to upload the graph musaSuccess, musaErrorInvalidValue, musaGraphInstantiate, musaGraphLaunch, musaGraphExecDestroy

Parameters:

  • musaGraphExec_t graphExec
  • musaStream_t stream

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphInstantiate, musaGraphLaunch, musaGraphExecDestroy

musaGraphMemcpyNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemcpyNodeGetParams(musaGraphNode_t node, struct musaMemcpy3DParms *pNodeParams)

Returns a memcpy node's parameters.

Returns the parameters of memcpy node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaMemcpy3D, musaGraphAddMemcpyNode, musaGraphMemcpyNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemcpy3DParms * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemcpy3D, musaGraphAddMemcpyNode, musaGraphMemcpyNodeSetParams

musaGraphMemcpyNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemcpyNodeSetParams(musaGraphNode_t node, const struct musaMemcpy3DParms *pNodeParams)

Sets a memcpy node's parameters.

Sets the parameters of memcpy node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue, musaGraphNodeSetParams, musaMemcpy3D, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphMemcpyNodeSetParams1D, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemcpy3DParms * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphNodeSetParams, musaMemcpy3D, musaGraphMemcpyNodeSetParamsToSymbol, musaGraphMemcpyNodeSetParamsFromSymbol, musaGraphMemcpyNodeSetParams1D, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams

musaGraphMemcpyNodeSetParams1D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemcpyNodeSetParams1D(musaGraphNode_t node, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Sets a memcpy node's parameters to perform a 1-dimensional copy.

Sets the parameters of memcpy node node to the copy described by the provided parameters. When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Launching a memcpy node with dst and src pointers that do not match the direction of the copy results in an undefined behavior. node - Node to set the parameters for dst - Destination memory address src - Source memory address count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue musaMemcpy, musaGraphMemcpyNodeSetParams, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • void * dst: - Destination memory address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemcpy, musaGraphMemcpyNodeSetParams, musaGraphAddMemcpyNode, musaGraphMemcpyNodeGetParams

musaGraphMemsetNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemsetNodeGetParams(musaGraphNode_t node, struct musaMemsetParams *pNodeParams)

Returns a memset node's parameters.

Returns the parameters of memset node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaMemset2D, musaGraphAddMemsetNode, musaGraphMemsetNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemsetParams * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemset2D, musaGraphAddMemsetNode, musaGraphMemsetNodeSetParams

musaGraphMemsetNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemsetNodeSetParams(musaGraphNode_t node, const struct musaMemsetParams *pNodeParams)

Sets a memset node's parameters.

Sets the parameters of memset node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaMemset2D, musaGraphAddMemsetNode, musaGraphMemsetNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemsetParams * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaMemset2D, musaGraphAddMemsetNode, musaGraphMemsetNodeGetParams

musaGraphNodeFindInClone

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeFindInClone(musaGraphNode_t *pNode, musaGraphNode_t originalNode, musaGraph_t clonedGraph)

Finds a cloned version of a node.

This function returns the node in clonedGraph corresponding to originalNode in the original graph. clonedGraph must have been cloned from originalGraph via musaGraphClone. originalNode must have been in originalGraph at the time of the call to musaGraphClone, and the corresponding cloned node in clonedGraph must not have been removed. The cloned node is then returned via pClonedNode. pNode - Returns handle to the cloned node originalNode - Handle to the original node clonedGraph - Cloned graph to query musaSuccess, musaErrorInvalidValue musaGraphClone

Parameters:

  • musaGraphNode_t * pNode: - Returns handle to the cloned node
  • musaGraphNode_t originalNode: - Handle to the original node
  • musaGraph_t clonedGraph: - Cloned graph to query

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphClone

musaGraphNodeGetType

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeGetType(musaGraphNode_t node, enum musaGraphNodeType *pType)

Returns a node's type.

Returns the node type of node in pType. node - Node to query pType - Pointer to return the node type musaSuccess, musaErrorInvalidValue musaGraphGetNodes, musaGraphGetRootNodes, musaGraphChildGraphNodeGetGraph, musaGraphKernelNodeGetParams, musaGraphKernelNodeSetParams, musaGraphHostNodeGetParams, musaGraphHostNodeSetParams, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemsetNodeGetParams, musaGraphMemsetNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to query
  • enum musaGraphNodeType * pType: - Pointer to return the node type

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphGetNodes, musaGraphGetRootNodes, musaGraphChildGraphNodeGetGraph, musaGraphKernelNodeGetParams, musaGraphKernelNodeSetParams, musaGraphHostNodeGetParams, musaGraphHostNodeSetParams, musaGraphMemcpyNodeGetParams, musaGraphMemcpyNodeSetParams, musaGraphMemsetNodeGetParams, musaGraphMemsetNodeSetParams

musaGraphExecUpdate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecUpdate(musaGraphExec_t hGraphExec, musaGraph_t hGraph, musaGraphExecUpdateResultInfo *resultInfo)

Check whether an executable graph can be updated with a graph and perform the update if possible.

Updates the node parameters in the instantiated graph specified by hGraphExec with the node parameters in a topologically identical graph specified by hGraph. Limitations: Kernel nodes: The owning context of the function cannot change. A node whose function originally did not use MUSA dynamic parallelism cannot be updated to a function which uses CDP. A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. A cooperative node cannot be updated to a non-cooperative node, and vice-versa. If the graph was instantiated with musaGraphInstantiateFlagUseNodePriority, the priority attribute cannot change. Equality is checked on the originally requested priority values, before they are clamped to the device's supported range. If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side musaGraphLaunch() cannot be updated to a function which uses device-side musaGraphLaunch() unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all. Neither hGraph nor hGraphExec may contain device-updatable kernel nodes. Memset and memcpy nodes: The MUSA device(s) to which the operand(s) was allocated/mapped cannot change. The source/destination memory must be allocated from the same contexts as the original source/destination memory. For 2d memsets, only address and assinged value may be updated. For 1d memsets, updating dimensions is also allowed, but may fail if the resulting operation doesn't map onto the work resources already allocated for the node. Additional memcpy node restrictions: Changing either the source or destination memory type(i.e. MU_MEMORYTYPE_DEVICE, MU_MEMORYTYPE_ARRAY, etc.) is not supported. Conditional nodes: Changing node parameters is not supported. Changeing parameters of nodes within the conditional body graph is subject to the rules above. Conditional handle flags and default values are updated as part of the graph update. Note: The API may add further restrictions in future releases. The return code should always be checked. musaGraphExecUpdate sets the result member of resultInfo to musaGraphExecUpdateErrorTopologyChanged under the following conditions: The count of nodes directly in hGraphExec and hGraph differ, in which case resultInfo->errorNode is set to NULL. hGraph has more exit nodes than hGraph, in which case resultInfo->errorNode is set to one of the exit nodes in hGraph. A node in hGraph has a different number of dependencies than the node from hGraphExec it is paired with, in which case resultInfo->errorNode is set to the node from hGraph. A node in hGraph has a dependency that does not match with the corresponding dependency of the paired node from hGraphExec. resultInfo->errorNode will be set to the node from hGraph. resultInfo->errorFromNode will be set to the mismatched dependency. The dependencies are paired based on edge order and a dependency does not match when the nodes are already paired based on other edges examined in the graph. musaGraphExecUpdate sets the result member of resultInfo to: musaGraphExecUpdateError if passed an invalid value. musaGraphExecUpdateErrorTopologyChanged if the graph topology changed musaGraphExecUpdateErrorNodeTypeChanged if the type of a node changed, in which case hErrorNode_out is set to the node from hGraph. musaGraphExecUpdateErrorFunctionChanged if the function of a kernel node changed (MUSA driver < 11.2) musaGraphExecUpdateErrorUnsupportedFunctionChange if the func field of a kernel changed in an unsupported way(see note above), in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorParametersChanged if any parameters to a node changed in a way that is not supported, in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorAttributesChanged if any attributes of a node changed in a way that is not supported, in which case hErrorNode_out is set to the node from hGraph musaGraphExecUpdateErrorNotSupported if something about a node is unsupported, like the node's type or configuration, in which case hErrorNode_out is set to the node from hGraph If the update fails for a reason not listed above, the result member of resultInfo will be set to musaGraphExecUpdateError. If the update succeeds, the result member will be set to musaGraphExecUpdateSuccess. musaGraphExecUpdate returns musaSuccess when the updated was performed successfully. It returns musaErrorGraphExecUpdateFailure if the graph update was not performed because it included changes which violated constraints specific to instantiated graph update. hGraphExec The instantiated graph to be updated hGraph The graph containing the updated parameters resultInfo the error info structure musaSuccess, musaErrorGraphExecUpdateFailure, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: The instantiated graph to be updated
  • musaGraph_t hGraph: The graph containing the updated parameters
  • musaGraphExecUpdateResultInfo * resultInfo: the error info structure

Returns:

musaSuccess, musaErrorGraphExecUpdateFailure,

See also:

musaGraphInstantiate

musaGraphExecKernelNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecKernelNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaKernelNodeParams *pNodeParams)

Sets the parameters for a kernel node in the given graphExec.

Sets the parameters of a kernel node in an executable graph hGraphExec. The node is identified by the corresponding node node in the non-executable graph, from which the executable graph was instantiated. node must not have been removed from the original graph. All nodeParams fields may change, but the following restrictions apply to func updates: The owning device of the function cannot change. A node whose function originally did not use MUSA dynamic parallelism cannot be updated to a function which uses CDP A node whose function originally did not make device-side update calls cannot be updated to a function which makes device-side update calls. If hGraphExec was not instantiated for device launch, a node whose function originally did not use device-side musaGraphLaunch() cannot be updated to a function which uses device-side musaGraphLaunch() unless the node resides on the same device as nodes which contained such calls at instantiate-time. If no such calls were present at instantiation, these updates cannot be performed at all. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. If node is a device-updatable kernel node, the next upload/launch of hGraphExec will overwrite any previous device-side updates. Additionally, applying host updates to a device-updatable kernel node while it is being updated from the device will result in undefined behavior. hGraphExec - The executable graph in which to set the specified node node - kernel node from the graph from which graphExec was instantiated pNodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddKernelNode, musaGraphKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - kernel node from the graph from which graphExec was instantiated
  • const struct musaKernelNodeParams * pNodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddKernelNode, musaGraphKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecMemcpyNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemcpyNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemcpy3DParms *pNodeParams)

Sets the parameters for a memcpy node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored. The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Both the instantiation-time memory operands and the memory operands in pNodeParams must be 1-dimensional. Zero-length operations are not supported. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. Returns musaErrorInvalidValue if the memory operands' mappings changed or either the original or new memory operands are multidimensional. hGraphExec - The executable graph in which to set the specified node node - Memcpy node from the graph which was used to instantiate graphExec pNodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddMemcpyNode, musaGraphMemcpyNodeSetParams, musaGraphExecMemcpyNodeSetParamsToSymbol, musaGraphExecMemcpyNodeSetParamsFromSymbol, musaGraphExecMemcpyNodeSetParams1D, musaGraphExecKernelNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memcpy node from the graph which was used to instantiate graphExec
  • const struct musaMemcpy3DParms * pNodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddMemcpyNode, musaGraphMemcpyNodeSetParams, musaGraphExecMemcpyNodeSetParamsToSymbol, musaGraphExecMemcpyNodeSetParamsFromSymbol, musaGraphExecMemcpyNodeSetParams1D, musaGraphExecKernelNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecMemcpyNodeSetParams1D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemcpyNodeSetParams1D(musaGraphExec_t hGraphExec, musaGraphNode_t node, void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Sets one-dimensional memcpy parameters for a memcpy node in the given graphExec.

Updates the work represented by node in hGraphExec using a one-dimensional memory copy. hGraphExec Executable graph in which to set the specified node. node Memcpy node from the graph used to instantiate hGraphExec. dst Destination memory address. src Source memory address. count Size in bytes to copy. kind Type of transfer. musaSuccess or musaErrorInvalidValue.

Parameters:

  • musaGraphExec_t hGraphExec: Executable graph in which to set the specified node.
  • musaGraphNode_t node: Memcpy node from the graph used to instantiate hGraphExec.
  • void * dst: Destination memory address.
  • const void * src: Source memory address.
  • size_t count: Size in bytes to copy.
  • enum musaMemcpyKind kind: Type of transfer.

Returns:

musaSuccess or musaErrorInvalidValue.

musaGraphExecMemsetNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemsetNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemsetParams *pNodeParams)

Sets the parameters for a memset node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored. Zero sized operations are not supported. The new destination pointer in pNodeParams must be to the same kind of allocation as the original destination pointer and have the same context association and device mapping as the original destination pointer. Both the value and pointer address may be updated. Changing other aspects of the memset (width, height, element size or pitch) may cause the update to be rejected. Specifically, for 2d memsets, all dimension changes are rejected. For 1d memsets, changes in height are explicitly rejected and other changes are oportunistically allowed if the resulting work maps onto the work resources already allocated for the node. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. hGraphExec - The executable graph in which to set the specified node node - Memset node from the graph which was used to instantiate graphExec pNodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddMemsetNode, musaGraphMemsetNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memset node from the graph which was used to instantiate graphExec
  • const struct musaMemsetParams * pNodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddMemsetNode, musaGraphMemsetNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecHostNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecHostNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaHostNodeParams *pNodeParams)

Sets the parameters for a host node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. hGraphExec - The executable graph in which to set the specified node node - Host node from the graph which was used to instantiate graphExec pNodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddHostNode, musaGraphHostNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Host node from the graph which was used to instantiate graphExec
  • const struct musaHostNodeParams * pNodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddHostNode, musaGraphHostNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphNodeSetEnabled

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeSetEnabled(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, unsigned int isEnabled)

Enables or disables the specified node in the given graphExec.

Sets hNode to be either enabled or disabled. Disabled nodes are functionally equivalent to empty nodes until they are reenabled. Existing node parameters are not affected by disabling/enabling the node. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated. hNode must not have been removed from the original graph. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call. Currently only kernel, memset and memcpy nodes are supported. hGraphExec - The executable graph in which to set the specified node hNode - Node from the graph from which graphExec was instantiated isEnabled - Node is enabled if != 0, otherwise the node is disabled musaSuccess, musaErrorInvalidValue, musaGraphNodeGetEnabled, musaGraphExecUpdate, musaGraphInstantiate musaGraphLaunch

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t hNode: - Node from the graph from which graphExec was instantiated
  • unsigned int isEnabled: - Node is enabled if != 0, otherwise the node is disabled

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphNodeGetEnabled, musaGraphExecUpdate, musaGraphInstantiate musaGraphLaunch

musaGraphNodeGetEnabled

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeGetEnabled(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, unsigned int *isEnabled)

Query whether a node in the given graphExec is enabled.

Sets isEnabled to 1 if hNode is enabled, or 0 if hNode is disabled. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated. hNode must not have been removed from the original graph. Currently only kernel, memset and memcpy nodes are supported. hGraphExec - The executable graph in which to set the specified node hNode - Node from the graph from which graphExec was instantiated isEnabled - Location to return the enabled status of the node musaSuccess, musaErrorInvalidValue, musaGraphNodeSetEnabled, musaGraphExecUpdate, musaGraphInstantiate musaGraphLaunch

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t hNode: - Node from the graph from which graphExec was instantiated
  • unsigned int * isEnabled: - Location to return the enabled status of the node

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphNodeSetEnabled, musaGraphExecUpdate, musaGraphInstantiate musaGraphLaunch

musaGraphAddMemAtomicNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemAtomicNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemAtomicParms *pMemAtomicParams)

Creates a memory atomic node and adds it to a graph.

Creates a new memory atomic node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will perform the memory atomic operation described by pMemAtomicParams. See musaMemoryAtomicAsync() for a description of the structure. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pMemAtomicParams - for the memory atomic musaSuccess, musaErrorInvalidValue, musaMemoryAtomicAsync, musaGraphMemAtomicNodeGetParams, musaGraphMemAtomicNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicValueNode, musaGraphAddMemWaitWriteNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemAtomicParms * pMemAtomicParams: - Parameters for the memory atomic

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemoryAtomicAsync, musaGraphMemAtomicNodeGetParams, musaGraphMemAtomicNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicValueNode, musaGraphAddMemWaitWriteNode

musaGraphAddMemAtomicValueNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemAtomicValueNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemAtomicValueParms *pMemAtomicValueParams)

Creates a memory atomic value node and adds it to a graph.

Creates a new memory atomic value node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will perform the memory atomic value operation described by pMemAtomicValueParams. See musaMemoryAtomicValueAsync() for a description of the structure. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pMemAtomicValueParams - for the memory atomic value musaSuccess, musaErrorInvalidValue, musaMemoryAtomicValueAsync, musaGraphMemAtomicValueNodeGetParams, musaGraphMemAtomicValueNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicNode, musaGraphAddMemWaitWriteNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemAtomicValueParms * pMemAtomicValueParams: - Parameters for the memory atomic value

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemoryAtomicValueAsync, musaGraphMemAtomicValueNodeGetParams, musaGraphMemAtomicValueNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicNode, musaGraphAddMemWaitWriteNode

musaGraphAddMemWaitWriteNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemWaitWriteNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemWaitWriteParms *pMemWaitWriteParams)

Creates a memory wait / write value node and adds it to a graph.

Creates a new memory wait / write value node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will perform the memory wait / write value described by pMemWaitWriteParams. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pMemWaitWriteParams - for the memory atomic value The musaMemWaitWriteParms structure is defined as: struct device_builtin musaMemWaitWriteParms { void* addr; size_t value; unsigned int flags; musaStreamBatchMemOpType operation; }; See musaStreamBatchMemOpType for the full set of supported operations, and muStreamWaitValue64() and muStreamWriteValue64() for details of specific operations. musaSuccess, musaErrorInvalidValue, muStreamWaitValue64, muStreamWriteValue64, musaGraphMemWaitWriteNodeGetParams, musaGraphMemWaitWriteNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicNode, musaGraphAddMemAtomicValueNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemWaitWriteParms * pMemWaitWriteParams: - Parameters for the memory atomic value

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muStreamWaitValue64, muStreamWriteValue64, musaGraphMemWaitWriteNodeGetParams, musaGraphMemWaitWriteNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode, musaGraphAddMemAtomicNode, musaGraphAddMemAtomicValueNode

musaGraphAddMemTransferNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddMemTransferNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaMemTransferParms *pMemTransferParams)

Creates a memory transfer node and adds it to a graph.

Creates a new memory transfer node and adds it to graph with numDependencies dependencies specified via pDependencies. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. pDependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. When the graph is launched, the node will copy count bytes from the memory area pointed to by src to the memory area pointed to by dst by transfer engine. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies pMemTransferParams - for the memory transfer musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaMemoryTransfer, musaGraphMemTransferNodeGetParams, musaGraphMemTransferNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaMemTransferParms * pMemTransferParams: - Parameters for the memory transfer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaMemoryTransfer, musaGraphMemTransferNodeGetParams, musaGraphMemTransferNodeSetParams, musaGraphCreate, musaGraphDestroyNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddHostNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphMemAtomicNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemAtomicNodeGetParams(musaGraphNode_t node, struct musaMemAtomicParms *pNodeParams)

Returns a memory atomic node's parameters.

Returns the parameters of memory atomic node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaMemoryAtomicAsync, musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemAtomicParms * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemoryAtomicAsync, musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeSetParams

musaGraphMemAtomicNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemAtomicNodeSetParams(musaGraphNode_t node, const struct musaMemAtomicParms *pNodeParams)

Sets a memory atomic node's parameters.

Sets the parameters of memory atomic node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue, musaMemoryAtomicAsync, musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemAtomicParms * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemoryAtomicAsync, musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeGetParams

musaGraphMemAtomicValueNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemAtomicValueNodeGetParams(musaGraphNode_t node, struct musaMemAtomicValueParms *pNodeParams)

Returns a memory atomic value node's parameters.

Returns the parameters of memory atomic value node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaMemoryAtomicValueAsync, musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemAtomicValueParms * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemoryAtomicValueAsync, musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeSetParams

musaGraphMemAtomicValueNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemAtomicValueNodeSetParams(musaGraphNode_t node, const struct musaMemAtomicValueParms *pNodeParams)

Sets a memory atomic value node's parameters.

Sets the parameters of memory atomic value node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue musaMemoryAtomicValueAsync, musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemAtomicValueParms * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemoryAtomicValueAsync, musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeGetParams

musaGraphMemWaitWriteNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemWaitWriteNodeGetParams(musaGraphNode_t node, struct musaMemWaitWriteParms *pNodeParams)

Returns a memory wait / write value node's parameters.

Returns the parameters of memory wait / write value node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue muStreamWaitValue64, muStreamWriteValue64, musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemWaitWriteParms * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muStreamWaitValue64, muStreamWriteValue64, musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeSetParams

musaGraphMemWaitWriteNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemWaitWriteNodeSetParams(musaGraphNode_t node, const struct musaMemWaitWriteParms *pNodeParams)

Sets a memory wait / write value node's parameters.

Sets the parameters of memory wait / write value node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue muStreamWaitValue64, muStreamWriteValue64, musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemWaitWriteParms * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muStreamWaitValue64, muStreamWriteValue64, musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeGetParams

musaGraphMemTransferNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemTransferNodeGetParams(musaGraphNode_t node, struct musaMemTransferParms *pNodeParams)

Returns a memory transfer node's parameters.

Returns the parameters of memory transfer node node in pNodeParams. node - Node to get the parameters for pNodeParams - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaMemoryTransfer, musaGraphAddMemTransferNode, musaGraphMemTransferNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to get the parameters for
  • struct musaMemTransferParms * pNodeParams: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemoryTransfer, musaGraphAddMemTransferNode, musaGraphMemTransferNodeSetParams

musaGraphMemTransferNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphMemTransferNodeSetParams(musaGraphNode_t node, const struct musaMemTransferParms *pNodeParams)

Sets a memory transfer node's parameters.

Sets the parameters of memory transfer node node to pNodeParams. node - Node to set the parameters for pNodeParams - to copy musaSuccess, musaErrorInvalidValue, musaGraphNodeSetParams, musaMemoryTransfer, musaGraphAddMemTransferNode, musaGraphMemTransferNodeGetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • const struct musaMemTransferParms * pNodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphNodeSetParams, musaMemoryTransfer, musaGraphAddMemTransferNode, musaGraphMemTransferNodeGetParams

musaGraphExecMemAtomicNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemAtomicNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemAtomicParms *pNodeParams)

Sets the parameters for a memory atomic node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored. The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Zero-length operations are not supported. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. hGraphExec - The executable graph in which to set the specified node node - Memory atomic node from the graph which was used to instantiate graphExec pNodeParams - The updated parameters to set musaSuccess, musaErrorInvalidValue, musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicValueNodeSetParams, musaGraphExecMemWaitWriteNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memory atomic node from the graph which was used to instantiate graphExec
  • const struct musaMemAtomicParms * pNodeParams: - The updated parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphAddMemAtomicNode, musaGraphMemAtomicNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicValueNodeSetParams, musaGraphExecMemWaitWriteNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecMemAtomicValueNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemAtomicValueNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemAtomicValueParms *pNodeParams)

Sets the parameters for a memory atomic value node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored. The destination memory in pNodeParams must be allocated from the same contexts as the original destination memory. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. hGraphExec - The executable graph in which to set the specified node node - Memory atomic value node from the graph which was used to instantiate graphExec pNodeParams - The updated parameters to set musaSuccess, musaErrorInvalidValue, musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicNodeSetParams, musaGraphExecMemWaitWriteNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memory atomic value node from the graph which was used to instantiate graphExec
  • const struct musaMemAtomicValueParms * pNodeParams: - The updated parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphAddMemAtomicValueNode, musaGraphMemAtomicValueNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicNodeSetParams, musaGraphExecMemWaitWriteNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecMemWaitWriteNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemWaitWriteNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemWaitWriteParms *pNodeParams)

Sets the parameters for a memory wait / write value node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. hNode must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from hNode are ignored. The destination memory in pNodeParams must be allocated from the same contexts as the original destination memory. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. hGraphExec - The executable graph in which to set the specified node node - Memory wait / write value node from the graph which was used to instantiate graphExec pNodeParams - The updated parameters to set musaSuccess, musaErrorInvalidValue, musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicNodeSetParams, musaGraphExecMemAtomicValueNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memory wait / write value node from the graph which was used to instantiate graphExec
  • const struct musaMemWaitWriteParms * pNodeParams: - The updated parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphAddMemWaitWriteNode, musaGraphMemWaitWriteNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecMemAtomicNodeSetParams, musaGraphExecMemAtomicValueNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecMemTransferNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecMemTransferNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t node, const struct musaMemTransferParms *pNodeParams)

Sets the parameters for a memory transfer node in the given graphExec.

Updates the work represented by node in hGraphExec as though node had contained pNodeParams at instantiation. node must remain in the graph which was used to instantiate hGraphExec. Changed edges to and from node are ignored. The source and destination memory in pNodeParams must be allocated from the same contexts as the original source and destination memory. Zero-length operations are not supported. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. node is also not modified by this call. Returns musaErrorInvalidValue if the memory operands' mappings changed or either the original or new memory operands are multidimensional. hGraphExec - The executable graph in which to set the specified node node - Memory transfer node from the graph which was used to instantiate graphExec pNodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddMemTransferNode, musaGraphMemTransferNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t node: - Memory transfer node from the graph which was used to instantiate graphExec
  • const struct musaMemTransferParms * pNodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddMemTransferNode, musaGraphMemTransferNodeSetParams, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeSetParams(musaGraphNode_t node, struct musaGraphNodeParams *nodeParams)

Update's a graph node's parameters.

Sets the parameters of graph node node to nodeParams. The node type specified by nodeParams->type must match the type of node. nodeParams must be fully initialized and all unused bytes (reserved, padding) zeroed. Modifying parameters is not supported for node types musaGraphNodeTypeMemAlloc and musaGraphNodeTypeMemFree. node - Node to set the parameters for nodeParams - to copy musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported musaGraphAddNode, musaGraphExecNodeSetParams

Parameters:

  • musaGraphNode_t node: - Node to set the parameters for
  • struct musaGraphNodeParams * nodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

See also:

musaGraphAddNode, musaGraphExecNodeSetParams

musaGraphAddNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, struct musaGraphNodeParams *nodeParams)

Adds a node of arbitrary type to a graph.

Creates a new node in graph described by nodeParams with numDependencies dependencies specified via pDependencies. numDependencies may be 0. pDependencies may be null if numDependencies is 0. pDependencies may not have any duplicate entries. nodeParams is a tagged union. The node type should be specified in the type field, and type-specific parameters in the corresponding union member. All unused bytes - that is, reserved0 and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset to ensure all bytes are initialized. Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr. A handle to the new node will be returned in phGraphNode. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies nodeParams - Specification of the node musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported musaGraphCreate, musaGraphNodeSetParams, musaGraphExecNodeSetParams

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • struct musaGraphNodeParams * nodeParams: - Specification of the node

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

See also:

musaGraphCreate, musaGraphNodeSetParams, musaGraphExecNodeSetParams

musaGraphExecNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecNodeSetParams(musaGraphExec_t graphExec, musaGraphNode_t node, struct musaGraphNodeParams *nodeParams)

Update's a graph node's parameters in an instantiated graph.

Sets the parameters of a node in an executable graph graphExec. The node is identified by the corresponding node node in the non-executable graph from which the executable graph was instantiated. node must not have been removed from the original graph. The modifications only affect future launches of graphExec. Already enqueued or running launches of graphExec are not affected by this call. node is also not modified by this call. Allowed changes to parameters on executable graphs are as follows: Node type Allowed changes kernel See musaGraphExecKernelNodeSetParams memcpy Addresses for 1-dimensional copies if allocated in same context; see musaGraphExecMemcpyNodeSetParams memset Addresses for 1-dimensional memsets if allocated in same context; see musaGraphExecMemsetNodeSetParams host Unrestricted child graph Topology must match and restrictions apply recursively; see musaGraphExecUpdate event wait Unrestricted event record Unrestricted external semaphore signal Number of semaphore operations cannot change external semaphore wait Number of semaphore operations cannot change memory allocation API unsupported memory free API unsupported graphExec - The executable graph in which to update the specified node node - Corresponding node from the graph from which graphExec was instantiated nodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported musaGraphAddNode, musaGraphNodeSetParams musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t graphExec: - The executable graph in which to update the specified node
  • musaGraphNode_t node: - Corresponding node from the graph from which graphExec was instantiated
  • struct musaGraphNodeParams * nodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

See also:

musaGraphAddNode, musaGraphNodeSetParams musaGraphExecUpdate, musaGraphInstantiate

musaGraphConditionalHandleCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphConditionalHandleCreate(musaGraphConditionalHandle *pHandle_out, musaGraph_t graph, unsigned int defaultLaunchValue __dv(0), unsigned int flags __dv(0))

Create a conditional handle.

Creates a conditional handle associated with hGraph. The conditional handle must be associated with a conditional node in this graph or one of its children. Handles not associated with a conditional node may cause graph instantiation to fail. pHandle_out - Pointer used to return the handle to the caller. hGraph - Graph which will contain the conditional node using this handle. defaultLaunchValue - Optional initial value for the conditional variable. Applied at the beginning of each graph execution if musaGraphCondAssignDefault is set in flags. flags - Currently must be musaGraphCondAssignDefault or 0. MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_SUPPORTED muGraphAddNode,

Parameters:

  • musaGraphConditionalHandle * pHandle_out: - Pointer used to return the handle to the caller.
  • musaGraph_t graph
  • unsigned int defaultLaunchValue __dv
  • unsigned int flags __dv

Returns:

MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_SUPPORTED

See also:

muGraphAddNode,

musaUserObjectCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaUserObjectCreate(musaUserObject_t *object_out, void *ptr, musaHostFn_t destroy, unsigned int initialRefcount, unsigned int flags)

Create a user object.

Create a user object with the specified destructor callback and initial reference count. The initial references are owned by the caller. Destructor callbacks cannot make MUSA API calls and should avoid blocking behavior, as they are executed by a shared internal thread. Another thread may be signaled to perform such actions, if it does not block forward progress of tasks scheduled through MUSA. See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects. object_out - Location to return the user object handle ptr - The pointer to pass to the destroy function destroy - Callback to free the user object when it is no longer in use initialRefcount - The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread. flags - Currently it is required to pass musaUserObjectNoDestructorSync, which is the only defined flag. This indicates that the destroy callback cannot be waited on by any MUSA API. Users requiring synchronization of the callback should signal its completion manually. musaSuccess, musaErrorInvalidValue musaUserObjectRetain, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

Parameters:

  • musaUserObject_t * object_out: - Location to return the user object handle
  • void * ptr: - The pointer to pass to the destroy function
  • musaHostFn_t destroy: - Callback to free the user object when it is no longer in use
  • unsigned int initialRefcount: - The initial refcount to create the object with, typically 1. The initial references are owned by the calling thread.
  • unsigned int flags: - Currently it is required to pass musaUserObjectNoDestructorSync, which is the only defined flag. This indicates that the destroy callback cannot be waited on by any MUSA API. Users requiring synchronization of the callback should signal its completion manually.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaUserObjectRetain, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

musaUserObjectRetain

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaUserObjectRetain(musaUserObject_t object, unsigned int count __dv(1))

Retain a reference to a user object.

Retains new references to a user object. The new references are owned by the caller. See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects. object - The object to retain count - The number of references to retain, typically 1. Must be nonzero and not larger than INT_MAX. musaSuccess, musaErrorInvalidValue musaUserObjectCreate, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

Parameters:

  • musaUserObject_t object: - The object to retain
  • unsigned int count __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaUserObjectCreate, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

musaUserObjectRelease

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaUserObjectRelease(musaUserObject_t object, unsigned int count __dv(1))

Release a reference to a user object.

Releases user object references owned by the caller. The object's destructor is invoked if the reference count reaches zero. It is undefined behavior to release references not owned by the caller, or to use a user object handle after all references are released. See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects. object - The object to release count - The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX. musaSuccess, musaErrorInvalidValue musaUserObjectCreate, musaUserObjectRetain, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

Parameters:

  • musaUserObject_t object: - The object to release
  • unsigned int count __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaUserObjectCreate, musaUserObjectRetain, musaGraphRetainUserObject, musaGraphReleaseUserObject, musaGraphCreate

musaGraphRetainUserObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphRetainUserObject(musaGraph_t graph, musaUserObject_t object, unsigned int count __dv(1), unsigned int flags __dv(0))

Retain a reference to a user object from a graph.

Creates or moves user object references that will be owned by a MUSA graph. See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects. graph - The graph to associate the reference with object - The user object to retain a reference for count - The number of references to add to the graph, typically 1. Must be nonzero and not larger than INT_MAX. flags - The optional flag musaGraphUserObjectMove transfers references from the calling thread, rather than create new references. Pass 0 to create new references. musaSuccess, musaErrorInvalidValue musaUserObjectCreate musaUserObjectRetain, musaUserObjectRelease, musaGraphReleaseUserObject, musaGraphCreate

Parameters:

  • musaGraph_t graph: - The graph to associate the reference with
  • musaUserObject_t object: - The user object to retain a reference for
  • unsigned int count __dv
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaUserObjectCreate musaUserObjectRetain, musaUserObjectRelease, musaGraphReleaseUserObject, musaGraphCreate

musaGraphReleaseUserObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphReleaseUserObject(musaGraph_t graph, musaUserObject_t object, unsigned int count __dv(1))

Release a user object reference from a graph.

Releases user object references owned by a graph. See MUSA User Objects in the MUSA C++ Programming Guide for more information on user objects. graph - The graph that will release the reference object - The user object to release a reference for count - The number of references to release, typically 1. Must be nonzero and not larger than INT_MAX. musaSuccess, musaErrorInvalidValue musaUserObjectCreate musaUserObjectRetain, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphCreate

Parameters:

  • musaGraph_t graph: - The graph that will release the reference
  • musaUserObject_t object: - The user object to release a reference for
  • unsigned int count __dv

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaUserObjectCreate musaUserObjectRetain, musaUserObjectRelease, musaGraphRetainUserObject, musaGraphCreate

musaGraphDebugDotPrint

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphDebugDotPrint(musaGraph_t graph, const char *path, unsigned int flags)

Write a DOT file describing graph structure.

Using the provided graph, write to path a DOT formatted description of the graph. By default this includes the graph topology, node types, node id, kernel names and memcpy direction. flags can be specified to write more detailed information about each node type such as parameter values, kernel attributes, node and function handles. graph - The graph to create a DOT file from path - The path to write the DOT file to flags - Flags from musaGraphDebugDotFlags for specifying which additional node information to write musaSuccess, musaErrorInvalidValue, musaErrorOperatingSystem

Parameters:

  • musaGraph_t graph: - The graph to create a DOT file from
  • const char * path: - The path to write the DOT file to
  • unsigned int flags: - Flags from musaGraphDebugDotFlags for specifying which additional node information to write

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorOperatingSystem

musaMalloc

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMalloc(void **devPtr, size_t size)

Allocate memory on the device.

Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. musaMalloc() returns musaErrorMemoryAllocation in case of failure. The device version of musaFree cannot be used with a *devPtr allocated using the host API, and vice versa. devPtr - Pointer to allocated device memory size - Requested allocation size in bytes musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMalloc3D, musaMalloc3DArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muMemAlloc

Parameters:

  • void ** devPtr: - Pointer to allocated device memory
  • size_t size: - Requested allocation size in bytes

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMalloc3D, musaMalloc3DArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muMemAlloc

musaMallocPitch

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocPitch(void **devPtr, size_t *pitch, size_t width, size_t height)

Allocates pitched memory on the device.

Allocates at least width (in bytes) * height bytes of linear memory on the device and returns in devPtr a pointer to the allocated memory. The function may pad the allocation to ensure that corresponding pointers in any given row will continue to meet the alignment requirements for coalescing as the address is updated from row to row. The pitch returned in pitch by musaMallocPitch() is the width in bytes of the allocation. The intended usage of pitch is as a separate parameter of the allocation, used to compute addresses within the 2D array. Given the row and column of an array element of type T, the address is computed as: T pElement = (T)((char*)BaseAddress + Row * pitch) + Column; For allocations of 2D arrays, it is recommended that programmers consider performing pitch allocations using musaMallocPitch(). Due to pitch alignment restrictions in the hardware, this is especially true if the application will be performing 2D memory copies between different regions of device memory (whether linear memory or MUSA arrays). devPtr - Pointer to allocated pitched device memory pitch - Pitch for allocation width - Requested pitched allocation width (in bytes) height - Requested pitched allocation height musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMalloc, musaFree, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muMemAllocPitch

Parameters:

  • void ** devPtr: - Pointer to allocated pitched device memory
  • size_t * pitch: - Pitch for allocation
  • size_t width: - Requested pitched allocation width (in bytes)
  • size_t height: - Requested pitched allocation height

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMalloc, musaFree, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muMemAllocPitch

musaMalloc3D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMalloc3D(struct musaPitchedPtr *pitchedDevPtr, struct musaExtent extent)

Allocates logical 1D, 2D, or 3D memory objects on the device.

Allocates at least width * height * depth bytes of linear memory on the device and returns a musaPitchedPtr in which ptr is a pointer to the allocated memory. The function may pad the allocation to ensure hardware alignment requirements are met. The pitch returned in the pitch field of pitchedDevPtr is the width in bytes of the allocation. The returned musaPitchedPtr contains additional fields xsize and ysize, the logical width and height of the allocation, which are equivalent to the width and height extent parameters provided by the programmer during allocation. For allocations of 2D and 3D objects, it is highly recommended that programmers perform allocations using musaMalloc3D() or musaMallocPitch(). Due to alignment restrictions in the hardware, this is especially true if the application will be performing memory copies involving 2D or 3D objects (whether linear memory or MUSA arrays). pitchedDevPtr - Pointer to allocated pitched device memory extent - Requested allocation size (width field in bytes) musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMallocPitch, musaFree, musaMemcpy3D, musaMemset3D, musaMalloc3DArray, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaPitchedPtr, make_musaExtent, muMemAllocPitch

Parameters:

  • struct musaPitchedPtr * pitchedDevPtr: - Pointer to allocated pitched device memory
  • struct musaExtent extent: - Requested allocation size (width field in bytes)

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMallocPitch, musaFree, musaMemcpy3D, musaMemset3D, musaMalloc3DArray, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaPitchedPtr, make_musaExtent, muMemAllocPitch

musaMallocHost

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocHost(void **ptr, size_t size)

Allocates page-locked memory on the host.

Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as musaMemcpy *(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). On systems where pageableMemoryAccessUsesHostPageTables is true, musaMallocHost may not page-lock the allocated memory. Page-locking excessive amounts of memory with musaMallocHost() may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device. ptr - Pointer to allocated host memory size - Requested allocation size in bytes musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMalloc, musaMallocPitch, musaMallocArray, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, musaFree, musaFreeArray, musaMallocHost (C++ API), musaFreeHost, musaHostAlloc, muMemAllocHost

Parameters:

  • void ** ptr: - Pointer to allocated host memory
  • size_t size: - Requested allocation size in bytes

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMalloc, musaMallocPitch, musaMallocArray, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, musaFree, musaFreeArray, musaMallocHost (C++ API), musaFreeHost, musaHostAlloc, muMemAllocHost

musaMallocManaged

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMallocManaged(void **devPtr, size_t size, unsigned int flags)

Allocates memory that will be automatically managed by the Unified Memory system.

Allocates size bytes of managed memory on the device and returns in *devPtr a pointer to the allocated memory. If the device doesn't support allocating managed memory, musaErrorNotSupported is returned. Support for managed memory can be queried using the device attribute musaDevAttrManagedMemory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared. If size is 0, musaMallocManaged returns musaErrorInvalidValue. The pointer is valid on the CPU and on all GPUs in the system that support managed memory. All accesses to this pointer must obey the Unified Memory programming model. flags specifies the default stream association for this allocation. flags must be one of musaMemAttachGlobal or musaMemAttachHost. The default value for flags is musaMemAttachGlobal. If musaMemAttachGlobal is specified, then this memory is accessible from any stream on any device. If musaMemAttachHost is specified, then the allocation should not be accessed from devices that have a zero value for the device attribute musaDevAttrConcurrentManagedAccess; an explicit call to musaStreamAttachMemAsync will be required to enable access on such devices. If the association is later changed via musaStreamAttachMemAsync to a single stream, the default association, as specifed during musaMallocManaged, is restored when that stream is destroyed. For managed variables, the default association is always musaMemAttachGlobal. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen until all work in the stream has completed. Memory allocated with musaMallocManaged should be released with musaFree. Device memory oversubscription is possible for GPUs that have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Managed memory on such GPUs may be evicted from device memory to host memory at any time by the Unified Memory driver in order to make room for other allocations. In a system where all GPUs have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess, managed memory may not be populated when this API returns and instead may be populated on access. In such systems, managed memory can migrate to any processor's memory at any time. The Unified Memory driver will employ heuristics to maintain data locality and prevent excessive page faults to the extent possible. The application can also guide the driver about memory usage patterns via musaMemAdvise. The application can also explicitly migrate memory to a desired processor's memory via musaMemPrefetchAsync. In a multi-GPU system where all of the GPUs have a zero value for the device attribute musaDevAttrConcurrentManagedAccess and all the GPUs have peer-to-peer support with each other, the physical storage for managed memory is created on the GPU which is active at the time musaMallocManaged is called. All other GPUs will reference the data at reduced bandwidth via peer mappings over the PCIe bus. The Unified Memory driver does not migrate memory among such GPUs. In a multi-GPU system where not all GPUs have peer-to-peer support with each other and where the value of the device attribute musaDevAttrConcurrentManagedAccess is zero for at least one of those GPUs, the location chosen for physical storage of managed memory is system-dependent. On Linux, the location chosen will be device memory as long as the current set of active contexts are on devices that either have peer-to-peer support with each other or have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. If there is an active context on a GPU that does not have a non-zero value for that device attribute and it does not have peer-to-peer support with the other devices that have active contexts on them, then the location for physical storage will be 'zero-copy' or host memory. Note that this means that managed memory that is located in device memory is migrated to host memory if a new context is created on a GPU that doesn't have a non-zero value for the device attribute and does not support peer-to-peer with at least one of the other devices that has an active context. This in turn implies that context creation may fail if there is insufficient host memory to migrate all managed allocations. On Windows, the physical storage is always created in 'zero-copy' or host memory. All GPUs will reference the data at reduced bandwidth over the PCIe bus. In these circumstances, use of the environment variable MUSA_VISIBLE_DEVICES is recommended to restrict MUSA to only use those GPUs that have peer-to-peer support. Alternatively, users can also set MUSA_MANAGED_FORCE_DEVICE_ALLOC to a non-zero value to force the driver to always use device memory for physical storage. When this environment variable is set to a non-zero value, all devices used in that process that support managed memory have to be peer-to-peer compatible with each other. The error musaErrorInvalidDevice will be returned if a device that supports managed memory is used and it is not peer-to-peer compatible with any of the other managed memory supporting devices that were previously used in that process, even if musaDeviceReset has been called on those devices. These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section. devPtr - Pointer to allocated device memory size - Requested allocation size in bytes flags - Must be either musaMemAttachGlobal or musaMemAttachHost (defaults to musaMemAttachGlobal) musaSuccess, musaErrorMemoryAllocation, musaErrorNotSupported, musaErrorInvalidValue musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMalloc3D, musaMalloc3DArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, musaDeviceGetAttribute, musaStreamAttachMemAsync, muMemAllocManaged

Parameters:

  • void ** devPtr: - Pointer to allocated device memory
  • size_t size: - Requested allocation size in bytes
  • unsigned int flags: - Must be either musaMemAttachGlobal or musaMemAttachHost (defaults to musaMemAttachGlobal)

Returns:

musaSuccess, musaErrorMemoryAllocation, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMalloc3D, musaMalloc3DArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, musaDeviceGetAttribute, musaStreamAttachMemAsync, muMemAllocManaged

musaFree

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaFree(void *devPtr)

Frees memory on the device.

Frees the memory space pointed to by devPtr, which must have been returned by a previous call to one of the following memory allocation APIs - musaMalloc(), musaMallocPitch(), musaMallocManaged(), musaMallocAsync(), musaMallocFromPoolAsync(). Note - This API will not perform any implicit synchronization when the pointer was allocated with musaMallocAsync or musaMallocFromPoolAsync. Callers must ensure that all accesses to these pointer have completed before invoking musaFree. For best performance and memory reuse, users should use musaFreeAsync to free memory allocated via the stream ordered memory allocator. For all other pointers, this API may perform implicit synchronization. If musaFree (devPtr) has already been called before, an error is returned. If devPtr is 0, no operation is performed. musaFree() returns musaErrorValue in case of failure. The device version of musaFree cannot be used with a *devPtr allocated using the host API, and vice versa. devPtr - Device pointer to memory to free musaSuccess, musaErrorInvalidValue musaMalloc, musaMallocPitch, musaMallocManaged, musaMallocArray, musaFreeArray, musaMallocAsync, musaMallocFromPoolAsync musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaFreeAsync musaHostAlloc, muMemFree

Parameters:

  • void * devPtr: - Device pointer to memory to free

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMalloc, musaMallocPitch, musaMallocManaged, musaMallocArray, musaFreeArray, musaMallocAsync, musaMallocFromPoolAsync musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaFreeAsync musaHostAlloc, muMemFree

musaFreeArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaFreeArray(musaArray_t array)

Frees an array on the device.

Frees the MUSA array array, which must have been returned by a previous call to musaMallocArray(). If devPtr is 0, no operation is performed. array - Pointer to array to free musaSuccess, musaErrorInvalidValue musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muArrayDestroy

Parameters:

  • musaArray_t array: - Pointer to array to free

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muArrayDestroy

musaFreeHost

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaFreeHost(void *ptr)

Frees page-locked memory.

Frees the memory space pointed to by hostPtr, which must have been returned by a previous call to musaMallocHost() or musaHostAlloc(). ptr - Pointer to memory to free musaSuccess, musaErrorInvalidValue musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muMemFreeHost

Parameters:

  • void * ptr: - Pointer to memory to free

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaFreeArray, musaMallocHost (C API), musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muMemFreeHost

musaHostAlloc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaHostAlloc(void **pHost, size_t size, unsigned int flags)

Allocates page-locked memory on the host.

Allocates size bytes of host memory that is page-locked and accessible to the device. The driver tracks the virtual memory ranges allocated with this function and automatically accelerates calls to functions such as musaMemcpy(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory obtained with functions such as malloc(). Allocating excessive amounts of pinned memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to allocate staging areas for data exchange between host and device. The flags parameter enables different options to be specified that affect the allocation, as follows. musaHostAllocDefault: This flag's value is defined to be 0 and causes musaHostAlloc() to emulate musaMallocHost(). musaHostAllocPortable: The memory returned by this call will be considered as pinned memory by all MUSA contexts, not just the one that performed the allocation. musaHostAllocMapped: Maps the allocation into the MUSA address space. The device pointer to the memory may be obtained by calling musaHostGetDevicePointer(). musaHostAllocWriteCombined: Allocates the memory as write-combined (WC). WC memory can be transferred across the PCI Express bus more quickly on some system configurations, but cannot be read efficiently by most CPUs. WC memory is a good option for buffers that will be written by the CPU and read by the device via mapped pinned memory or host->device transfers. All of these flags are orthogonal to one another: a developer may allocate memory that is portable, mapped and/or write-combined with no restrictions. In order for the musaHostAllocMapped flag to have any effect, the MUSA context must support the musaDeviceMapHost flag, which can be checked via musaGetDeviceFlags(). The musaDeviceMapHost flag is implicitly set for contexts created via the runtime API. The musaHostAllocMapped flag may be specified on MUSA contexts for devices that do not support mapped pinned memory. The failure is deferred to musaHostGetDevicePointer() because the memory may be mapped into other MUSA contexts via the musaHostAllocPortable flag. Memory allocated by this function must be freed with musaFreeHost(). pHost - Device pointer to allocated memory size - Requested allocation size in bytes flags - Requested properties of allocated memory musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaSetDeviceFlags, musaMallocHost (C API), musaFreeHost, musaGetDeviceFlags, muMemHostAlloc

Parameters:

  • void ** pHost: - Device pointer to allocated memory
  • size_t size: - Requested allocation size in bytes
  • unsigned int flags: - Requested properties of allocated memory

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaSetDeviceFlags, musaMallocHost (C API), musaFreeHost, musaGetDeviceFlags, muMemHostAlloc

musaHostGetDevicePointer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaHostGetDevicePointer(void **pDevice, void *pHost, unsigned int flags)

Passes back device pointer of mapped host memory allocated by musaHostAlloc or registered by musaHostRegister.

Passes back the device pointer corresponding to the mapped, pinned host buffer allocated by musaHostAlloc() or registered by musaHostRegister(). musaHostGetDevicePointer() will fail if the musaDeviceMapHost flag was not specified before deferred context creation occurred, or if called on a device that does not support mapped, pinned memory. For devices that have a non-zero value for the device attribute musaDevAttrCanUseHostPointerForRegisteredMem, the memory can also be accessed from the device using the host pointer pHost. The device pointer returned by musaHostGetDevicePointer() may or may not match the original host pointer pHost and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will match the original pointer pHost. If any device visible to the application has a zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will not match the original host pointer pHost, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both. flags provides for future releases. For now, it must be set to 0. pDevice - Returned device pointer for mapped memory pHost - Requested host pointer mapping flags - Flags for extensions (must be 0 for now) musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaSetDeviceFlags, musaHostAlloc, muMemHostGetDevicePointer

Parameters:

  • void ** pDevice: - Returned device pointer for mapped memory
  • void * pHost: - Requested host pointer mapping
  • unsigned int flags: - Flags for extensions (must be 0 for now)

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaSetDeviceFlags, musaHostAlloc, muMemHostGetDevicePointer

musaHostGetFlags

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaHostGetFlags(unsigned int *pFlags, void *pHost)

Passes back flags used to allocate pinned host memory allocated by musaHostAlloc.

musaHostGetFlags() will fail if the input pointer does not reside in an address range allocated by musaHostAlloc(). pFlags - Returned flags word pHost - Host pointer musaSuccess, musaErrorInvalidValue musaHostAlloc, muMemHostGetFlags

Parameters:

  • unsigned int * pFlags: - Returned flags word
  • void * pHost: - Host pointer

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaHostAlloc, muMemHostGetFlags

musaPointerGetAttributes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaPointerGetAttributes(struct musaPointerAttributes *attributes, const void *ptr)

Returns attributes about a specified pointer.

Returns in *attributes the attributes of the pointer ptr. If pointer was not allocated in, mapped by or registered with context supporting unified addressing musaErrorInvalidValue is returned. In MUSA 11.0 forward passing host pointer will return musaMemoryTypeUnregistered in musaPointerAttributestype and call will return musaSuccess. The musaPointerAttributes structure is defined as: struct musaPointerAttributes { enum musaMemoryType type; int device; void *devicePointer; void *hostPointer; } In this structure, the individual fields mean musaPointerAttributestype identifies type of memory. It can be musaMemoryTypeUnregistered for unregistered host memory, musaMemoryTypeHost for registered host memory, musaMemoryTypeDevice for device memory or musaMemoryTypeManaged for managed memory. device is the device against which ptr was allocated. If ptr has memory type musaMemoryTypeDevice then this identifies the device on which the memory referred to by ptr physically resides. If ptr has memory type musaMemoryTypeHost then this identifies the device which was current when the allocation was made (and if that device is deinitialized then this allocation will vanish with that device's state). devicePointer is the device pointer alias through which the memory referred to by ptr may be accessed on the current device. If the memory referred to by ptr cannot be accessed directly by the current device then this is NULL. hostPointer is the host pointer alias through which the memory referred to by ptr may be accessed on the host. If the memory referred to by ptr cannot be accessed directly by the host then this is NULL. attributes - Attributes for the specified pointer ptr - Pointer to get attributes for musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaInitDevice, muPointerGetAttributes

Parameters:

  • struct musaPointerAttributes * attributes: - Attributes for the specified pointer
  • const void * ptr: - Pointer to get attributes for

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue

See also:

musaGetDeviceCount, musaGetDevice, musaSetDevice, musaChooseDevice, musaInitDevice, muPointerGetAttributes

musaMemcpy

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy(void *dst, const void *src, size_t count, enum musaMemcpyKind kind)

Returns the layout properties of a sparse MUSA array.

Returns the layout properties of a sparse MUSA array in sparseProperties. If the MUSA array is not allocated with flag musaArraySparse musaErrorInvalidValue will be returned. If the returned value in musaArraySparsePropertiesflags contains musaArraySparsePropertiesSingleMipTail, then musaArraySparsePropertiesmiptailSize represents the total size of the array. Otherwise, it will be zero. Also, the returned value in musaArraySparsePropertiesmiptailFirstLevel is always zero. Note that the array must have been allocated using musaMallocArray or musaMalloc3DArray. For MUSA arrays obtained using musaMipmappedArrayGetLevel, musaErrorInvalidValue will be returned. Instead, musaMipmappedArrayGetSparseProperties must be used to obtain the sparse properties of the entire MUSA mipmapped array to which array belongs to. musaSuccess musaErrorInvalidValue sparseProperties - Pointer to return the musaArraySparseProperties array - The MUSA array to get the sparse properties of musaMipmappedArrayGetSparseProperties, muMemMapArrayAsync Returns the layout properties of a sparse MUSA mipmapped array Returns the sparse array layout properties in sparseProperties. If the MUSA mipmapped array is not allocated with flag musaArraySparse musaErrorInvalidValue will be returned. For non-layered MUSA mipmapped arrays, musaArraySparsePropertiesmiptailSize returns the size of the mip tail region. The mip tail region includes all mip levels whose width, height or depth is less than that of the tile. For layered MUSA mipmapped arrays, if musaArraySparsePropertiesflags contains musaArraySparsePropertiesSingleMipTail, then musaArraySparsePropertiesmiptailSize specifies the size of the mip tail of all layers combined. Otherwise, musaArraySparsePropertiesmiptailSize specifies mip tail size per layer. The returned value of musaArraySparsePropertiesmiptailFirstLevel is valid only if musaArraySparsePropertiesmiptailSize is non-zero. musaSuccess musaErrorInvalidValue sparseProperties - Pointer to return musaArraySparseProperties mipmap - The MUSA mipmapped array to get the sparse properties of musaArrayGetSparseProperties, muMemMapArrayAsync Copies data between host and device Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. Calling musaMemcpy() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. dst - Destination memory address src - Source memory address count - Size in bytes to copy kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyDtoH, muMemcpyHtoD, muMemcpyDtoD, muMemcpy

Parameters:

  • void * dst: - Destination memory address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess musaErrorInvalidValue musaSuccess musaErrorInvalidValue musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMipmappedArrayGetSparseProperties, muMemMapArrayAsync musaArrayGetSparseProperties, muMemMapArrayAsync musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyDtoH, muMemcpyHtoD, muMemcpyDtoD, muMemcpy

musaMemcpyAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemcpyAsync(void *dst, const void *src, size_t count, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. The memory areas may not overlap. Calling musaMemcpyAsync() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. musaMemcpyAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and the stream is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. dst - Destination memory address src - Source memory address count - Size in bytes to copy kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAsync, muMemcpyDtoHAsync, muMemcpyHtoDAsync, muMemcpyDtoDAsync

Parameters:

  • void * dst: - Destination memory address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpyAsync, muMemcpyDtoHAsync, muMemcpyHtoDAsync, muMemcpyDtoDAsync

musaMemcpyBatchAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyBatchAsync(void **dsts, void **srcs, size_t *sizes, size_t count, struct musaMemcpyAttributes *attrs, size_t *attrsIdxs, size_t numAttrs, size_t *failIdx, musaStream_t stream)

Performs a batch of memory copies asynchronously.

Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. This API only supports pointer-to-pointer copies. For copies involving MUSA arrays, please see musaMemcpy3DBatchAsync. Performs memory copies from source buffers specified in srcs to destination buffers specified in dsts. The size of each copy is specified in sizes. All three arrays must be of the same length as specified by count. Since there are no ordering guarantees for copies within a batch, specifying any dependent copies within a batch will result in undefined behavior. Every copy in the batch has to be associated with a set of attributes specified in the attrs array. Each entry in this array can apply to more than one copy. This can be done by specifying in the attrsIdxs array, the index of the first copy that the corresponding entry in the attrs array applies to. Both attrs and attrsIdxs must be of the same length as specified by numAttrs. For example, if a batch has 10 copies listed in dst/src/sizes, the first 6 of which have one set of attributes and the remaining 4 another, then numAttrs will be 2, attrsIdxs will be {0, 6} and attrs will contains the two sets of attributes. Note that the first entry in attrsIdxs must always be 0. Also, each entry must be greater than the previous entry and the last entry should be less than count. Furthermore, numAttrs must be lesser than or equal to count. The musaMemcpyAttributessrcAccessOrder indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to musaMemcpySrcAccessOrderStream, then the source will be accessed in stream order. If the source access order is set to musaMemcpySrcAccessOrderDuringApiCall then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call. If the source access order is set to musaMemcpySrcAccessOrderAny then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside MUSA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcpy operation in the batch must have a valid musaMemcpyAttributes corresponding to it including the appropriate srcAccessOrder setting, otherwise the API will return musaErrorInvalidValue. The musaMemcpyAttributessrcLocHint and musaMemcpyAttributesdstLocHint allows applications to specify hint locations for operands of a copy when the operand doesn't have a fixed location. That is, these hints are only applicable for managed memory pointers on devices where musaDevAttrConcurrentManagedAccess is true or system-allocated pageable memory on devices where musaDevAttrPageableMemoryAccess is true. For other cases, these hints are ignored. The musaMemcpyAttributesflags field can be used to specify certain flags for copies. Setting the musaMemcpyFlagPreferOverlapWithCompute flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy. If any error is encountered while parsing the batch, the index within the batch where the error was encountered will be returned in failIdx. dsts - Array of destination pointers. srcs - Array of memcpy source pointers. sizes - Array of sizes for memcpy operations. count - Size of dsts, srcs and sizes arrays attrs - Array of memcpy attributes. attrsIdxs - Array of indices to specify which copies each entry in the attrs array applies to. The attributes specified in attrs[k] will be applied to copies starting from attrsIdxs[k] through attrsIdxs[k+1] - 1. Also attrs[numAttrs-1] will apply to copies starting from attrsIdxs[numAttrs-1] through count - 1. numAttrs - Size of attrs and attrsIdxs arrays. failIdx - Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy. hStream - The stream to enqueue the operations in. Must not be legacy NULL stream. musaSuccess musaErrorInvalidValue

Parameters:

  • void ** dsts: - Array of destination pointers.
  • void ** srcs: - Array of memcpy source pointers.
  • size_t * sizes: - Array of sizes for memcpy operations.
  • size_t count: - Size of dsts, srcs and sizes arrays
  • struct musaMemcpyAttributes * attrs: - Array of memcpy attributes.
  • size_t * attrsIdxs: - Array of indices to specify which copies each entry in the attrs array applies to. The attributes specified in attrs[k] will be applied to copies starting from attrsIdxs[k] through attrsIdxs[k+1] - 1. Also attrs[numAttrs-1] will apply to copies starting from attrsIdxs[numAttrs-1] through count - 1.
  • size_t numAttrs: - Size of attrs and attrsIdxs arrays.
  • size_t * failIdx: - Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  • musaStream_t stream

Returns:

musaSuccess musaErrorInvalidValue

musaMemcpy3DBatchAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy3DBatchAsync(size_t numOps, struct musaMemcpy3DBatchOp *opList, size_t *failIdx, unsigned long long flags, musaStream_t stream)

Performs a batch of 3D memory copies asynchronously.

Performs a batch of memory copies. The batch as a whole executes in stream order but copies within a batch are not guaranteed to execute in any specific order. Note that this means specifying any dependent copies within a batch will result in undefined behavior. Performs memory copies as specified in the opList array. The length of this array is specified in numOps. Each entry in this array describes a copy operation. This includes among other things, the source and destination operands for the copy as specified in musaMemcpy3DBatchOpsrc and musaMemcpy3DBatchOpdst respectively. The source and destination operands of a copy can either be a pointer or a MUSA array. The width, height and depth of a copy is specified in musaMemcpy3DBatchOpextent. The width, height and depth of a copy are specified in elements and must not be zero. For pointer-to-pointer copies, the element size is considered to be 1. For pointer to MUSA array or vice versa copies, the element size is determined by the MUSA array. For MUSA array to MUSA array copies, the element size of the two MUSA arrays must match. For a given operand, if musaMemcpy3DOperandtype is specified as musaMemcpyOperandTypePointer, then musaMemcpy3DOperandopptr will be used. The musaMemcpy3DOperandopptrptr field must contain the pointer where the copy should begin. The musaMemcpy3DOperandopptrrowLength field specifies the length of each row in elements and must either be zero or be greater than or equal to the width of the copy specified in musaMemcpy3DBatchOpextentwidth. The musaMemcpy3DOperandopptrlayerHeight field specifies the height of each layer and must either be zero or be greater than or equal to the height of the copy specified in musaMemcpy3DBatchOpextentheight. When either of these values is zero, that aspect of the operand is considered to be tightly packed according to the copy extent. For managed memory pointers on devices where musaDevAttrConcurrentManagedAccess is true or system-allocated pageable memory on devices where musaDevAttrPageableMemoryAccess is true, the musaMemcpy3DOperandopptrlocHint field can be used to hint the location of the operand. If an operand's type is specified as musaMemcpyOperandTypeArray, then musaMemcpy3DOperandoparray will be used. The musaMemcpy3DOperandoparrayarray field specifies the MUSA array and musaMemcpy3DOperandoparrayoffset specifies the 3D offset into that array where the copy begins. The musaMemcpyAttributessrcAccessOrder indicates the source access ordering to be observed for copies associated with the attribute. If the source access order is set to musaMemcpySrcAccessOrderStream, then the source will be accessed in stream order. If the source access order is set to musaMemcpySrcAccessOrderDuringApiCall then it indicates that access to the source pointer can be out of stream order and all accesses must be complete before the API call returns. This flag is suited for ephemeral sources (ex., stack variables) when it's known that no prior operations in the stream can be accessing the memory and also that the lifetime of the memory is limited to the scope that the source variable was declared in. Specifying this flag allows the driver to optimize the copy and removes the need for the user to synchronize the stream after the API call. If the source access order is set to musaMemcpySrcAccessOrderAny then it indicates that access to the source pointer can be out of stream order and the accesses can happen even after the API call returns. This flag is suited for host pointers allocated outside MUSA (ex., via malloc) when it's known that no prior operations in the stream can be accessing the memory. Specifying this flag allows the driver to optimize the copy on certain platforms. Each memcopy operation in opList must have a valid srcAccessOrder setting, otherwise this API will return musaErrorInvalidValue. The musaMemcpyAttributesflags field can be used to specify certain flags for copies. Setting the musaMemcpyFlagPreferOverlapWithCompute flag indicates that the associated copies should preferably overlap with any compute work. Note that this flag is a hint and can be ignored depending on the platform and other parameters of the copy. If any error is encountered while parsing the batch, the index within the batch where the error was encountered will be returned in failIdx. numOps - Total number of memcpy operations. opList - Array of size numOps containing the actual memcpy operations. failIdx - Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy. flags - Flags for future use, must be zero now. hStream - The stream to enqueue the operations in. Must not be default NULL stream. musaSuccess musaErrorInvalidValue

Parameters:

  • size_t numOps: - Total number of memcpy operations.
  • struct musaMemcpy3DBatchOp * opList: - Array of size numOps containing the actual memcpy operations.
  • size_t * failIdx: - Pointer to a location to return the index of the copy where a failure was encountered. The value will be SIZE_MAX if the error doesn't pertain to any specific copy.
  • unsigned long long flags: - Flags for future use, must be zero now.
  • musaStream_t stream

Returns:

musaSuccess musaErrorInvalidValue

musaMemcpy2D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2D(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind)

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of each row. The memory areas may not overlap. width must not exceed either dpitch or spitch. Calling musaMemcpy2D() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. musaMemcpy2D() returns an error if dpitch or spitch exceeds the maximum allowed. dst - Destination memory address dpitch - Pitch of destination memory src - Source memory address spitch - Pitch of source memory width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

Parameters:

  • void * dst: - Destination memory address
  • size_t dpitch: - Pitch of destination memory
  • const void * src: - Source memory address
  • size_t spitch: - Pitch of source memory
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

musaMemcpy2DAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch and spitch are the widths in memory in bytes of the 2D arrays pointed to by dst and src, including any padding added to the end of each row. The memory areas may not overlap. width must not exceed either dpitch or spitch. Calling musaMemcpy2DAsync() with dst and src pointers that do not match the direction of the copy results in an undefined behavior. musaMemcpy2DAsync() returns an error if dpitch or spitch is greater than the maximum allowed. musaMemcpy2DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. dst - Destination memory address dpitch - Pitch of destination memory src - Source memory address spitch - Pitch of source memory width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2DAsync

Parameters:

  • void * dst: - Destination memory address
  • size_t dpitch: - Pitch of destination memory
  • const void * src: - Source memory address
  • size_t spitch: - Pitch of source memory
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2DAsync

musaMemcpy2DFromArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2DFromArray(void *dst, size_t dpitch, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, enum musaMemcpyKind kind)

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array src. width must not exceed dpitch. musaMemcpy2DFromArray() returns an error if dpitch exceeds the maximum allowed. dst - Destination memory address dpitch - Pitch of destination memory src - Source memory address wOffset - Source starting X offset (columns in bytes) hOffset - Source starting Y offset (rows) width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

Parameters:

  • void * dst: - Destination memory address
  • size_t dpitch: - Pitch of destination memory
  • musaArray_const_t src: - Source memory address
  • size_t wOffset: - Source starting X offset (columns in bytes)
  • size_t hOffset: - Source starting Y offset (rows)
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

musaMemcpy2DFromArrayAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2DFromArrayAsync(void *dst, size_t dpitch, musaArray_const_t src, size_t wOffset, size_t hOffset, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffset rows and wOffset bytes from the upper left corner to the memory area pointed to by dst, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dpitch is the width in memory in bytes of the 2D array pointed to by dst, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array src. width must not exceed dpitch. musaMemcpy2DFromArrayAsync() returns an error if dpitch exceeds the maximum allowed. musaMemcpy2DFromArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. dst - Destination memory address dpitch - Pitch of destination memory src - Source memory address wOffset - Source starting X offset (columns in bytes) hOffset - Source starting Y offset (rows) width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2DAsync

Parameters:

  • void * dst: - Destination memory address
  • size_t dpitch: - Pitch of destination memory
  • musaArray_const_t src: - Source memory address
  • size_t wOffset: - Source starting X offset (columns in bytes)
  • size_t hOffset: - Source starting Y offset (rows)
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync,

musaMemcpy2DToArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2DToArray(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind)

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array dst. width must not exceed spitch. musaMemcpy2DToArray() returns an error if spitch exceeds the maximum allowed. dst - Destination memory address wOffset - Destination starting X offset (columns in bytes) hOffset - Destination starting Y offset (rows) src - Source memory address spitch - Pitch of source memory width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

Parameters:

  • musaArray_t dst: - Destination memory address
  • size_t wOffset: - Destination starting X offset (columns in bytes)
  • size_t hOffset: - Destination starting Y offset (rows)
  • const void * src: - Source memory address
  • size_t spitch: - Pitch of source memory
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

musaMemcpy2DToArrayAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2DToArrayAsync(musaArray_t dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the memory area pointed to by src to the MUSA array dst starting at hOffset rows and wOffset bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. spitch is the width in memory in bytes of the 2D array pointed to by src, including any padding added to the end of each row. wOffset + width must not exceed the width of the MUSA array dst. width must not exceed spitch. musaMemcpy2DToArrayAsync() returns an error if spitch exceeds the maximum allowed. musaMemcpy2DToArrayAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. dst - Destination memory address wOffset - Destination starting X offset (columns in bytes) hOffset - Destination starting Y offset (rows) src - Source memory address spitch - Pitch of source memory width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2DAsync

Parameters:

  • musaArray_t dst: - Destination memory address
  • size_t wOffset: - Destination starting X offset (columns in bytes)
  • size_t hOffset: - Destination starting Y offset (rows)
  • const void * src: - Source memory address
  • size_t spitch: - Pitch of source memory
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync,

musaMemcpy2DArrayToArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy2DArrayToArray(musaArray_t dst, size_t wOffsetDst, size_t hOffsetDst, musaArray_const_t src, size_t wOffsetSrc, size_t hOffsetSrc, size_t width, size_t height, enum musaMemcpyKind kind __dv(musaMemcpyDeviceToDevice))

Copies data between host and device.

Copies a matrix (height rows of width bytes each) from the MUSA array src starting at hOffsetSrc rows and wOffsetSrc bytes from the upper left corner to the MUSA array dst starting at hOffsetDst rows and wOffsetDst bytes from the upper left corner, where kind specifies the direction of the copy, and must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. wOffsetDst + width must not exceed the width of the MUSA array dst. wOffsetSrc + width must not exceed the width of the MUSA array src. dst - Destination memory address wOffsetDst - Destination starting X offset (columns in bytes) hOffsetDst - Destination starting Y offset (rows) src - Source memory address wOffsetSrc - Source starting X offset (columns in bytes) hOffsetSrc - Source starting Y offset (rows) width - Width of matrix transfer (columns in bytes) height - Height of matrix transfer (rows) kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

Parameters:

  • musaArray_t dst: - Destination memory address
  • size_t wOffsetDst: - Destination starting X offset (columns in bytes)
  • size_t hOffsetDst: - Destination starting Y offset (rows)
  • musaArray_const_t src: - Source memory address
  • size_t wOffsetSrc: - Source starting X offset (columns in bytes)
  • size_t hOffsetSrc: - Source starting Y offset (rows)
  • size_t width: - Width of matrix transfer (columns in bytes)
  • size_t height: - Height of matrix transfer (rows)
  • enum musaMemcpyKind kind __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidMemcpyDirection

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy2D, muMemcpy2DUnaligned

musaMemcpy3D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy3D(const struct musaMemcpy3DParms *p)

Copies data between 3D objects.

struct musaExtent { size_t width; size_t height; size_t depth; }; struct musaExtent make_musaExtent(size_t w, size_t h, size_t d); struct musaPos { size_t x; size_t y; size_t z; }; struct musaPos make_musaPos(size_t x, size_t y, size_t z); struct musaMemcpy3DParms { musaArray_t srcArray; struct musaPos srcPos; struct musaPitchedPtr srcPtr; musaArray_t dstArray; struct musaPos dstPos; struct musaPitchedPtr dstPtr; struct musaExtent extent; enum musaMemcpyKind kind; }; musaMemcpy3D() copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a MUSA array. The source, destination, extent, and kind of copy performed is specified by the musaMemcpy3DParms struct which should be initialized to zero before use: musaMemcpy3DParms myParms = {0}; The struct passed to musaMemcpy3D() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. Passing more than one non-zero source or destination will cause musaMemcpy3D() to return an error. The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char. The extent field defines the dimensions of the transferred area in elements. If a MUSA array is participating in the copy, the extent is defined in terms of that array's elements. If no MUSA array is participating in the copy then the extents are defined in elements of unsigned char. The kind field defines the direction of the copy. It must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. For musaMemcpyHostToHost or musaMemcpyHostToDevice or musaMemcpyDeviceToHost passed as kind and musaArray type passed as source or destination, if the kind implies musaArray type to be present on the host, musaMemcpy3D() will disregard that implication and silently correct the kind based on the fact that musaArray type can only be present on the device. If the source and destination are both arrays, musaMemcpy3D() will return an error if they do not have the same element size. The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result. The source object must entirely contain the region defined by srcPos and extent. The destination object must entirely contain the region defined by dstPos and extent. musaMemcpy3D() returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a musaPitchedPtr allocated with musaMalloc3D() will always be valid. p - 3D memory copy parameters musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMalloc3D, musaMalloc3DArray, musaMemset3D, musaMemcpy3DAsync, musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, make_musaExtent, make_musaPos, muMemcpy3D

Parameters:

  • const struct musaMemcpy3DParms * p: - 3D memory copy parameters

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMalloc3D, musaMalloc3DArray, musaMemset3D, musaMemcpy3DAsync, musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, make_musaExtent, make_musaPos, muMemcpy3D

musaMemcpy3DPeer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy3DPeer(const struct musaMemcpy3DPeerParms *p)

Copies memory between devices.

Perform a 3D memory copy according to the parameters specified in p. See the definition of the musaMemcpy3DPeerParms structure for documentation of its parameters. Note that this function is synchronous with respect to the host only if the source or destination of the transfer is host memory. Note also that this copy is serialized with respect to all pending and future asynchronous work in to the current device, the copy's source device, and the copy's destination device (use musaMemcpy3DPeerAsync to avoid this synchronization). p - for the memory copy musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpy3DPeer

Parameters:

  • const struct musaMemcpy3DPeerParms * p: - Parameters for the memory copy

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpy3DPeer

musaMemcpy3DAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemcpy3DAsync(const struct musaMemcpy3DParms *p, musaStream_t stream __dv(0))

Copies data between 3D objects.

struct musaExtent { size_t width; size_t height; size_t depth; }; struct musaExtent make_musaExtent(size_t w, size_t h, size_t d); struct musaPos { size_t x; size_t y; size_t z; }; struct musaPos make_musaPos(size_t x, size_t y, size_t z); struct musaMemcpy3DParms { musaArray_t srcArray; struct musaPos srcPos; struct musaPitchedPtr srcPtr; musaArray_t dstArray; struct musaPos dstPos; struct musaPitchedPtr dstPtr; struct musaExtent extent; enum musaMemcpyKind kind; }; musaMemcpy3DAsync() copies data betwen two 3D objects. The source and destination objects may be in either host memory, device memory, or a MUSA array. The source, destination, extent, and kind of copy performed is specified by the musaMemcpy3DParms struct which should be initialized to zero before use: musaMemcpy3DParms myParms = {0}; The struct passed to musaMemcpy3DAsync() must specify one of srcArray or srcPtr and one of dstArray or dstPtr. Passing more than one non-zero source or destination will cause musaMemcpy3DAsync() to return an error. The srcPos and dstPos fields are optional offsets into the source and destination objects and are defined in units of each object's elements. The element for a host or device pointer is assumed to be unsigned char. For MUSA arrays, positions must be in the range [0, 2048) for any dimension. The extent field defines the dimensions of the transferred area in elements. If a MUSA array is participating in the copy, the extent is defined in terms of that array's elements. If no MUSA array is participating in the copy then the extents are defined in elements of unsigned char. The kind field defines the direction of the copy. It must be one of musaMemcpyHostToHost, musaMemcpyHostToDevice, musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. For musaMemcpyHostToHost or musaMemcpyHostToDevice or musaMemcpyDeviceToHost passed as kind and musaArray type passed as source or destination, if the kind implies musaArray type to be present on the host, musaMemcpy3DAsync() will disregard that implication and silently correct the kind based on the fact that musaArray type can only be present on the device. If the source and destination are both arrays, musaMemcpy3DAsync() will return an error if they do not have the same element size. The source and destination object may not overlap. If overlapping source and destination objects are specified, undefined behavior will result. The source object must lie entirely within the region defined by srcPos and extent. The destination object must lie entirely within the region defined by dstPos and extent. musaMemcpy3DAsync() returns an error if the pitch of srcPtr or dstPtr exceeds the maximum allowed. The pitch of a musaPitchedPtr allocated with musaMalloc3D() will always be valid. musaMemcpy3DAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice or musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. p - 3D memory copy parameters stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection musaMalloc3D, musaMalloc3DArray, musaMemset3D, musaMemcpy3D, musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray,::: musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, make_musaExtent, make_musaPos, muMemcpy3DAsync

Parameters:

  • const struct musaMemcpy3DParms * p: - 3D memory copy parameters
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidPitchValue, musaErrorInvalidMemcpyDirection

See also:

musaMalloc3D, musaMalloc3DArray, musaMemset3D, musaMemcpy3D, musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray,::: musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, make_musaExtent, make_musaPos, muMemcpy3DAsync

musaMemcpy3DPeerAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpy3DPeerAsync(const struct musaMemcpy3DPeerParms *p, musaStream_t stream __dv(0))

Copies memory between devices asynchronously.

Perform a 3D memory copy according to the parameters specified in p. See the definition of the musaMemcpy3DPeerParms structure for documentation of its parameters. p - for the memory copy stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpy3DPeerAsync

Parameters:

  • const struct musaMemcpy3DPeerParms * p: - Parameters for the memory copy
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice, musaErrorInvalidPitchValue

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpy3DPeerAsync

musaHostRegister

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaHostRegister(void *ptr, size_t size, unsigned int flags)

Registers an existing host memory range for use by MUSA.

Page-locks the memory range specified by ptr and size and maps it for the device(s) as specified by flags. This memory range also is added to the same tracking mechanism as musaHostAlloc() to automatically accelerate calls to functions such as musaMemcpy(). Since the memory can be accessed directly by the device, it can be read or written with much higher bandwidth than pageable memory that has not been registered. Page-locking excessive amounts of memory may degrade system performance, since it reduces the amount of memory available to the system for paging. As a result, this function is best used sparingly to register staging areas for data exchange between host and device. On systems where pageableMemoryAccessUsesHostPageTables is true, musaHostRegister will not page-lock the memory range specified by ptr but only populate unpopulated pages. musaHostRegister is supported only on I/O coherent devices that have a non-zero value for the device attribute musaDevAttrHostRegisterSupported. The flags parameter enables different options to be specified that affect the allocation, as follows. musaHostRegisterDefault: On a system with unified virtual addressing, the memory will be both mapped and portable. On a system with no unified virtual addressing, the memory will be neither mapped nor portable. musaHostRegisterPortable: The memory returned by this call will be considered as pinned memory by all MUSA contexts, not just the one that performed the allocation. musaHostRegisterMapped: Maps the allocation into the MUSA address space. The device pointer to the memory may be obtained by calling musaHostGetDevicePointer(). musaHostRegisterIoMemory: The passed memory pointer is treated as pointing to some memory-mapped I/O space, e.g. belonging to a third-party PCIe device, and it will marked as non cache-coherent and contiguous. musaHostRegisterReadOnly: The passed memory pointer is treated as pointing to memory that is considered read-only by the device. On platforms without musaDevAttrPageableMemoryAccessUsesHostPageTables, this flag is required in order to register memory mapped to the CPU as read-only. Support for the use of this flag can be queried from the device attribute musaDevAttrHostRegisterReadOnlySupported. Using this flag with a current context associated with a device that does not have this attribute set will cause musaHostRegister to error with musaErrorNotSupported. All of these flags are orthogonal to one another: a developer may page-lock memory that is portable or mapped with no restrictions. The MUSA context must have been created with the musaMapHost flag in order for the musaHostRegisterMapped flag to have any effect. The musaHostRegisterMapped flag may be specified on MUSA contexts for devices that do not support mapped pinned memory. The failure is deferred to musaHostGetDevicePointer() because the memory may be mapped into other MUSA contexts via the musaHostRegisterPortable flag. For devices that have a non-zero value for the device attribute musaDevAttrCanUseHostPointerForRegisteredMem, the memory can also be accessed from the device using the host pointer ptr. The device pointer returned by musaHostGetDevicePointer() may or may not match the original host pointer ptr and depends on the devices visible to the application. If all devices visible to the application have a non-zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will match the original pointer ptr. If any device visible to the application has a zero value for the device attribute, the device pointer returned by musaHostGetDevicePointer() will not match the original host pointer ptr, but it will be suitable for use on all devices provided Unified Virtual Addressing is enabled. In such systems, it is valid to access the memory using either pointer on devices that have a non-zero value for the device attribute. Note however that such devices should access the memory using only of the two pointers and not both. The memory page-locked by this function must be unregistered with musaHostUnregister(). ptr - Host pointer to memory to page-lock size - Size in bytes of the address range to page-lock in bytes flags - Flags for allocation request musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorHostMemoryAlreadyRegistered, musaErrorNotSupported musaHostUnregister, musaHostGetFlags, musaHostGetDevicePointer, muMemHostRegister

Parameters:

  • void * ptr: - Host pointer to memory to page-lock
  • size_t size: - Size in bytes of the address range to page-lock in bytes
  • unsigned int flags: - Flags for allocation request

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorHostMemoryAlreadyRegistered, musaErrorNotSupported

See also:

musaHostUnregister, musaHostGetFlags, musaHostGetDevicePointer, muMemHostRegister

musaHostUnregister

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaHostUnregister(void *ptr)

Unregisters a memory range that was registered with musaHostRegister.

Unmaps the memory range whose base address is specified by ptr, and makes it pageable again. The base address must be the same one specified to musaHostRegister(). ptr - Host pointer to memory to unregister musaSuccess, musaErrorInvalidValue, musaErrorHostMemoryNotRegistered musaHostUnregister, muMemHostUnregister

Parameters:

  • void * ptr: - Host pointer to memory to unregister

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorHostMemoryNotRegistered

See also:

musaHostUnregister, muMemHostUnregister

musaMemGetInfo

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemGetInfo(size_t *free, size_t *total)

Gets free and total device memory.

Returns in *total the total amount of memory available to the the current context. Returns in *free the amount of memory on the device that is free according to the OS. MUSA is not guaranteed to be able to allocate all of the memory that the OS reports as free. In a multi-tenet situation, free estimate returned is prone to race condition where a new allocation/free done by a different process or a different thread in the same process between the time when free memory was estimated and reported, will result in deviation in free value reported and actual free memory. The integrated GPU on Tegra shares memory with CPU and other component of the SoC. The free and total values returned by the API excludes the SWAP memory space maintained by the OS on some platforms. The OS may move some of the memory pages into swap area as the GPU or CPU allocate or access memory. See Tegra app note on how to calculate total and free memory on Tegra. free - Returned free memory in bytes total - Returned total memory in bytes musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure muMemGetInfo

Parameters:

  • size_t * free: - Returned free memory in bytes
  • size_t * total: - Returned total memory in bytes

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorLaunchFailure

See also:

muMemGetInfo

musaArrayGetInfo

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaArrayGetInfo(struct musaChannelFormatDesc *desc, struct musaExtent *extent, unsigned int *flags, musaArray_t array)

Gets info about the specified musaArray.

Returns in *desc, *extent and *flags respectively, the type, shape and flags of array. Any of *desc, *extent and *flags may be specified as NULL. desc - Returned array type extent - Returned array shape. 2D arrays will have depth of zero flags - Returned array flags array - The musaArray to get info for musaSuccess, musaErrorInvalidValue muArrayGetDescriptor, muArray3DGetDescriptor

Parameters:

  • struct musaChannelFormatDesc * desc: - Returned array type
  • struct musaExtent * extent: - Returned array shape. 2D arrays will have depth of zero
  • unsigned int * flags: - Returned array flags
  • musaArray_t array: - The musaArray to get info for

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muArrayGetDescriptor, muArray3DGetDescriptor

musaMemset

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemset(void *devPtr, int value, size_t count)

Initializes or sets device memory to a value.

Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value. Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory. devPtr - Pointer to device memory value - Value to set for each byte of specified memory count - Size in bytes to set musaSuccess, musaErrorInvalidValue, muMemsetD8, muMemsetD16, muMemsetD32

Parameters:

  • void * devPtr: - Pointer to device memory
  • int value: - Value to set for each byte of specified memory
  • size_t count: - Size in bytes to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muMemsetD8, muMemsetD16, muMemsetD32

musaMemsetAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemsetAsync(void *devPtr, int value, size_t count, musaStream_t stream __dv(0))

Initializes or sets device memory to a value.

Fills the first count bytes of the memory area pointed to by devPtr with the constant byte value value. musaMemsetAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. devPtr - Pointer to device memory value - Value to set for each byte of specified memory count - Size in bytes to set stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaMemset, musaMemset2D, musaMemset3D, musaMemset2DAsync, musaMemset3DAsync, muMemsetD8Async, muMemsetD16Async, muMemsetD32Async

Parameters:

  • void * devPtr: - Pointer to device memory
  • int value: - Value to set for each byte of specified memory
  • size_t count: - Size in bytes to set
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemset, musaMemset2D, musaMemset3D, musaMemset2DAsync, musaMemset3DAsync, muMemsetD8Async, muMemsetD16Async, muMemsetD32Async

musaMemset2D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemset2D(void *devPtr, size_t pitch, int value, size_t width, size_t height)

Initializes or sets device memory to a value.

Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is the width in bytes of the 2D array pointed to by dstPtr, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by musaMallocPitch(). Note that this function is asynchronous with respect to the host unless devPtr refers to pinned host memory. devPtr - Pointer to 2D device memory pitch - Pitch in bytes of 2D device memory(Unused if height is 1) value - Value to set for each byte of specified memory width - Width of matrix set (columns in bytes) height - Height of matrix set (rows) musaSuccess, musaErrorInvalidValue, musaMemset, musaMemset3D, musaMemsetAsync, musaMemset2DAsync, musaMemset3DAsync, muMemsetD2D8, muMemsetD2D16, muMemsetD2D32

Parameters:

  • void * devPtr: - Pointer to 2D device memory
  • size_t pitch: - Pitch in bytes of 2D device memory(Unused if height is 1)
  • int value: - Value to set for each byte of specified memory
  • size_t width: - Width of matrix set (columns in bytes)
  • size_t height: - Height of matrix set (rows)

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemset, musaMemset3D, musaMemsetAsync, musaMemset2DAsync, musaMemset3DAsync, muMemsetD2D8, muMemsetD2D16, muMemsetD2D32

musaMemset2DAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, musaStream_t stream __dv(0))

Initializes or sets device memory to a value.

Sets to the specified value value a matrix (height rows of width bytes each) pointed to by dstPtr. pitch is the width in bytes of the 2D array pointed to by dstPtr, including any padding added to the end of each row. This function performs fastest when the pitch is one that has been passed back by musaMallocPitch(). musaMemset2DAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. devPtr - Pointer to 2D device memory pitch - Pitch in bytes of 2D device memory(Unused if height is 1) value - Value to set for each byte of specified memory width - Width of matrix set (columns in bytes) height - Height of matrix set (rows) stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaMemset, musaMemset2D, musaMemset3D, musaMemsetAsync, musaMemset3DAsync, muMemsetD2D8Async, muMemsetD2D16Async, muMemsetD2D32Async

Parameters:

  • void * devPtr: - Pointer to 2D device memory
  • size_t pitch: - Pitch in bytes of 2D device memory(Unused if height is 1)
  • int value: - Value to set for each byte of specified memory
  • size_t width: - Width of matrix set (columns in bytes)
  • size_t height: - Height of matrix set (rows)
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemset, musaMemset2D, musaMemset3D, musaMemsetAsync, musaMemset3DAsync, muMemsetD2D8Async, muMemsetD2D16Async, muMemsetD2D32Async

musaMemset3D

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemset3D(struct musaPitchedPtr pitchedDevPtr, int value, struct musaExtent extent)

Initializes or sets device memory to a value.

Initializes each element of a 3D array to the specified value value. The object to initialize is defined by pitchedDevPtr. The pitch field of pitchedDevPtr is the width in memory in bytes of the 3D array pointed to by pitchedDevPtr, including any padding added to the end of each row. The xsize field specifies the logical width of each row in bytes, while the ysize field specifies the height of each 2D slice in rows. The pitch field of pitchedDevPtr is ignored when height and depth are both equal to 1. The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices. Extents with width greater than or equal to the xsize of pitchedDevPtr may perform significantly faster than extents narrower than the xsize. Secondarily, extents with height equal to the ysize of pitchedDevPtr will perform faster than when the height is shorter than the ysize. This function performs fastest when the pitchedDevPtr has been allocated by musaMalloc3D(). Note that this function is asynchronous with respect to the host unless pitchedDevPtr refers to pinned host memory. pitchedDevPtr - Pointer to pitched device memory value - Value to set for each byte of specified memory extent - Size parameters for where to set device memory (width field in bytes) musaSuccess, musaErrorInvalidValue, musaMemset, musaMemset2D, musaMemsetAsync, musaMemset2DAsync, musaMemset3DAsync, musaMalloc3D, make_musaPitchedPtr, make_musaExtent

Parameters:

  • struct musaPitchedPtr pitchedDevPtr: - Pointer to pitched device memory
  • int value: - Value to set for each byte of specified memory
  • struct musaExtent extent: - Size parameters for where to set device memory (width field in bytes)

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemset, musaMemset2D, musaMemsetAsync, musaMemset2DAsync, musaMemset3DAsync, musaMalloc3D, make_musaPitchedPtr, make_musaExtent

musaMemset3DAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemset3DAsync(struct musaPitchedPtr pitchedDevPtr, int value, struct musaExtent extent, musaStream_t stream __dv(0))

Initializes or sets device memory to a value.

Initializes each element of a 3D array to the specified value value. The object to initialize is defined by pitchedDevPtr. The pitch field of pitchedDevPtr is the width in memory in bytes of the 3D array pointed to by pitchedDevPtr, including any padding added to the end of each row. The xsize field specifies the logical width of each row in bytes, while the ysize field specifies the height of each 2D slice in rows. The pitch field of pitchedDevPtr is ignored when height and depth are both equal to 1. The extents of the initialized region are specified as a width in bytes, a height in rows, and a depth in slices. Extents with width greater than or equal to the xsize of pitchedDevPtr may perform significantly faster than extents narrower than the xsize. Secondarily, extents with height equal to the ysize of pitchedDevPtr will perform faster than when the height is shorter than the ysize. This function performs fastest when the pitchedDevPtr has been allocated by musaMalloc3D(). musaMemset3DAsync() is asynchronous with respect to the host, so the call may return before the memset is complete. The operation can optionally be associated to a stream by passing a non-zero stream argument. If stream is non-zero, the operation may overlap with operations in other streams. The device version of this function only handles device to device copies and cannot be given local or shared pointers. pitchedDevPtr - Pointer to pitched device memory value - Value to set for each byte of specified memory extent - Size parameters for where to set device memory (width field in bytes) stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaMemset, musaMemset2D, musaMemset3D, musaMemsetAsync, musaMemset2DAsync, musaMalloc3D, make_musaPitchedPtr, make_musaExtent

Parameters:

  • struct musaPitchedPtr pitchedDevPtr: - Pointer to pitched device memory
  • int value: - Value to set for each byte of specified memory
  • struct musaExtent extent: - Size parameters for where to set device memory (width field in bytes)
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaMemset, musaMemset2D, musaMemset3D, musaMemsetAsync, musaMemset2DAsync, musaMalloc3D, make_musaPitchedPtr, make_musaExtent

musaIpcCloseMemHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaIpcCloseMemHandle(void *devPtr)

Attempts to close memory mapped with musaIpcOpenMemHandle.

Decrements the reference count of the memory returnd by musaIpcOpenMemHandle by 1. When the reference count reaches 0, this API unmaps the memory. The original allocation in the exporting process as well as imported mappings in other processes will be unaffected. Any resources used to enable peer access will be freed if this is the last mapping using them. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport devPtr - Device pointer returned by musaIpcOpenMemHandle musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, muIpcCloseMemHandle

Parameters:

  • void * devPtr: - Device pointer returned by musaIpcOpenMemHandle

Returns:

musaSuccess, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcOpenMemHandle, muIpcCloseMemHandle

musaIpcGetMemHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaIpcGetMemHandle(musaIpcMemHandle_t *handle, void *devPtr)

Gets an interprocess memory handle for an existing device memory allocation.

Takes a pointer to the base of an existing device memory allocation created with musaMalloc and exports it for use in another process. This is a lightweight operation and may be called multiple times on an allocation without adverse effects. If a region of memory is freed with musaFree and a subsequent call to musaMalloc returns memory with the same device address, musaIpcGetMemHandle will return a unique handle for the new memory. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport handle - Pointer to user allocated musaIpcMemHandle to return the handle in. devPtr - Base pointer to previously allocated device memory musaSuccess, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetMemHandle

Parameters:

  • musaIpcMemHandle_t * handle: - Pointer to user allocated musaIpcMemHandle to return the handle in.
  • void * devPtr: - Base pointer to previously allocated device memory

Returns:

musaSuccess, musaErrorMemoryAllocation, musaErrorMapBufferObjectFailed, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcOpenMemHandle, musaIpcCloseMemHandle, muIpcGetMemHandle

musaIpcOpenMemHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaIpcOpenMemHandle(void **devPtr, musaIpcMemHandle_t handle, unsigned int flags)

Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process.

Maps memory exported from another process with musaIpcGetMemHandle into the current device address space. For contexts on different devices musaIpcOpenMemHandle can attempt to enable peer access between the devices as if the user called musaDeviceEnablePeerAccess. This behavior is controlled by the musaIpcMemLazyEnablePeerAccess flag. musaDeviceCanAccessPeer can determine if a mapping is possible. musaIpcOpenMemHandle can open handles to devices that may not be visible in the process calling the API. Contexts that may open musaIpcMemHandles are restricted in the following way. musaIpcMemHandles from each device in a given process may only be opened by one context per device per other process. If the memory handle has already been opened by the current context, the reference count on the handle is incremented by 1 and the existing device pointer is returned. Memory returned from musaIpcOpenMemHandle must be freed with musaIpcCloseMemHandle. Calling musaFree on an exported memory region before calling musaIpcCloseMemHandle in the importing context will result in undefined behavior. IPC functionality is restricted to devices with support for unified addressing on Linux and Windows operating systems. IPC functionality on Windows is supported for compatibility purposes but not recommended as it comes with performance cost. Users can test their device for IPC functionality by calling musaDeviceGetAttribute with musaDevAttrIpcEventSupport devPtr - Returned device pointer handle - musaIpcMemHandle to open flags - Flags for this operation. Must be specified as musaIpcMemLazyEnablePeerAccess musaSuccess, musaErrorMapBufferObjectFailed, musaErrorInvalidResourceHandle, musaErrorDeviceUninitialized, musaErrorTooManyPeers, musaErrorNotSupported, musaErrorInvalidValue No guarantees are made about the address returned in *devPtr. In particular, multiple processes may not receive the same address for the same handle. musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcCloseMemHandle, musaDeviceEnablePeerAccess, musaDeviceCanAccessPeer, muIpcOpenMemHandle

Parameters:

  • void ** devPtr: - Returned device pointer
  • musaIpcMemHandle_t handle: - musaIpcMemHandle to open
  • unsigned int flags: - Flags for this operation. Must be specified as musaIpcMemLazyEnablePeerAccess

Returns:

musaSuccess, musaErrorMapBufferObjectFailed, musaErrorInvalidResourceHandle, musaErrorDeviceUninitialized, musaErrorTooManyPeers, musaErrorNotSupported, musaErrorInvalidValue

See also:

musaMalloc, musaFree, musaIpcGetEventHandle, musaIpcOpenEventHandle, musaIpcGetMemHandle, musaIpcCloseMemHandle, musaDeviceEnablePeerAccess, musaDeviceCanAccessPeer, muIpcOpenMemHandle

musaMallocMipmappedArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocMipmappedArray(musaMipmappedArray_t *mipmappedArray, const struct musaChannelFormatDesc *desc, struct musaExtent extent, unsigned int numLevels, unsigned int flags __dv(0))

Allocate a mipmapped array on the device.

Allocates a MUSA mipmapped array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA mipmapped array in *mipmappedArray. numLevels specifies the number of mipmap levels to be allocated. This value is clamped to the range [1, 1 + floor(log2(max(width, height, depth)))]. The musaChannelFormatDesc is defined as: struct musaChannelFormatDesc { int x, y, z, w; enum musaChannelFormatKind f; }; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat. musaMallocMipmappedArray() can allocate the following: A 1D mipmapped array is allocated if the height and depth extents are both zero. A 2D mipmapped array is allocated if only the depth extent is zero. A 3D mipmapped array is allocated if all three extents are non-zero. A 1D layered MUSA mipmapped array is allocated if only the height extent is zero and the musaArrayLayered flag is set. Each layer is a 1D mipmapped array. The number of layers is determined by the depth extent. A 2D layered MUSA mipmapped array is allocated if all three extents are non-zero and the musaArrayLayered flag is set. Each layer is a 2D mipmapped array. The number of layers is determined by the depth extent. A cubemap MUSA mipmapped array is allocated if all three extents are non-zero and the musaArrayCubemap flag is set. Width must be equal to height, and depth must be six. The order of the six layers in memory is the same as that listed in musaGraphicsCubeFace. A cubemap layered MUSA mipmapped array is allocated if all three extents are non-zero, and both, musaArrayCubemap and musaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered MUSA mipmapped array is a special type of 2D layered MUSA mipmapped array that consists of a collection of cubemap mipmapped arrays. The first six layers represent the first cubemap mipmapped array, the next six layers form the second cubemap mipmapped array, and so on. The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default mipmapped array allocation musaArrayLayered: Allocates a layered MUSA mipmapped array, with the depth extent indicating the number of layers musaArrayCubemap: Allocates a cubemap MUSA mipmapped array. Width must be equal to height, and depth must be six. If the musaArrayLayered flag is also set, depth must be a multiple of six. musaArraySurfaceLoadStore: This flag indicates that individual mipmap levels of the MUSA mipmapped array will be read from or written to using a surface reference. musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the MUSA array. Texture gather can only be performed on 2D MUSA mipmapped arrays, and the gather operations are performed only on the most detailed mipmap level. musaArraySparse: Allocates a MUSA mipmapped array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. This flag can only be used for creating 2D, 3D or 2D layered sparse MUSA mipmapped arrays. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA mipmapped array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate. The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements. MUSA array type Valid extents that must always be met {(width range in elements), (height range), (depth range)} Valid extents with musaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} 1D { (1,maxTexture1DMipmap), 0, 0 } { (1,maxSurface1D), 0, 0 } 2D { (1,maxTexture2DMipmap[0]), (1,maxTexture2DMipmap[1]), 0 } { (1,maxSurface2D[0]), (1,maxSurface2D[1]), 0 } 3D { (1,maxTexture3D[0]), (1,maxTexture3D[1]), (1,maxTexture3D[2]) } OR { (1,maxTexture3DAlt[0]), (1,maxTexture3DAlt[1]), (1,maxTexture3DAlt[2]) } { (1,maxSurface3D[0]), (1,maxSurface3D[1]), (1,maxSurface3D[2]) } 1D Layered { (1,maxTexture1DLayered[0]), 0, (1,maxTexture1DLayered[1]) } { (1,maxSurface1DLayered[0]), 0, (1,maxSurface1DLayered[1]) } 2D Layered { (1,maxTexture2DLayered[0]), (1,maxTexture2DLayered[1]), (1,maxTexture2DLayered[2]) } { (1,maxSurface2DLayered[0]), (1,maxSurface2DLayered[1]), (1,maxSurface2DLayered[2]) } Cubemap { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } Cubemap Layered { (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[1]) } { (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[1]) } mipmappedArray - Pointer to allocated mipmapped array in device memory desc - Requested channel format extent - Requested allocation size (width field in elements) numLevels - Number of mipmap levels to allocate flags - Flags for extensions musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muMipmappedArrayCreate

Parameters:

  • musaMipmappedArray_t * mipmappedArray: - Pointer to allocated mipmapped array in device memory
  • const struct musaChannelFormatDesc * desc: - Requested channel format
  • struct musaExtent extent: - Requested allocation size (width field in elements)
  • unsigned int numLevels: - Number of mipmap levels to allocate
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muMipmappedArrayCreate

musaFreeMipmappedArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaFreeMipmappedArray(musaMipmappedArray_t mipmappedArray)

Frees a mipmapped array on the device.

Frees the MUSA mipmapped array mipmappedArray, which must have been returned by a previous call to musaMallocMipmappedArray(). If devPtr is 0, no operation is performed. mipmappedArray - Pointer to mipmapped array to free musaSuccess, musaErrorInvalidValue musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muMipmappedArrayDestroy

Parameters:

  • musaMipmappedArray_t mipmappedArray: - Pointer to mipmapped array to free

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMalloc, musaMallocPitch, musaFree, musaMallocArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, muMipmappedArrayDestroy

musaGetMipmappedArrayLevel

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetMipmappedArrayLevel(musaArray_t *levelArray, musaMipmappedArray_const_t mipmappedArray, unsigned int level)

Gets a mipmap level of a MUSA mipmapped array.

Returns in *levelArray a MUSA array that represents a single mipmap level of the MUSA mipmapped array mipmappedArray. If level is greater than the maximum number of levels in this mipmapped array, musaErrorInvalidValue is returned. If mipmappedArray is NULL, musaErrorInvalidResourceHandle is returned. levelArray - Returned mipmap level MUSA array mipmappedArray - MUSA mipmapped array level - Mipmap level musaSuccess, musaErrorInvalidValue musaErrorInvalidResourceHandle musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muMipmappedArrayGetLevel

Parameters:

  • musaArray_t * levelArray: - Returned mipmap level MUSA array
  • musaMipmappedArray_const_t mipmappedArray: - MUSA mipmapped array
  • unsigned int level: - Mipmap level

Returns:

musaSuccess, musaErrorInvalidValue musaErrorInvalidResourceHandle

See also:

musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muMipmappedArrayGetLevel

musaMalloc3DArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMalloc3DArray(musaArray_t *array, const struct musaChannelFormatDesc *desc, struct musaExtent extent, unsigned int flags __dv(0))

Allocate an array on the device.

Allocates a MUSA array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA array in *array. The musaChannelFormatDesc is defined as: struct musaChannelFormatDesc { int x, y, z, w; enum musaChannelFormatKind f; }; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat. musaMalloc3DArray() can allocate the following: A 1D array is allocated if the height and depth extents are both zero. A 2D array is allocated if only the depth extent is zero. A 3D array is allocated if all three extents are non-zero. A 1D layered MUSA array is allocated if only the height extent is zero and the musaArrayLayered flag is set. Each layer is a 1D array. The number of layers is determined by the depth extent. A 2D layered MUSA array is allocated if all three extents are non-zero and the musaArrayLayered flag is set. Each layer is a 2D array. The number of layers is determined by the depth extent. A cubemap MUSA array is allocated if all three extents are non-zero and the musaArrayCubemap flag is set. Width must be equal to height, and depth must be six. A cubemap is a special type of 2D layered MUSA array, where the six layers represent the six faces of a cube. The order of the six layers in memory is the same as that listed in musaGraphicsCubeFace. A cubemap layered MUSA array is allocated if all three extents are non-zero, and both, musaArrayCubemap and musaArrayLayered flags are set. Width must be equal to height, and depth must be a multiple of six. A cubemap layered MUSA array is a special type of 2D layered MUSA array that consists of a collection of cubemaps. The first six layers represent the first cubemap, the next six layers form the second cubemap, and so on. The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default array allocation musaArrayLayered: Allocates a layered MUSA array, with the depth extent indicating the number of layers musaArrayCubemap: Allocates a cubemap MUSA array. Width must be equal to height, and depth must be six. If the musaArrayLayered flag is also set, depth must be a multiple of six. musaArraySurfaceLoadStore: Allocates a MUSA array that could be read from or written to using a surface reference. musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the MUSA array. Texture gather can only be performed on 2D MUSA arrays. musaArraySparse: Allocates a MUSA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. This flag can only be used for creating 2D, 3D or 2D layered sparse MUSA arrays. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate. The width, height and depth extents must meet certain size requirements as listed in the following table. All values are specified in elements. Note that 2D MUSA arrays have different size requirements if the musaArrayTextureGather flag is set. In that case, the valid range for (width, height, depth) is ((1,maxTexture2DGather[0]), (1,maxTexture2DGather[1]), 0). MUSA array type Valid extents that must always be met {(width range in elements), (height range), (depth range)} Valid extents with musaArraySurfaceLoadStore set {(width range in elements), (height range), (depth range)} 1D { (1,maxTexture1D), 0, 0 } { (1,maxSurface1D), 0, 0 } 2D { (1,maxTexture2D[0]), (1,maxTexture2D[1]), 0 } { (1,maxSurface2D[0]), (1,maxSurface2D[1]), 0 } 3D { (1,maxTexture3D[0]), (1,maxTexture3D[1]), (1,maxTexture3D[2]) } OR { (1,maxTexture3DAlt[0]), (1,maxTexture3DAlt[1]), (1,maxTexture3DAlt[2]) } { (1,maxSurface3D[0]), (1,maxSurface3D[1]), (1,maxSurface3D[2]) } 1D Layered { (1,maxTexture1DLayered[0]), 0, (1,maxTexture1DLayered[1]) } { (1,maxSurface1DLayered[0]), 0, (1,maxSurface1DLayered[1]) } 2D Layered { (1,maxTexture2DLayered[0]), (1,maxTexture2DLayered[1]), (1,maxTexture2DLayered[2]) } { (1,maxSurface2DLayered[0]), (1,maxSurface2DLayered[1]), (1,maxSurface2DLayered[2]) } Cubemap { (1,maxTextureCubemap), (1,maxTextureCubemap), 6 } { (1,maxSurfaceCubemap), (1,maxSurfaceCubemap), 6 } Cubemap Layered { (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[0]), (1,maxTextureCubemapLayered[1]) } { (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[0]), (1,maxSurfaceCubemapLayered[1]) } array - Pointer to allocated array in device memory desc - Requested channel format extent - Requested allocation size (width field in elements) flags - Flags for extensions musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muArray3DCreate

Parameters:

  • musaArray_t * array: - Pointer to allocated array in device memory
  • const struct musaChannelFormatDesc * desc: - Requested channel format
  • struct musaExtent extent: - Requested allocation size (width field in elements)
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMalloc3D, musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaHostAlloc, make_musaExtent, muArray3DCreate

musaMallocArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocArray(musaArray_t *array, const struct musaChannelFormatDesc *desc, size_t width, size_t height __dv(0), unsigned int flags __dv(0))

Allocate an array on the device.

Allocates a MUSA array according to the musaChannelFormatDesc structure desc and returns a handle to the new MUSA array in *array. The musaChannelFormatDesc is defined as: struct musaChannelFormatDesc { int x, y, z, w; enum musaChannelFormatKind f; }; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat. The flags parameter enables different options to be specified that affect the allocation, as follows. musaArrayDefault: This flag's value is defined to be 0 and provides default array allocation musaArraySurfaceLoadStore: Allocates an array that can be read from or written to using a surface reference musaArrayTextureGather: This flag indicates that texture gather operations will be performed on the array. musaArraySparse: Allocates a MUSA array without physical backing memory. The subregions within this sparse array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate. musaArrayDeferredMapping: Allocates a MUSA array without physical backing memory. The entire array can later be mapped onto a physical memory allocation by calling muMemMapArrayAsync. The physical backing memory must be allocated via muMemCreate. width and height must meet certain size requirements. See musaMalloc3DArray() for more details. array - Pointer to allocated array in device memory desc - Requested channel format width - Requested array allocation width height - Requested array allocation height flags - Requested properties of allocated array musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muArrayCreate

Parameters:

  • musaArray_t * array: - Pointer to allocated array in device memory
  • const struct musaChannelFormatDesc * desc: - Requested channel format
  • size_t width: - Requested array allocation width
  • size_t height __dv
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation

See also:

musaMalloc, musaMallocPitch, musaFree, musaFreeArray, musaMallocHost (C API), musaFreeHost, musaMalloc3D, musaMalloc3DArray, musaHostAlloc, muArrayCreate

musaMemAdvise

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemAdvise(const void *devPtr, size_t count, enum musaMemoryAdvise advice, int device)

Advise about the usage of a given memory range.

Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The memory range could also refer to system-allocated pageable memory provided it represents a valid, host-accessible region of memory and all additional constraints imposed by advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being returned. The advice parameter can take the following values: musaMemAdviseSetReadMostly: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally, if musaMemPrefetchAsync is called on this region, it will create a read-only copy of the data on the destination processor. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. The device argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Also, if a context is created on a device that does not have the device attribute musaDevAttrConcurrentManagedAccess set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then setting this advice will not create a read-only copy when that device accesses this memory region. musaMemAdviceUnsetReadMostly: Undoes the effect of musaMemAdviceReadMostly and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. musaMemAdviseSetPreferredLocation: This advice sets the preferred location for the data to be the memory belonging to device. Passing in musaCpuDeviceId for device sets the preferred location as host memory. If device is a GPU, then it must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using musaMemPrefetchAsync. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from device will not result in a read-only copy being created on that device as outlined in description for the advice musaMemAdviseSetReadMostly. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. musaMemAdviseUnsetPreferredLocation: Undoes the effect of musaMemAdviseSetPreferredLocation and changes the preferred location to none. musaMemAdviseSetAccessedBy: This advice implies that the data will be accessed by device. Passing in musaCpuDeviceId for device will set the advice for the CPU. If device is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the musaMemAdviceSetAccessedBy flag set for this data will now have its mapping updated to point to the page in host memory. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also device, then the policies associated with musaMemAdviseSetPreferredLocation will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if device has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. musaMemAdviseUnsetAccessedBy: Undoes the effect of musaMemAdviseSetAccessedBy. Any mappings to the data from device may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, then device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if device has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. devPtr - Pointer to memory to set the advice for count - Size in bytes of the memory range advice - Advice to be applied for the specified memory range device - Device to apply the advice for musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemPrefetchAsync, muMemAdvise

Parameters:

  • const void * devPtr: - Pointer to memory to set the advice for
  • size_t count: - Size in bytes of the memory range
  • enum musaMemoryAdvise advice: - Advice to be applied for the specified memory range
  • int device: - Device to apply the advice for

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemPrefetchAsync, muMemAdvise

musaMemAdvise_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemAdvise_v2(const void *devPtr, size_t count, enum musaMemoryAdvise advice, struct musaMemLocation location)

Advise about the usage of a given memory range.

Advise the Unified Memory subsystem about the usage pattern for the memory range starting at devPtr with a size of count bytes. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the advice is applied. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The memory range could also refer to system-allocated pageable memory provided it represents a valid, host-accessible region of memory and all additional constraints imposed by advice as outlined below are also satisfied. Specifying an invalid system-allocated pageable memory range results in an error being returned. The advice parameter can take the following values: musaMemAdviseSetReadMostly: This implies that the data is mostly going to be read from and only occasionally written to. Any read accesses from any processor to this region will create a read-only copy of at least the accessed pages in that processor's memory. Additionally, if musaMemPrefetchAsync or musaMemPrefetchAsync_v2 is called on this region, it will create a read-only copy of the data on the destination processor. If the target location for musaMemPrefetchAsync_v2 is a host NUMA node and a read-only copy already exists on another host NUMA node, that copy will be migrated to the targeted host NUMA node. If any processor writes to this region, all copies of the corresponding page will be invalidated except for the one where the write occurred. If the writing processor is the CPU and the preferred location of the page is a host NUMA node, then the page will also be migrated to that host NUMA node. The location argument is ignored for this advice. Note that for a page to be read-duplicated, the accessing processor must either be the CPU or a GPU that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Also, if a context is created on a device that does not have the device attribute musaDevAttrConcurrentManagedAccess set, then read-duplication will not occur until all such contexts are destroyed. If the memory region refers to valid system-allocated pageable memory, then the accessing device must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess for a read-only copy to be created on that device. Note however that if the accessing device also has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then setting this advice will not create a read-only copy when that device accesses this memory region. musaMemAdviceUnsetReadMostly: Undoes the effect of musaMemAdviseSetReadMostly and also prevents the Unified Memory driver from attempting heuristic read-duplication on the memory range. Any read-duplicated copies of the data will be collapsed into a single copy. The location for the collapsed copy will be the preferred location if the page has a preferred location and one of the read-duplicated copies was resident at that location. Otherwise, the location chosen is arbitrary. Note: The location argument is ignored for this advice. musaMemAdviseSetPreferredLocation: This advice sets the preferred location for the data to be the memory belonging to location. When musaMemLocationtype is musaMemLocationTypeHost, musaMemLocationid is ignored and the preferred location is set to be host memory. To set the preferred location to a specific host NUMA node, applications must set musaMemLocationtype to musaMemLocationTypeHostNuma and musaMemLocationid must specify the NUMA ID of the host NUMA node. If musaMemLocationtype is set to musaMemLocationTypeHostNumaCurrent, musaMemLocationid will be ignored and the host NUMA node closest to the calling thread's CPU will be used as the preferred location. If musaMemLocationtype is a musaMemLocationTypeDevice, then musaMemLocationid must be a valid device ordinal and the device must have a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. Setting the preferred location does not cause data to migrate to that location immediately. Instead, it guides the migration policy when a fault occurs on that memory region. If the data is already in its preferred location and the faulting processor can establish a mapping without requiring the data to be migrated, then data migration will be avoided. On the other hand, if the data is not in its preferred location or if a direct mapping cannot be established, then it will be migrated to the processor accessing it. It is important to note that setting the preferred location does not prevent data prefetching done using musaMemPrefetchAsync. Having a preferred location can override the page thrash detection and resolution logic in the Unified Memory driver. Normally, if a page is detected to be constantly thrashing between for example host and device memory, the page may eventually be pinned to host memory by the Unified Memory driver. But if the preferred location is set as device memory, then the page will continue to thrash indefinitely. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice, unless read accesses from location will not result in a read-only copy being created on that procesor as outlined in description for the advice musaMemAdviseSetReadMostly. If the memory region refers to valid system-allocated pageable memory, and musaMemLocationtype is musaMemLocationTypeDevice then musaMemLocationid must be a valid device that has a non-zero alue for the device attribute musaDevAttrPageableMemoryAccess. musaMemAdviseUnsetPreferredLocation: Undoes the effect of musaMemAdviseSetPreferredLocation and changes the preferred location to none. The location argument is ignored for this advice. musaMemAdviseSetAccessedBy: This advice implies that the data will be accessed by processor location. The musaMemLocationtype must be either musaMemLocationTypeDevice with musaMemLocationid representing a valid device ordinal or musaMemLocationTypeHost and musaMemLocationid will be ignored. All other location types are invalid. If musaMemLocationid is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. This advice does not cause data migration and has no impact on the location of the data per se. Instead, it causes the data to always be mapped in the specified processor's page tables, as long as the location of the data permits a mapping to be established. If the data gets migrated for any reason, the mappings are updated accordingly. This advice is recommended in scenarios where data locality is not important, but avoiding faults is. Consider for example a system containing multiple GPUs with peer-to-peer access enabled, where the data located on one GPU is occasionally accessed by peer GPUs. In such scenarios, migrating data over to the other GPUs is not as important because the accesses are infrequent and the overhead of migration may be too high. But preventing faults can still help improve performance, and so having a mapping set up in advance is useful. Note that on CPU access of this data, the data may be migrated to host memory because the CPU typically cannot access device memory directly. Any GPU that had the musaMemAdviseSetAccessedBy flag set for this data will now have its mapping updated to point to the page in host memory. If musaMemAdviseSetReadMostly is also set on this memory region or any subset of it, then the policies associated with that advice will override the policies of this advice. Additionally, if the preferred location of this memory region or any subset of it is also location, then the policies associated with MU_MEM_ADVISE_SET_PREFERRED_LOCATION will override the policies of this advice. If the memory region refers to valid system-allocated pageable memory, and musaMemLocationtype is musaMemLocationTypeDevice then device in musaMemLocationid must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if musaMemLocationid has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. MU_MEM_ADVISE_UNSET_ACCESSED_BY: Undoes the effect of musaMemAdviseSetAccessedBy. Any mappings to the data from location may be removed at any time causing accesses to result in non-fatal page faults. If the memory region refers to valid system-allocated pageable memory, and musaMemLocationtype is musaMemLocationTypeDevice then device in musaMemLocationid must have a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. Additionally, if musaMemLocationid has a non-zero value for the device attribute musaDevAttrPageableMemoryAccessUsesHostPageTables, then this call has no effect. devPtr - Pointer to memory to set the advice for count - Size in bytes of the memory range advice - Advice to be applied for the specified memory range location - location to apply the advice for musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemPrefetchAsync, muMemAdvise, muMemAdvise_v2

Parameters:

  • const void * devPtr: - Pointer to memory to set the advice for
  • size_t count: - Size in bytes of the memory range
  • enum musaMemoryAdvise advice: - Advice to be applied for the specified memory range
  • struct musaMemLocation location: - location to apply the advice for

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemPrefetchAsync, muMemAdvise, muMemAdvise_v2

musaMemPrefetchAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPrefetchAsync(const void *devPtr, size_t count, int dstDevice, musaStream_t stream __dv(0))

Prefetches memory to the specified destination device.

Prefetches memory to the specified destination device. devPtr is the base device pointer of the memory to be prefetched and dstDevice is the destination device. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables, or it may also refer to system-allocated memory on systems with non-zero musaDevAttrPageableMemoryAccess. Passing in musaCpuDeviceId for dstDevice will prefetch the data to host memory. If dstDevice is a GPU, then the device attribute musaDevAttrConcurrentManagedAccess must be non-zero. Additionally, stream must be associated with a device that has a non-zero value for the device attribute musaDevAttrConcurrentManagedAccess. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the prefetch operation is enqueued in the stream. If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other musaMallocManaged allocations to host memory in order to make room. Device memory allocated using musaMalloc or musaMallocArray will not be evicted. By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are only setup on dstDevice. The exact behavior however also depends on the settings applied to this memory range via musaMemAdvise as described below: If musaMemAdviseSetReadMostly was set on any subset of this memory range, then that subset will create a read-only copy of the pages on dstDevice. If musaMemAdviseSetPreferredLocation was called on any subset of this memory range, then the pages will be migrated to dstDevice even if dstDevice is not the preferred location of any pages in the memory range. If musaMemAdviseSetAccessedBy was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared. Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated. Note that this function is asynchronous with respect to the host and all work on other devices. devPtr - Pointer to be prefetched count - Size in bytes dstDevice - Destination device to prefetch to stream - Stream to enqueue prefetch operation musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemAdvise, musaMemAdvise_v2 muMemPrefetchAsync

Parameters:

  • const void * devPtr: - Pointer to be prefetched
  • size_t count: - Size in bytes
  • int dstDevice: - Destination device to prefetch to
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemAdvise, musaMemAdvise_v2 muMemPrefetchAsync

musaMemPrefetchAsync_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPrefetchAsync_v2(const void *devPtr, size_t count, struct musaMemLocation location, unsigned int flags, musaStream_t stream __dv(0))

Prefetches memory to the specified destination location.

Prefetches memory to the specified destination location. devPtr is the base device pointer of the memory to be prefetched and location specifies the destination location. count specifies the number of bytes to copy. stream is the stream in which the operation is enqueued. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables, or it may also refer to system-allocated memory on systems with non-zero musaDevAttrPageableMemoryAccess. Specifying musaMemLocationTypeDevice for musaMemLocationtype will prefetch memory to GPU specified by device ordinal musaMemLocationid which must have non-zero value for the device attribute concurrentManagedAccess. Additionally, stream must be associated with a device that has a non-zero value for the device attribute concurrentManagedAccess. Specifying musaMemLocationTypeHost as musaMemLocationtype will prefetch data to host memory. Applications can request prefetching memory to a specific host NUMA node by specifying musaMemLocationTypeHostNuma for musaMemLocationtype and a valid host NUMA node id in musaMemLocationid Users can also request prefetching memory to the host NUMA node closest to the current thread's CPU by specifying musaMemLocationTypeHostNumaCurrent for musaMemLocationtype. Note when musaMemLocationtype is etiher musaMemLocationTypeHost OR musaMemLocationTypeHostNumaCurrent, musaMemLocationid will be ignored. The start address and end address of the memory range will be rounded down and rounded up respectively to be aligned to CPU page size before the prefetch operation is enqueued in the stream. If no physical memory has been allocated for this region, then this memory region will be populated and mapped on the destination device. If there's insufficient memory to prefetch the desired region, the Unified Memory driver may evict pages from other musaMallocManaged allocations to host memory in order to make room. Device memory allocated using musaMalloc or musaMallocArray will not be evicted. By default, any mappings to the previous location of the migrated pages are removed and mappings for the new location are only setup on the destination location. The exact behavior however also depends on the settings applied to this memory range via muMemAdvise as described below: If musaMemAdviseSetReadMostly was set on any subset of this memory range, then that subset will create a read-only copy of the pages on destination location. If however the destination location is a host NUMA node, then any pages of that subset that are already in another host NUMA node will be transferred to the destination. If musaMemAdviseSetPreferredLocation was called on any subset of this memory range, then the pages will be migrated to location even if location is not the preferred location of any pages in the memory range. If musaMemAdviseSetAccessedBy was called on any subset of this memory range, then mappings to those pages from all the appropriate processors are updated to refer to the new location if establishing such a mapping is possible. Otherwise, those mappings are cleared. Note that this API is not required for functionality and only serves to improve performance by allowing the application to migrate data to a suitable location before it is accessed. Memory accesses to this range are always coherent and are allowed even when the data is actively being migrated. Note that this function is asynchronous with respect to the host and all work on other devices. devPtr - Pointer to be prefetched count - Size in bytes location - location to prefetch to flags - flags for future use, must be zero now. stream - Stream to enqueue prefetch operation musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemAdvise, musaMemAdvise_v2 muMemPrefetchAsync

Parameters:

  • const void * devPtr: - Pointer to be prefetched
  • size_t count: - Size in bytes
  • struct musaMemLocation location: - location to prefetch to
  • unsigned int flags: - flags for future use, must be zero now.
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, musaMemAdvise, musaMemAdvise_v2 muMemPrefetchAsync

musaMemRangeGetAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemRangeGetAttribute(void *data, size_t dataSize, enum musaMemRangeAttribute attribute, const void *devPtr, size_t count)

Query an attribute of a given memory range.

Query an attribute about the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The attribute parameter can take the following values: musaMemRangeAttributeReadMostly: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be 1 if all pages in the given memory range have read-duplication enabled, or 0 otherwise. musaMemRangeAttributePreferredLocation: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be a GPU device id if all pages in the memory range have that GPU as their preferred location, or it will be musaCpuDeviceId if all pages in the memory range have the CPU as their preferred location, or it will be musaInvalidDeviceId if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all. Note that the actual location of the pages in the memory range at the time of the query may be different from the preferred location. musaMemRangeAttributeAccessedBy: If this attribute is specified, data will be interpreted as an array of 32-bit integers, and dataSize must be a non-zero multiple of 4. The result returned will be a list of device ids that had musaMemAdviceSetAccessedBy set for that entire memory range. If any device does not have that advice set for the entire memory range, that device will not be included. If data is larger than the number of devices that have that advice set for that memory range, musaInvalidDeviceId will be returned in all the extra space provided. For ex., if dataSize is 12 (i.e. data has 3 elements) and only device 0 has the advice set, then the result returned will be { 0, musaInvalidDeviceId, musaInvalidDeviceId }. If data is smaller than the number of devices that have that advice set, then only as many devices will be returned as can fit in the array. There is no guarantee on which specific devices will be returned, however. musaMemRangeAttributeLastPrefetchLocation: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. The result returned will be the last location to which all pages in the memory range were prefetched explicitly via musaMemPrefetchAsync. This will either be a GPU id or musaCpuDeviceId depending on whether the last location for prefetch was a GPU or the CPU respectively. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, musaInvalidDeviceId will be returned. Note that this simply returns the last location that the applicaton requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun. musaMemRangeAttributePreferredLocationType: If this attribute is specified, data will be interpreted as a musaMemLocationType, and dataSize must be sizeof(musaMemLocationType). The musaMemLocationType returned will be musaMemLocationTypeDevice if all pages in the memory range have the same GPU as their preferred location, or musaMemLocationType will be musaMemLocationTypeHost if all pages in the memory range have the CPU as their preferred location, or or it will be musaMemLocationTypeHostNuma if all the pages in the memory range have the same host NUMA node ID as their preferred location or it will be musaMemLocationTypeInvalid if either all the pages don't have the same preferred location or some of the pages don't have a preferred location at all. Note that the actual location type of the pages in the memory range at the time of the query may be different from the preferred location type. musaMemRangeAttributePreferredLocationId: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the musaMemRangeAttributePreferredLocationType query for the same address range returns musaMemLocationTypeDevice, it will be a valid device ordinal or if it returns musaMemLocationTypeHostNuma, it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored. musaMemRangeAttributeLastPrefetchLocationType: If this attribute is specified, data will be interpreted as a musaMemLocationType, and dataSize must be sizeof(musaMemLocationType). The result returned will be the last location type to which all pages in the memory range were prefetched explicitly via muMemPrefetchAsync. The musaMemLocationType returned will be musaMemLocationTypeDevice if the last prefetch location was the GPU or musaMemLocationTypeHost if it was the CPU or musaMemLocationTypeHostNuma if the last prefetch location was a specific host NUMA node. If any page in the memory range was never explicitly prefetched or if all pages were not prefetched to the same location, CUmemLocationType will be musaMemLocationTypeInvalid. Note that this simply returns the last location type that the application requested to prefetch the memory range to. It gives no indication as to whether the prefetch operation to that location has completed or even begun. musaMemRangeAttributeLastPrefetchLocationId: If this attribute is specified, data will be interpreted as a 32-bit integer, and dataSize must be 4. If the musaMemRangeAttributeLastPrefetchLocationType query for the same address range returns musaMemLocationTypeDevice, it will be a valid device ordinal or if it returns musaMemLocationTypeHostNuma, it will be a valid host NUMA node ID or if it returns any other location type, the id should be ignored. data - A pointers to a memory location where the result of each attribute query will be written to. dataSize - Array containing the size of data attribute - The attribute to query devPtr - Start of the range to query count - Size of the range to query musaSuccess, musaErrorInvalidValue musaMemRangeGetAttributes, musaMemPrefetchAsync, musaMemAdvise, muMemRangeGetAttribute

Parameters:

  • void * data: - A pointers to a memory location where the result of each attribute query will be written to.
  • size_t dataSize: - Array containing the size of data
  • enum musaMemRangeAttribute attribute: - The attribute to query
  • const void * devPtr: - Start of the range to query
  • size_t count: - Size of the range to query

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemRangeGetAttributes, musaMemPrefetchAsync, musaMemAdvise, muMemRangeGetAttribute

musaMemRangeGetAttributes

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemRangeGetAttributes(void **data, size_t *dataSizes, enum musaMemRangeAttribute *attributes, size_t numAttributes, const void *devPtr, size_t count)

Query attributes of a given memory range.

Query attributes of the memory range starting at devPtr with a size of count bytes. The memory range must refer to managed memory allocated via musaMallocManaged or declared via managed variables. The attributes array will be interpreted to have numAttributes entries. The dataSizes array will also be interpreted to have numAttributes entries. The results of the query will be stored in data. The list of supported attributes are given below. Please refer to musaMemRangeGetAttribute for attribute descriptions and restrictions. musaMemRangeAttributeReadMostly musaMemRangeAttributePreferredLocation musaMemRangeAttributeAccessedBy musaMemRangeAttributeLastPrefetchLocation:: musaMemRangeAttributePreferredLocationType:: musaMemRangeAttributePreferredLocationId:: musaMemRangeAttributeLastPrefetchLocationType:: musaMemRangeAttributeLastPrefetchLocationId data - A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written to. dataSizes - Array containing the sizes of each result attributes - An array of attributes to query (numAttributes and the number of attributes in this array should match) numAttributes - Number of attributes to query devPtr - Start of the range to query count - Size of the range to query musaSuccess, musaErrorInvalidValue musaMemRangeGetAttribute, musaMemAdvise, musaMemPrefetchAsync, muMemRangeGetAttributes

Parameters:

  • void ** data: - A two-dimensional array containing pointers to memory locations where the result of each attribute query will be written to.
  • size_t * dataSizes: - Array containing the sizes of each result
  • enum musaMemRangeAttribute * attributes: - An array of attributes to query (numAttributes and the number of attributes in this array should match)
  • size_t numAttributes: - Number of attributes to query
  • const void * devPtr: - Start of the range to query
  • size_t count: - Size of the range to query

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaMemRangeGetAttribute, musaMemAdvise, musaMemPrefetchAsync, muMemRangeGetAttributes

musaMemcpyFromSymbol

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyFromSymbol(void *dst, const void *symbol, size_t count, size_t offset __dv(0), enum musaMemcpyKind kind __dv(musaMemcpyDeviceToHost))

Copies data from the given symbol on the device.

Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. dst - Destination memory address symbol - Device symbol address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy, muMemcpyDtoH, muMemcpyDtoD

Parameters:

  • void * dst: - Destination memory address
  • const void * symbol: - Device symbol address
  • size_t count: - Size in bytes to copy
  • size_t offset __dv
  • enum musaMemcpyKind kind __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy, muMemcpyDtoH, muMemcpyDtoD

musaMemcpyFromSymbolAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyFromSymbolAsync(void *dst, const void *symbol, size_t count, size_t offset, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data from the given symbol on the device.

Copies count bytes from the memory area pointed to by offset bytes from the start of symbol symbol to the memory area pointed to by dst. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyDeviceToHost, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. musaMemcpyFromSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyDeviceToHost and stream is non-zero, the copy may overlap with operations in other streams. dst - Destination memory address symbol - Device symbol address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, muMemcpyAsync, muMemcpyDtoHAsync, muMemcpyDtoDAsync

Parameters:

  • void * dst: - Destination memory address
  • const void * symbol: - Device symbol address
  • size_t count: - Size in bytes to copy
  • size_t offset: - Offset from start of symbol in bytes
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, muMemcpyAsync, muMemcpyDtoHAsync, muMemcpyDtoDAsync

musaMemcpyToSymbol

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyToSymbol(const void *symbol, const void *src, size_t count, size_t offset __dv(0), enum musaMemcpyKind kind __dv(musaMemcpyHostToDevice))

Copies data to the given symbol on the device.

Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. symbol - Device symbol address src - Source memory address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy, muMemcpyHtoD, muMemcpyDtoD

Parameters:

  • const void * symbol: - Device symbol address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • size_t offset __dv
  • enum musaMemcpyKind kind __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyToSymbolAsync, musaMemcpyFromSymbolAsync, muMemcpy, muMemcpyHtoD, muMemcpyDtoD

musaMemcpyToSymbolAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyToSymbolAsync(const void *symbol, const void *src, size_t count, size_t offset, enum musaMemcpyKind kind, musaStream_t stream __dv(0))

Copies data to the given symbol on the device.

Copies count bytes from the memory area pointed to by src to the memory area pointed to by offset bytes from the start of symbol symbol. The memory areas may not overlap. symbol is a variable that resides in global or constant memory space. kind can be either musaMemcpyHostToDevice, musaMemcpyDeviceToDevice, or musaMemcpyDefault. Passing musaMemcpyDefault is recommended, in which case the type of transfer is inferred from the pointer values. However, musaMemcpyDefault is only allowed on systems that support unified virtual addressing. musaMemcpyToSymbolAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is musaMemcpyHostToDevice and stream is non-zero, the copy may overlap with operations in other streams. symbol - Device symbol address src - Source memory address count - Size in bytes to copy offset - Offset from start of symbol in bytes kind - Type of transfer stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyFromSymbolAsync, muMemcpyAsync, muMemcpyHtoDAsync, muMemcpyDtoDAsync

Parameters:

  • const void * symbol: - Device symbol address
  • const void * src: - Source memory address
  • size_t count: - Size in bytes to copy
  • size_t offset: - Offset from start of symbol in bytes
  • enum musaMemcpyKind kind: - Type of transfer
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidSymbol, musaErrorInvalidMemcpyDirection, musaErrorNoKernelImageForDevice

See also:

musaMemcpy, musaMemcpy2D, musaMemcpy2DToArray, musaMemcpy2DFromArray, musaMemcpy2DArrayToArray, musaMemcpyToSymbol, musaMemcpyFromSymbol, musaMemcpyAsync, musaMemcpy2DAsync, musaMemcpy2DToArrayAsync, musaMemcpy2DFromArrayAsync, musaMemcpyFromSymbolAsync, muMemcpyAsync, muMemcpyHtoDAsync, muMemcpyDtoDAsync

musaMemcpyPeer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyPeer(void *dst, int dstDevice, const void *src, int srcDevice, size_t count)

Copies memory between two devices.

Copies memory from one device to memory on another device. dst is the base device pointer of the destination memory and dstDevice is the destination device. src is the base device pointer of the source memory and srcDevice is the source device. count specifies the number of bytes to copy. Note that this function is asynchronous with respect to the host, but serialized with respect all pending and future asynchronous work in to the current device, srcDevice, and dstDevice (use musaMemcpyPeerAsync to avoid this synchronization). dst - Destination device pointer dstDevice - Destination device src - Source device pointer srcDevice - Source device count - Size of memory copy in bytes musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpyPeer

Parameters:

  • void * dst: - Destination device pointer
  • int dstDevice: - Destination device
  • const void * src: - Source device pointer
  • int srcDevice: - Source device
  • size_t count: - Size of memory copy in bytes

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyAsync, musaMemcpyPeerAsync, musaMemcpy3DPeerAsync, muMemcpyPeer

musaMemcpyPeerAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemcpyPeerAsync(void *dst, int dstDevice, const void *src, int srcDevice, size_t count, musaStream_t stream __dv(0))

Copies memory between two devices asynchronously.

Copies memory from one device to memory on another device. dst is the base device pointer of the destination memory and dstDevice is the destination device. src is the base device pointer of the source memory and srcDevice is the source device. count specifies the number of bytes to copy. Note that this function is asynchronous with respect to the host and all work on other devices. dst - Destination device pointer dstDevice - Destination device src - Source device pointer srcDevice - Source device count - Size of memory copy in bytes stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, muMemcpyPeerAsync

Parameters:

  • void * dst: - Destination device pointer
  • int dstDevice: - Destination device
  • const void * src: - Source device pointer
  • int srcDevice: - Source device
  • size_t count: - Size of memory copy in bytes
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDevice

See also:

musaMemcpy, musaMemcpyPeer, musaMemcpyAsync, musaMemcpy3DPeerAsync, muMemcpyPeerAsync

musaMallocFromPoolAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocFromPoolAsync(void **ptr, size_t size, musaMemPool_t memPool, musaStream_t stream)

Allocates memory from a specified pool with stream ordered semantics.

Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in *dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the specified memory pool. The specified memory pool may be from a device different than that of the specified hStream. Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and MUSA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs. During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters. ptr - Returned device pointer bytesize - Number of bytes to allocate memPool - The pool to allocate from stream - The stream establishing the stream ordering semantic musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory muMemAllocFromPoolAsync, musaMallocAsync (C++ API), musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaMemPoolCreate, musaMemPoolSetAccess, musaMemPoolSetAttribute

Parameters:

  • void ** ptr: - Returned device pointer
  • size_t size
  • musaMemPool_t memPool: - The pool to allocate from
  • musaStream_t stream: - The stream establishing the stream ordering semantic

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory

See also:

muMemAllocFromPoolAsync, musaMallocAsync (C++ API), musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaMemPoolCreate, musaMemPoolSetAccess, musaMemPoolSetAttribute

musaMemoryAtomicAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemoryAtomicAsync(void *dst, const void *src, size_t elementCount, enum musaAtomicType operation, musaStream_t stream __dv(0))

Memory atomic from Device to Device.

Perform memory atomic operation from device memory to device memory. dst and src are base pointers of the destination and source, respectively. elementCount specifies the number of elements to perform memory atomic. dst - Destination device pointer src - Source device pointer elementCount - Size of memory atomic in elements operation - Specifies which atomic operation to perform, include element size. stream - Stream identifier musaSuccess, musaErrorInvalidValue, muMemoryAtomicAsync

Parameters:

  • void * dst: - Destination device pointer
  • const void * src: - Source device pointer
  • size_t elementCount: - Size of memory atomic in elements
  • enum musaAtomicType operation: - Specifies which atomic operation to perform, include element size.
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muMemoryAtomicAsync

musaMemoryAtomicValueAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemoryAtomicValueAsync(void *dst, size_t value, enum musaAtomicValueType operation, musaStream_t stream __dv(0))

Memory atomic value.

Perform memory atomic value operation to device memory range of 64-bit values. dst - Destination device pointer value - data value for the atomic operation operation - Specifies which atomic operation to perform. stream - Stream identifier musaSuccess, musaErrorInvalidValue, muMemoryAtomicValueAsync

Parameters:

  • void * dst: - Destination device pointer
  • size_t value: - data value for the atomic operation
  • enum musaAtomicValueType operation: - Specifies which atomic operation to perform.
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muMemoryAtomicValueAsync

musaMemoryTransfer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemoryTransfer(void *dst, const void *src, size_t count)

Copies memory from Device to Device by transfer engine.

Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst. dst - Destination device memory address src - Source device memory address count - Size in bytes to copy musaSuccess, musaErrorInvalidValue, muMemoryTransfer

Parameters:

  • void * dst: - Destination device memory address
  • const void * src: - Source device memory address
  • size_t count: - Size in bytes to copy

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muMemoryTransfer

musaMemoryTransferAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaMemoryTransferAsync(void *dst, const void *src, size_t count, musaStream_t stream __dv(0))

Copies memory from Device to Device by transfer engine asynchronously.

Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst. The memory areas may not overlap. musaMemoryTransferAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. The copy can optionally be associated to a stream by passing a non-zero stream argument. The device version of this function cannot be given local or shared pointers. dst - Destination device memory address src - Source device memory address count - Size in bytes to copy stream - Stream identifier musaSuccess, musaErrorInvalidValue, muMemoryTransferAsync

Parameters:

  • void * dst: - Destination device memory address
  • const void * src: - Source device memory address
  • size_t count: - Size in bytes to copy
  • musaStream_t stream __dv

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

muMemoryTransferAsync

musaLaunchHostFunc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLaunchHostFunc(musaStream_t stream, musaHostFn_t fn, void *userData)

Converts a double argument to be executed on a device.

d - Double to convert Deprecated This function is deprecated as of MUSA 7.5 Converts the double value of d to an internal float representation if the device does not support double arithmetic. If the device does natively support doubles, then this function does nothing. musaSuccess musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C API), musaSetDoubleForHost Converts a double argument after execution on a device Deprecated This function is deprecated as of MUSA 7.5 Converts the double value of d from a potentially internal float representation if the device does not support double arithmetic. If the device does natively support doubles, then this function does nothing. d - Double to convert musaSuccess musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C API), musaSetDoubleForDevice Enqueues a host function call in a stream Enqueues a host function to run in a stream. The function will be called after currently enqueued work and will block work added after it. The host function must not make any MUSA API calls. Attempting to use a MUSA API may result in musaErrorNotPermitted, but this is not required. The host function must not perform any synchronization that may depend on outstanding MUSA work not mandated to run earlier. Host functions without a mandated order (such as in independent streams) execute in undefined order and may be serialized. For the purposes of Unified Memory, execution makes a number of guarantees: The stream is considered idle for the duration of the function's execution. Thus, for example, the function may always use memory attached to the stream it was enqueued in. The start of execution of the function has the same effect as synchronizing an event recorded in the same stream immediately prior to the function. It thus synchronizes streams which have been "joined" prior to the function. Adding device work to any stream does not have the effect of making the stream active until all preceding host functions and stream callbacks have executed. Thus, for example, a function might use global attached memory even if work has been added to another stream, if the work has been ordered behind the function call with an event. Completion of the function does not cause a stream to become active except as described above. The stream will remain idle if no device work follows the function, and will remain idle across consecutive host functions or stream callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a host function at the end of the stream. Note that, in constrast to muStreamAddCallback, the function will not be called in the event of an error in the MUSA context. hStream - Stream to enqueue function call in fn - The function to call once preceding stream operations are complete userData - User-specified data to be passed to the function musaSuccess, musaErrorInvalidResourceHandle, musaErrorInvalidValue, musaErrorNotSupported musaStreamCreate, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamDestroy, musaMallocManaged, musaStreamAttachMemAsync, musaStreamAddCallback, muLaunchHostFunc

Parameters:

  • musaStream_t stream
  • musaHostFn_t fn: - The function to call once preceding stream operations are complete
  • void * userData: - User-specified data to be passed to the function

Returns:

musaSuccess musaSuccess musaSuccess, musaErrorInvalidResourceHandle, musaErrorInvalidValue, musaErrorNotSupported

See also:

musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C API), musaSetDoubleForHost musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C API), musaSetDoubleForDevice musaStreamCreate, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamDestroy, musaMallocManaged, musaStreamAttachMemAsync, musaStreamAddCallback, muLaunchHostFunc

musaLaunchKernel

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLaunchKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, musaStream_t stream)

Launches a device function.

The function invokes kernel func on gridDim (gridDim.x gridDim.y gridDim.z) grid of blocks. Each block contains blockDim (blockDim.x blockDim.y blockDim.z) threads. If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> sharedMem sets the amount of dynamic shared memory that will be available to each thread block. stream specifies a stream the invocation is associated to. func - Device function symbol gridDim - Grid dimentions blockDim - Block dimentions args - Arguments sharedMem - Shared memory stream - Stream identifier musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled musaLaunchKernel (C++ API), muLaunchKernel

Parameters:

  • const void * func: - Device function symbol
  • dim3 gridDim: - Grid dimentions
  • dim3 blockDim: - Block dimentions
  • void ** args: - Arguments
  • size_t sharedMem: - Shared memory
  • musaStream_t stream: - Stream identifier

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled

See also:

musaLaunchKernel (C++ API), muLaunchKernel

musaLaunchKernelExC

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLaunchKernelExC(const musaLaunchConfig_t *config, const void *func, void **args)

Launches a MUSA function with launch-time configuration.

Note that the functionally equivalent variadic template musaLaunchKernelEx is available for C++11 and newer. Invokes the kernel func on config->gridDim (config->gridDim.x config->gridDim.y config->gridDim.z) grid of blocks. Each block contains config->blockDim (config->blockDim.x config->blockDim.y config->blockDim.z) threads. config->dynamicSmemBytes sets the amount of dynamic shared memory that will be available to each thread block. config->stream specifies a stream the invocation is associated to. Configuration beyond grid and block dimensions, dynamic shared memory size, and stream can be provided with the following two fields of config: config->attrs is an array of config->numAttrs contiguous musaLaunchAttribute elements. The value of this pointer is not considered if config->numAttrs is zero. However, in that case, it is recommended to set the pointer to NULL. config->numAttrs is the number of attributes populating the first config->numAttrs positions of the config->attrs array. If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied. N.B. This function is so named to avoid unintentionally invoking the templated version, musaLaunchKernelEx, for kernels taking a single void** or void* parameter. config - Launch configuration func - Kernel to launch args - Array of pointers to kernel parameters musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled musaLaunchKernelEx(const musaLaunchConfig_t *config, void (*kernel)(ExpTypes...), ActTypes &&... args) "musaLaunchKernelEx (C++ API)", muLaunchKernelEx

Parameters:

  • const musaLaunchConfig_t * config: - Launch configuration
  • const void * func: - Kernel to launch
  • void ** args: - Array of pointers to kernel parameters

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorSharedObjectInitFailed, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorJitCompilerNotFound, musaErrorJitCompilationDisabled

See also:

musaLaunchKernelEx(const musaLaunchConfig_t *config, void (*kernel)(ExpTypes...), ActTypes &&... args) "musaLaunchKernelEx (C++ API)", muLaunchKernelEx

musaLaunchCooperativeKernel

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLaunchCooperativeKernel(const void *func, dim3 gridDim, dim3 blockDim, void **args, size_t sharedMem, musaStream_t stream)

Launches a device function where thread blocks can cooperate and synchronize as they execute.

The function invokes kernel func on gridDim (gridDim.x gridDim.y gridDim.z) grid of blocks. Each block contains blockDim (blockDim.x blockDim.y blockDim.z) threads. The device on which this kernel is invoked must have a non-zero value for the device attribute musaDevAttrCooperativeLaunch. The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned by musaOccupancyMaxActiveBlocksPerMultiprocessor (or musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attribute musaDevAttrMultiProcessorCount. The kernel cannot make use of MUSA dynamic parallelism. If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> sharedMem sets the amount of dynamic shared memory that will be available to each thread block. stream specifies a stream the invocation is associated to. func - Device function symbol gridDim - Grid dimentions blockDim - Block dimentions args - Arguments sharedMem - Shared memory stream - Stream identifier musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed musaLaunchCooperativeKernel (C++ API), musaLaunchCooperativeKernelMultiDevice, muLaunchCooperativeKernel

Parameters:

  • const void * func: - Device function symbol
  • dim3 gridDim: - Grid dimentions
  • dim3 blockDim: - Block dimentions
  • void ** args: - Arguments
  • size_t sharedMem: - Shared memory
  • musaStream_t stream: - Stream identifier

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed

See also:

musaLaunchCooperativeKernel (C++ API), musaLaunchCooperativeKernelMultiDevice, muLaunchCooperativeKernel

musaLaunchCooperativeKernelMultiDevice

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaLaunchCooperativeKernelMultiDevice(struct musaLaunchParams *launchParamsList, unsigned int numDevices, unsigned int flags __dv(0))

Launches device functions on multiple devices where thread blocks can cooperate and synchronize as they execute.

Deprecated This function is deprecated as of MUSA 11.3. Invokes kernels as specified in the launchParamsList array where each element of the array specifies all the parameters required to perform a single kernel launch. These kernels can cooperate and synchronize as they execute. The size of the array is specified by numDevices. No two kernels can be launched on the same device. All the devices targeted by this multi-device launch must be identical. All devices must have a non-zero value for the device attribute musaDevAttrCooperativeMultiDeviceLaunch. The same kernel must be launched on all devices. Note that any device or constant variables are independently instantiated on every device. It is the application's responsiblity to ensure these variables are initialized and used appropriately. The size of the grids as specified in blocks, the size of the blocks themselves and the amount of shared memory used by each thread block must also match across all launched kernels. The streams used to launch these kernels must have been created via either musaStreamCreate or musaStreamCreateWithPriority or musaStreamCreateWithPriority. The NULL stream or musaStreamLegacy or musaStreamPerThread cannot be used. The total number of blocks launched per kernel cannot exceed the maximum number of blocks per multiprocessor as returned by musaOccupancyMaxActiveBlocksPerMultiprocessor (or musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attribute musaDevAttrMultiProcessorCount. Since the total number of blocks launched per device has to match across all devices, the maximum number of blocks that can be launched per device will be limited by the device with the least number of multiprocessors. The kernel cannot make use of MUSA dynamic parallelism. The musaLaunchParams structure is defined as: struct musaLaunchParams { void *func; dim3 gridDim; dim3 blockDim; void **args; size_t sharedMem; musaStream_t stream; }; where: musaLaunchParamsfunc specifies the kernel to be launched. This same functions must be launched on all devices. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> musaLaunchParamsgridDim specifies the width, height and depth of the grid in blocks. This must match across all kernels launched. musaLaunchParamsblockDim is the width, height and depth of each thread block. This must match across all kernels launched. musaLaunchParamsargs specifies the arguments to the kernel. If the kernel has N parameters then musaLaunchParamsargs should point to array of N pointers. Each pointer, from musaLaunchParamsargs[0] to musaLaunchParamsargs[N - 1], point to the region of memory from which the actual parameter will be copied. musaLaunchParamssharedMem is the dynamic shared-memory size per thread block in bytes. This must match across all kernels launched. musaLaunchParamsstream is the handle to the stream to perform the launch in. This cannot be the NULL stream or musaStreamLegacy or musaStreamPerThread. By default, the kernel won't begin execution on any GPU until all prior work in all the specified streams has completed. This behavior can be overridden by specifying the flag musaCooperativeLaunchMultiDeviceNoPreSync. When this flag is specified, each kernel will only wait for prior work in the stream corresponding to that GPU to complete before it begins execution. Similarly, by default, any subsequent work pushed in any of the specified streams will not begin execution until the kernels on all GPUs have completed. This behavior can be overridden by specifying the flag musaCooperativeLaunchMultiDeviceNoPostSync. When this flag is specified, any subsequent work pushed in any of the specified streams will only wait for the kernel launched on the GPU corresponding to that stream to complete before it begins execution. launchParamsList - List of launch parameters, one per device numDevices - Size of the launchParamsList array flags - Flags to control launch behavior musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed musaLaunchCooperativeKernel (C++ API), musaLaunchCooperativeKernel, muLaunchCooperativeKernelMultiDevice

Parameters:

  • struct musaLaunchParams * launchParamsList: - List of launch parameters, one per device
  • unsigned int numDevices: - Size of the launchParamsList array
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidConfiguration, musaErrorLaunchFailure, musaErrorLaunchTimeout, musaErrorLaunchOutOfResources, musaErrorCooperativeLaunchTooLarge, musaErrorSharedObjectInitFailed

See also:

musaLaunchCooperativeKernel (C++ API), musaLaunchCooperativeKernel, muLaunchCooperativeKernelMultiDevice

musaGetSymbolAddress

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetSymbolAddress(void **devPtr, const void *symbol)

Finds the address associated with a MUSA symbol.

Returns in *devPtr the address of symbol symbol on the device. symbol is a variable that resides in global or constant memory space. If symbol cannot be found, or if symbol is not declared in the global or constant memory space, *devPtr is unchanged and the error musaErrorInvalidSymbol is returned. devPtr - Return device pointer associated with symbol symbol - Device symbol address musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice musaGetSymbolAddress (C++ API), musaGetSymbolSize (C API), muModuleGetGlobal

Parameters:

  • void ** devPtr: - Return device pointer associated with symbol
  • const void * symbol: - Device symbol address

Returns:

musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice

See also:

musaGetSymbolAddress (C++ API), musaGetSymbolSize (C API), muModuleGetGlobal

musaGetSymbolSize

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetSymbolSize(size_t *size, const void *symbol)

Finds the size of the object associated with a MUSA symbol.

Returns in *size the size of symbol symbol. symbol is a variable that resides in global or constant memory space. If symbol cannot be found, or if symbol is not declared in global or constant memory space, *size is unchanged and the error musaErrorInvalidSymbol is returned. size - Size of object associated with symbol symbol - Device symbol address musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice musaGetSymbolAddress (C API), musaGetSymbolSize (C++ API), muModuleGetGlobal

Parameters:

  • size_t * size: - Size of object associated with symbol
  • const void * symbol: - Device symbol address

Returns:

musaSuccess, musaErrorInvalidSymbol, musaErrorNoKernelImageForDevice

See also:

musaGetSymbolAddress (C API), musaGetSymbolSize (C++ API), muModuleGetGlobal

musaFuncGetAttributes

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaFuncGetAttributes(struct musaFuncAttributes *attr, const void *func)

Find out attributes for a given function.

This function obtains the attributes of a function specified via func. func is a device function symbol and must be declared as a global function. The fetched attributes are placed in attr. If the specified function does not exist, then it is assumed to be a musaKernel_t and used as is. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> Note that some function attributes such as maxThreadsPerBlock may vary based on the device that is currently being used. attr - Return pointer to function's attributes func - Device function symbol musaSuccess, musaErrorInvalidDeviceFunction musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C++ API), musaLaunchKernel (C API), muFuncGetAttribute

Parameters:

  • struct musaFuncAttributes * attr: - Return pointer to function's attributes
  • const void * func: - Device function symbol

Returns:

musaSuccess, musaErrorInvalidDeviceFunction

See also:

musaFuncSetCacheConfig (C API), musaFuncGetAttributes (C++ API), musaLaunchKernel (C API), muFuncGetAttribute

musaFuncGetName

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaFuncGetName(const char **name, const void *func)

Returns the function name for a device entry function pointer.

Returns in **name the function name associated with the symbol func. The function name is returned as a null-terminated string. This API may return a mangled name if the function is not declared as having C linkage. If **name is NULL, musaErrorInvalidValue is returned. If func is not a device entry function, then it is assumed to be a musaKernel_t and used as is. name - The returned name of the function func - The function pointer to retrieve name for musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction musaFuncGetName (C++ API)

Parameters:

  • const char ** name: - The returned name of the function
  • const void * func: - The function pointer to retrieve name for

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction

musaFuncGetParamInfo

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaFuncGetParamInfo(const void *func, size_t paramIndex, size_t *paramOffset, size_t *paramSize)

Returns the offset and size of a kernel parameter in the device-side parameter layout.

Queries the kernel parameter at paramIndex in func's list of parameters and returns parameter information via paramOffset and paramSize. paramOffset returns the offset of the parameter in the device-side parameter layout. paramSize returns the size in bytes of the parameter. This information can be used to update kernel node parameters from the device via musaGraphKernelNodeSetParam() and musaGraphKernelNodeUpdatesApply(). paramIndex must be less than the number of parameters that func takes. func - The function to query paramIndex - The parameter index to query paramOffset - The offset into the device-side parameter layout at which the parameter resides paramSize - The size of the parameter in the device-side parameter layout MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE,

Parameters:

  • const void * func: - The function to query
  • size_t paramIndex: - The parameter index to query
  • size_t * paramOffset: - The offset into the device-side parameter layout at which the parameter resides
  • size_t * paramSize: - The size of the parameter in the device-side parameter layout

Returns:

MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE,

musaFuncSetAttribute

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaFuncSetAttribute(const void *func, enum musaFuncAttribute attr, int value)

Set attributes for a given function.

This function sets the attributes of a function specified via func. The parameter func must be a pointer to a function that executes on the device. The parameter specified by func must be declared as a global function. The enumeration defined by attr is set to the value defined by value. If the specified function does not exist, then it is assumed to be a musaKernel_t and used as is. If the specified attribute cannot be written, or if the value is incorrect, then musaErrorInvalidValue is returned. Valid values for attr are: musaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute sharedSizeBytes cannot exceed the device attribute musaDevAttrMaxSharedMemoryPerBlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU architecture. musaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See musaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. musaFuncAttributeRequiredClusterWidth: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterHeight: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterDepth: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeNonPortableClusterSizeAllowed: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. musaFuncAttributeClusterSchedulingPolicyPreference: The block scheduling policy of a function. The value type is musaClusterSchedulingPolicy. func - Function to get attributes of attr - Attribute to set value - Value to set musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue musaLaunchKernel (C++ API), musaFuncSetCacheConfig (C++ API), musaFuncGetAttributes (C API),

Parameters:

  • const void * func: - Function to get attributes of
  • enum musaFuncAttribute attr: - Attribute to set
  • int value: - Value to set

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue

musaFuncSetCacheConfig

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaFuncSetCacheConfig(const void *func, enum musaFuncCache cacheConfig)

Sets the preferred cache configuration for a device function.

On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the function specified via func. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute func. func is a device function symbol and must be declared as a global function. If the specified function does not exist, then musaErrorInvalidDeviceFunction is returned. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> This setting does nothing on devices where the size of the L1 cache and shared memory are fixed. Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point. The supported cache configurations are: musaFuncCachePreferNone: no preference for shared memory or L1 (default) musaFuncCachePreferShared: prefer larger shared memory and smaller L1 cache musaFuncCachePreferL1: prefer larger L1 cache and smaller shared memory musaFuncCachePreferEqual: prefer equal size L1 cache and shared memory func - Device function symbol cacheConfig - Requested cache configuration musaSuccess, musaErrorInvalidDeviceFunction This API does not accept a musaKernel_t casted as void*. If cache config modification is required for a musaKernel_t (or a global function), it can be replaced with a call to musaFuncSetAttributes with the attribute musaFuncAttributePreferredSharedMemoryCarveout to specify a more granular L1 cache and shared memory split configuration. musaFuncSetCacheConfig (C++ API), musaFuncGetAttributes (C API), musaLaunchKernel (C API), muFuncSetCacheConfig

Parameters:

  • const void * func: - Device function symbol
  • enum musaFuncCache cacheConfig: - Requested cache configuration

Returns:

musaSuccess, musaErrorInvalidDeviceFunction

See also:

musaFuncSetCacheConfig (C++ API), musaFuncGetAttributes (C API), musaLaunchKernel (C API), muFuncSetCacheConfig

musaFuncSetSharedMemConfig

Header: musa_runtime_api.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaFuncSetSharedMemConfig(const void *func, enum musaSharedMemConfig config)

Sets the shared memory configuration for a device function.

Deprecated On devices with configurable shared memory banks, this function will force all subsequent launches of the specified device function to have the given shared memory bank size configuration. On any given launch of the function, the shared memory configuration of the device will be temporarily changed if needed to suit the function's preferred configuration. Changes in shared memory configuration between subsequent launches of functions, may introduce a device side synchronization point. Any per-function setting of shared memory bank size set via musaFuncSetSharedMemConfig will override the device wide setting set by musaDeviceSetSharedMemConfig. Changing the shared memory bank size will not increase shared memory usage or affect occupancy of kernels, but may have major effects on performance. Larger bank sizes will allow for greater potential bandwidth to shared memory, but will change what kinds of accesses to shared memory will result in bank conflicts. This function will do nothing on devices with fixed shared memory bank size. For templated functions, pass the function symbol as follows: func_name<template_arg_0,...,template_arg_N> The supported bank configurations are: musaSharedMemBankSizeDefault: use the device's shared memory configuration when launching this function. musaSharedMemBankSizeFourByte: set shared memory bank width to be four bytes natively when launching this function. musaSharedMemBankSizeEightByte: set shared memory bank width to be eight bytes natively when launching this function. func - Device function symbol config - Requested shared memory configuration musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue, musaDeviceSetSharedMemConfig, musaDeviceGetSharedMemConfig, musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaFuncSetCacheConfig, muFuncSetSharedMemConfig

Parameters:

  • const void * func: - Device function symbol
  • enum musaSharedMemConfig config: - Requested shared memory configuration

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue,

See also:

musaDeviceSetSharedMemConfig, musaDeviceGetSharedMemConfig, musaDeviceSetCacheConfig, musaDeviceGetCacheConfig, musaFuncSetCacheConfig, muFuncSetSharedMemConfig

musaGetFuncBySymbol

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI_CDECL musaGetFuncBySymbol(musaFunction_t *functionPtr, const void *symbolPtr)

Get pointer to device entry function that matches entry function symbolPtr.

Returns in functionPtr the device entry function corresponding to the symbol symbolPtr. functionPtr - Returns the device entry function symbolPtr - Pointer to device entry function to search for musaSuccess

Parameters:

  • musaFunction_t * functionPtr: - Returns the device entry function
  • const void * symbolPtr: - Pointer to device entry function to search for

Returns:

musaSuccess

musaDeviceRegisterAsyncNotification

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceRegisterAsyncNotification(int device, musaAsyncCallback callbackFunc, void *userData, musaAsyncCallbackHandle_t *callback)

Blocks until remote writes are visible to the specified scope.

Blocks until remote writes to the target context via mappings created through GPUDirect RDMA APIs, like mthreads_p2p_get_pages (see https://docs.mthreads.com/musa/gpudirect-rdma for more information), are visible to the specified scope. If the scope equals or lies within the scope indicated by musaDevAttrGPUDirectRDMAWritesOrdering, the call will be a no-op and can be safely omitted for performance. This can be determined by comparing the numerical values between the two enums, with smaller scopes having smaller values. Users may query support for this API via musaDevAttrGPUDirectRDMAFlushWritesOptions. target - The target of the operation, see musaFlushGPUDirectRDMAWritesTarget scope - The scope of the operation, see musaFlushGPUDirectRDMAWritesScope musaSuccess, musaErrorNotSupported, muFlushGPUDirectRDMAWrites Registers a callback function to receive async notifications Registers callbackFunc to receive async notifications. The userData parameter is passed to the callback function at async notification time. Likewise, callback is also passed to the callback function to distinguish between multiple registered callbacks. The callback function being registered should be designed to return quickly (~10ms). Any long running tasks should be queued for execution on an application thread. Callbacks may not call musaDeviceRegisterAsyncNotification or musaDeviceUnregisterAsyncNotification. Doing so will result in musaErrorNotPermitted. Async notification callbacks execute in an undefined order and may be serialized. Returns in *callback a handle representing the registered callback instance. device - The device on which to register the callback callbackFunc - The function to register as a callback userData - A generic pointer to user data. This is passed into the callback function. callback - A handle representing the registered callback instance musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown musaDeviceUnregisterAsyncNotification

Parameters:

  • int device: - The device on which to register the callback
  • musaAsyncCallback callbackFunc: - The function to register as a callback
  • void * userData: - A generic pointer to user data. This is passed into the callback function.
  • musaAsyncCallbackHandle_t * callback: - A handle representing the registered callback instance

Returns:

musaSuccess, musaErrorNotSupported, musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown

See also:

muFlushGPUDirectRDMAWrites musaDeviceUnregisterAsyncNotification

musaDeviceUnregisterAsyncNotification

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceUnregisterAsyncNotification(int device, musaAsyncCallbackHandle_t callback)

Unregisters an async notification callback.

Unregisters callback so that the corresponding callback function will stop receiving async notifications. device - The device from which to remove callback. callback - The callback instance to unregister from receiving async notifications. musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown musaDeviceRegisterAsyncNotification

Parameters:

  • int device: - The device from which to remove callback.
  • musaAsyncCallbackHandle_t callback: - The callback instance to unregister from receiving async notifications.

Returns:

musaSuccess musaErrorNotSupported musaErrorInvalidDevice musaErrorInvalidValue musaErrorNotPermitted musaErrorUnknown

See also:

musaDeviceRegisterAsyncNotification

musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSMemSize, unsigned int flags)

Returns occupancy for a device function with the specified flags.

Returns in *numBlocks the maximum number of active blocks per streaming multiprocessor for the device function. The flags parameter controls how special cases are handled. Valid flags include: musaOccupancyDefault: keeps the default behavior as musaOccupancyMaxActiveBlocksPerMultiprocessor musaOccupancyDisableCachingOverride: This flag suppresses the default behavior on platform where global caching affects occupancy. On such platforms, if caching is enabled, but per-block SM resource usage would result in zero occupancy, the occupancy calculator will calculate the occupancy as if caching is disabled. Setting this flag makes the occupancy calculator to return 0 in such cases. More information can be found about this feature in the "Unified L1/Texture Cache" section of the Maxwell tuning guide. numBlocks - Returned occupancy func - Kernel function for which occupancy is calculated blockSize - Block size the kernel is intended to be launched with dynamicSMemSize - Per-block dynamic shared memory usage intended, in bytes flags - Requested behavior for the occupancy calculator musaSuccess, musaErrorInvalidDevice, musaErrorInvalidDeviceFunction, musaErrorInvalidValue, musaErrorUnknown, musaOccupancyMaxActiveBlocksPerMultiprocessor, musaOccupancyMaxPotentialBlockSize (C++ API), musaOccupancyMaxPotentialBlockSizeWithFlags (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API), musaOccupancyAvailableDynamicSMemPerBlock (C++ API), muOccupancyMaxActiveBlocksPerMultiprocessorWithFlags

Parameters:

  • int * numBlocks: - Returned occupancy
  • const void * func: - Kernel function for which occupancy is calculated
  • int blockSize: - Block size the kernel is intended to be launched with
  • size_t dynamicSMemSize: - Per-block dynamic shared memory usage intended, in bytes
  • unsigned int flags: - Requested behavior for the occupancy calculator

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidDeviceFunction, musaErrorInvalidValue, musaErrorUnknown,

See also:

musaOccupancyMaxActiveBlocksPerMultiprocessor, musaOccupancyMaxPotentialBlockSize (C++ API), musaOccupancyMaxPotentialBlockSizeWithFlags (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMem (C++ API), musaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags (C++ API), musaOccupancyAvailableDynamicSMemPerBlock (C++ API), muOccupancyMaxActiveBlocksPerMultiprocessorWithFlags

musaGraphicsGLRegisterBuffer

Header: musa_gl_interop.h

__host__ musaError_t MUSARTAPI musaGraphicsGLRegisterBuffer(struct musaGraphicsResource **resource, GLuint buffer, unsigned int flags)

Registers an OpenGL buffer object.

Registers the buffer object specified by buffer for access by MUSA. A handle to the registered object is returned as resource. The register flags flags specify the intended usage, as follows: musaGraphicsRegisterFlagsNone: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by MUSA. This is the default value. musaGraphicsRegisterFlagsReadOnly: Specifies that MUSA will not write to this resource. musaGraphicsRegisterFlagsWriteDiscard: Specifies that MUSA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. resource - Pointer to the returned object handle buffer - name of buffer object to be registered flags - Register flags musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsResourceGetMappedPointer, muGraphicsGLRegisterBuffer

Parameters:

  • struct musaGraphicsResource ** resource: - Pointer to the returned object handle
  • GLuint buffer: - name of buffer object to be registered
  • unsigned int flags: - Register flags

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsResourceGetMappedPointer, muGraphicsGLRegisterBuffer

musaGLSetGLDevice

Header: musa_gl_interop.h

__MUSA_DEPRECATED __host__ musaError_t MUSARTAPI musaGLSetGLDevice(int device)

Sets a MUSA device to use OpenGL interoperability.

Deprecated This function is deprecated as of MUSA 5.0. This function is deprecated and should no longer be used. It is no longer necessary to associate a MUSA device with an OpenGL context in order to achieve maximum interoperability performance. device - Device to use for OpenGL interoperability musaSuccess, musaErrorInvalidDevice, musaErrorSetOnActiveProcess musaGraphicsGLRegisterBuffer, musaGraphicsGLRegisterImage

Parameters:

  • int device: - Device to use for OpenGL interoperability

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorSetOnActiveProcess

See also:

musaGraphicsGLRegisterBuffer, musaGraphicsGLRegisterImage

musaDeviceCanAccessPeer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceCanAccessPeer(int *canAccessPeer, int device, int peerDevice)

Queries if a device may directly access a peer device's memory.

Returns in *canAccessPeer a value of 1 if device device is capable of directly accessing memory from peerDevice and 0 otherwise. If direct access of peerDevice from device is possible, then access may be enabled by calling musaDeviceEnablePeerAccess(). canAccessPeer - Returned access capability device - Device from which allocations on peerDevice are to be directly accessed. peerDevice - Device on which the allocations to be directly accessed by device reside. musaSuccess, musaErrorInvalidDevice musaDeviceEnablePeerAccess, musaDeviceDisablePeerAccess, muDeviceCanAccessPeer

Parameters:

  • int * canAccessPeer: - Returned access capability
  • int device: - Device from which allocations on peerDevice are to be directly accessed.
  • int peerDevice: - Device on which the allocations to be directly accessed by device reside.

Returns:

musaSuccess, musaErrorInvalidDevice

See also:

musaDeviceEnablePeerAccess, musaDeviceDisablePeerAccess, muDeviceCanAccessPeer

musaDeviceEnablePeerAccess

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceEnablePeerAccess(int peerDevice, unsigned int flags)

Enables direct access to memory allocations on a peer device.

On success, all allocations from peerDevice will immediately be accessible by the current device. They will remain accessible until access is explicitly disabled using musaDeviceDisablePeerAccess() or either device is reset using musaDeviceReset(). Note that access granted by this call is unidirectional and that in order to access memory on the current device from peerDevice, a separate symmetric call to musaDeviceEnablePeerAccess() is required. Note that there are both device-wide and system-wide limitations per system configuration, as noted in the MUSA Programming Guide under the section "Peer-to-Peer Memory Access". Returns musaErrorInvalidDevice if musaDeviceCanAccessPeer() indicates that the current device cannot directly access memory from peerDevice. Returns musaErrorPeerAccessAlreadyEnabled if direct access of peerDevice from the current device has already been enabled. Returns musaErrorInvalidValue if flags is not 0. peerDevice - Peer device to enable direct access to from the current device flags - Reserved for future use and must be set to 0 musaSuccess, musaErrorInvalidDevice, musaErrorPeerAccessAlreadyEnabled, musaErrorInvalidValue musaDeviceCanAccessPeer, musaDeviceDisablePeerAccess, muCtxEnablePeerAccess

Parameters:

  • int peerDevice: - Peer device to enable direct access to from the current device
  • unsigned int flags: - Reserved for future use and must be set to 0

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorPeerAccessAlreadyEnabled, musaErrorInvalidValue

See also:

musaDeviceCanAccessPeer, musaDeviceDisablePeerAccess, muCtxEnablePeerAccess

musaDeviceDisablePeerAccess

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceDisablePeerAccess(int peerDevice)

Disables direct access to memory allocations on a peer device.

Returns musaErrorPeerAccessNotEnabled if direct access to memory on peerDevice has not yet been enabled from the current device. peerDevice - Peer device to disable direct access to musaSuccess, musaErrorPeerAccessNotEnabled, musaErrorInvalidDevice musaDeviceCanAccessPeer, musaDeviceEnablePeerAccess, muCtxDisablePeerAccess

Parameters:

  • int peerDevice: - Peer device to disable direct access to

Returns:

musaSuccess, musaErrorPeerAccessNotEnabled, musaErrorInvalidDevice

See also:

musaDeviceCanAccessPeer, musaDeviceEnablePeerAccess, muCtxDisablePeerAccess

musaProfilerStart

Header: musa_profiler_api.h

__host__ musaError_t MUSARTAPI musaProfilerStart(void)

Enable profiling.

Enables profile collection by the active profiling tool for the current context. If profiling is already enabled, then musaProfilerStart() has no effect. musaProfilerStart and musaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code. musaSuccess musaProfilerStop, muProfilerStart

Returns:

musaSuccess

See also:

musaProfilerStop, muProfilerStart

musaProfilerStop

Header: musa_profiler_api.h

__host__ musaError_t MUSARTAPI musaProfilerStop(void)

Disable profiling.

Disables profile collection by the active profiling tool for the current context. If profiling is already disabled, then musaProfilerStop() has no effect. musaProfilerStart and musaProfilerStop APIs are used to programmatically control the profiling granularity by allowing profiling to be done only on selective pieces of code. musaSuccess musaProfilerStart, muProfilerStop

Returns:

musaSuccess

See also:

musaProfilerStart, muProfilerStop

musaMemPoolCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolCreate(musaMemPool_t *memPool, const struct musaMemPoolProps *poolProps)

Creates a memory pool.

Creates a MUSA memory pool and returns the handle in pool. The poolProps determines the properties of the pool such as the backing device and IPC capabilities. To create a memory pool targeting a specific host NUMA node, applications must set musaMemPoolPropsmusaMemLocationtype to musaMemLocationTypeHostNuma and musaMemPoolPropsmusaMemLocationid must specify the NUMA ID of the host memory node. Specifying musaMemLocationTypeHostNumaCurrent or musaMemLocationTypeHost as the musaMemPoolPropsmusaMemLocationtype will result in musaErrorInvalidValue. By default, the pool's memory will be accessible from the device it is allocated on. In the case of pools created with musaMemLocationTypeHostNuma, their default accessibility will be from the host CPU. Applications can control the maximum size of the pool by specifying a non-zero value for musaMemPoolPropsmaxSize. If set to 0, the maximum size of the pool will default to a system dependent value. Applications that intend to use MU_MEM_HANDLE_TYPE_FABRIC based memory sharing must ensure: (1) mthreads-caps-imex-channels character device is created by the driver and is listed under /proc/devices (2) have at least one IMEX channel file accessible by the user launching the application. When exporter and importer MUSA processes have been granted access to the same IMEX channel, they can securely share memory. The IMEX channel security model works on a per user basis. Which means all processes under a user can share memory if the user has access to a valid IMEX channel. When multi-user isolation is desired, a separate IMEX channel is required for each user. These channel files exist in /dev/mthreads-caps-imex-channels/channel* and can be created using standard OS native calls like mknod on Linux. For example: To create channel0 with the major number from /proc/devices users can execute the following command: mknod /dev/mthreads-caps-imex-channels/channel0 c <major number> 0 Specifying musaMemHandleTypeNone creates a memory pool that will not support IPC. musaSuccess, musaErrorInvalidValue, musaErrorNotSupported muMemPoolCreate, musaDeviceSetMemPool, musaMallocFromPoolAsync, musaMemPoolExportToShareableHandle, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool

Parameters:

  • musaMemPool_t * memPool
  • const struct musaMemPoolProps * poolProps

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

See also:

muMemPoolCreate, musaDeviceSetMemPool, musaMallocFromPoolAsync, musaMemPoolExportToShareableHandle, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool

musaMemPoolDestroy

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolDestroy(musaMemPool_t memPool)

Destroys the specified memory pool.

If any pointers obtained from this pool haven't been freed or the pool has free operations that haven't completed when musaMemPoolDestroy is invoked, the function will return immediately and the resources associated with the pool will be released automatically once there are no more outstanding allocations. Destroying the current mempool of a device sets the default mempool of that device as the current mempool for that device. A device's default memory pool cannot be destroyed. musaSuccess, musaErrorInvalidValue muMemPoolDestroy, musaFreeAsync, musaDeviceSetMemPool, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

Parameters:

  • musaMemPool_t memPool

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muMemPoolDestroy, musaFreeAsync, musaDeviceSetMemPool, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

musaMallocAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMallocAsync(void **devPtr, size_t size, musaStream_t hStream)

Allocates memory with stream ordered semantics.

Inserts an allocation operation into hStream. A pointer to the allocated memory is returned immediately in *dptr. The allocation must not be accessed until the the allocation operation completes. The allocation comes from the memory pool associated with the stream's device. The default memory pool of a device contains device memory from that device. Basic stream ordering allows future work submitted into the same stream to use the allocation. Stream query, stream synchronize, and MUSA events can be used to guarantee that the allocation operation completes before work submitted in a separate stream runs. During stream capture, this function results in the creation of an allocation node. In this case, the allocation is owned by the graph instead of the memory pool. The memory pool's properties are used to set the node's creation parameters. devPtr - Returned device pointer size - Number of bytes to allocate hStream - The stream establishing the stream ordering contract and the memory pool to allocate from musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory, muMemAllocAsync, musaMallocAsync (C++ API), musaMallocFromPoolAsync, musaFreeAsync, musaDeviceSetMemPool, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolSetAccess, musaMemPoolSetAttribute, musaMemPoolGetAttribute

Parameters:

  • void ** devPtr: - Returned device pointer
  • size_t size: - Number of bytes to allocate
  • musaStream_t hStream: - The stream establishing the stream ordering contract and the memory pool to allocate from

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported, musaErrorOutOfMemory,

See also:

muMemAllocAsync, musaMallocAsync (C++ API), musaMallocFromPoolAsync, musaFreeAsync, musaDeviceSetMemPool, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolSetAccess, musaMemPoolSetAttribute, musaMemPoolGetAttribute

musaFreeAsync

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaFreeAsync(void *devPtr, musaStream_t hStream)

Frees memory with stream ordered semantics.

Inserts a free operation into hStream. The allocation must not be accessed after stream execution reaches the free. After this API returns, accessing the memory from any subsequent work launched on the GPU or querying its pointer attributes results in undefined behavior. During stream capture, this function results in the creation of a free node and must therefore be passed the address of a graph allocation. dptr - memory to free hStream - The stream establishing the stream ordering promise musaSuccess, musaErrorInvalidValue, musaErrorNotSupported muMemFreeAsync, musaMallocAsync

Parameters:

  • void * devPtr
  • musaStream_t hStream: - The stream establishing the stream ordering promise

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorNotSupported

See also:

muMemFreeAsync, musaMallocAsync

musaMemPoolGetAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolGetAttribute(musaMemPool_t memPool, enum musaMemPoolAttr attr, void *value)

Gets attributes of a memory pool.

Supported attributes are: musaMemPoolAttrReleaseThreshold: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0) musaMemPoolReuseFollowEventDependencies: (value type = int) Allow musaMallocAsync to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. Musa events and null stream interactions can create the required stream ordered dependencies. (default enabled) musaMemPoolReuseAllowOpportunistic: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled) musaMemPoolReuseAllowInternalDependencies: (value type = int) Allow musaMallocAsync to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by musaFreeAsync (default enabled). musaMemPoolAttrReservedMemCurrent: (value type = cuuint64_t) Amount of backing memory currently allocated for the mempool. musaMemPoolAttrReservedMemHigh: (value type = cuuint64_t) High watermark of backing memory allocated for the mempool since the last time it was reset. musaMemPoolAttrUsedMemCurrent: (value type = cuuint64_t) Amount of memory from the pool that is currently in use by the application. musaMemPoolAttrUsedMemHigh: (value type = cuuint64_t) High watermark of the amount of memory from the pool that was in use by the application since the last time it was reset. pool - The memory pool to get attributes of attr - The attribute to get value - Retrieved value musaSuccess, musaErrorInvalidValue muMemPoolGetAttribute, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

Parameters:

  • musaMemPool_t memPool
  • enum musaMemPoolAttr attr: - The attribute to get
  • void * value: - Retrieved value

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muMemPoolGetAttribute, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

musaMemPoolSetAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolSetAttribute(musaMemPool_t memPool, enum musaMemPoolAttr attr, void *value)

Sets attributes of a memory pool.

Supported attributes are: musaMemPoolAttrReleaseThreshold: (value type = cuuint64_t) Amount of reserved memory in bytes to hold onto before trying to release memory back to the OS. When more than the release threshold bytes of memory are held by the memory pool, the allocator will try to release memory back to the OS on the next call to stream, event or context synchronize. (default 0) musaMemPoolReuseFollowEventDependencies: (value type = int) Allow musaMallocAsync to use memory asynchronously freed in another stream as long as a stream ordering dependency of the allocating stream on the free action exists. Musa events and null stream interactions can create the required stream ordered dependencies. (default enabled) musaMemPoolReuseAllowOpportunistic: (value type = int) Allow reuse of already completed frees when there is no dependency between the free and allocation. (default enabled) musaMemPoolReuseAllowInternalDependencies: (value type = int) Allow musaMallocAsync to insert new stream dependencies in order to establish the stream ordering required to reuse a piece of memory released by musaFreeAsync (default enabled). musaMemPoolAttrReservedMemHigh: (value type = cuuint64_t) Reset the high watermark that tracks the amount of backing memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value. musaMemPoolAttrUsedMemHigh: (value type = cuuint64_t) Reset the high watermark that tracks the amount of used memory that was allocated for the memory pool. It is illegal to set this attribute to a non-zero value. pool - The memory pool to modify attr - The attribute to modify value - Pointer to the value to assign musaSuccess, musaErrorInvalidValue muMemPoolSetAttribute, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

Parameters:

  • musaMemPool_t memPool
  • enum musaMemPoolAttr attr: - The attribute to modify
  • void * value: - Pointer to the value to assign

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muMemPoolSetAttribute, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

musaMemPoolSetAccess

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolSetAccess(musaMemPool_t memPool, const struct musaMemAccessDesc *descList, size_t count)

Controls visibility of pools between devices.

pool - The pool being modified map - Array of access descriptors. Each descriptor instructs the access to enable for a single gpu count - Number of descriptors in the map array. musaSuccess, musaErrorInvalidValue muMemPoolSetAccess, musaMemPoolGetAccess, musaMallocAsync, musaFreeAsync

Parameters:

  • musaMemPool_t memPool
  • const struct musaMemAccessDesc * descList
  • size_t count: - Number of descriptors in the map array.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muMemPoolSetAccess, musaMemPoolGetAccess, musaMallocAsync, musaFreeAsync

musaMemPoolGetAccess

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolGetAccess(enum musaMemAccessFlags *flags, musaMemPool_t memPool, struct musaMemLocation *location)

Returns the accessibility of a pool from a device.

Returns the accessibility of the pool's memory from the specified location. flags - the accessibility of the pool from the specified location memPool - the pool being queried location - the location accessing the pool muMemPoolGetAccess, musaMemPoolSetAccess

Parameters:

  • enum musaMemAccessFlags * flags: - the accessibility of the pool from the specified location
  • musaMemPool_t memPool: - the pool being queried
  • struct musaMemLocation * location: - the location accessing the pool

See also:

muMemPoolGetAccess, musaMemPoolSetAccess

musaMemPoolTrimTo

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolTrimTo(musaMemPool_t memPool, size_t minBytesToKeep)

Tries to release memory back to the OS.

Releases memory back to the OS until the pool contains fewer than minBytesToKeep reserved bytes, or there is no more memory that the allocator can safely release. The allocator cannot release OS allocations that back outstanding asynchronous allocations. The OS allocations may happen at different granularity from the user allocations.: Allocations that have not been freed count as outstanding.: Allocations that have been asynchronously freed but whose completion has not been observed on the host (eg. by a synchronize) can count as outstanding. pool - The memory pool to trim minBytesToKeep - If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed to have at least minBytesToKeep bytes reserved after the operation. musaSuccess, musaErrorInvalidValue muMemPoolTrimTo, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

Parameters:

  • musaMemPool_t memPool
  • size_t minBytesToKeep: - If the pool has less than minBytesToKeep reserved, the TrimTo operation is a no-op. Otherwise the pool will be guaranteed to have at least minBytesToKeep bytes reserved after the operation.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

muMemPoolTrimTo, musaMallocAsync, musaFreeAsync, musaDeviceGetDefaultMemPool, musaDeviceGetMemPool, musaMemPoolCreate

musaMemPoolImportFromShareableHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolImportFromShareableHandle(musaMemPool_t *memPool, void *shareableHandle, enum musaMemAllocationHandleType handleType, unsigned int flags)

imports a memory pool from a shared handle.

Specific allocations can be imported from the imported pool with musaMemPoolImportPointer. Imported memory pools do not support creating new allocations. As such imported memory pools may not be used in musaDeviceSetMemPool or musaMallocFromPoolAsync calls. pool_out - Returned memory pool handle - OS handle of the pool to open handleType - The type of handle being imported flags - must be 0 musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory muMemPoolImportFromShareableHandle, musaMemPoolExportToShareableHandle, musaMemPoolExportPointer, musaMemPoolImportPointer

Parameters:

  • musaMemPool_t * memPool
  • void * shareableHandle
  • enum musaMemAllocationHandleType handleType: - The type of handle being imported
  • unsigned int flags: - must be 0

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

See also:

muMemPoolImportFromShareableHandle, musaMemPoolExportToShareableHandle, musaMemPoolExportPointer, musaMemPoolImportPointer

musaMemPoolExportToShareableHandle

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolExportToShareableHandle(void *shareableHandle, musaMemPool_t memPool, enum musaMemAllocationHandleType handleType, unsigned int flags)

Exports a memory pool to the requested handle type.

Given an IPC capable mempool, create an OS handle to share the pool with another process. A recipient process can convert the shareable handle into a mempool with musaMemPoolImportFromShareableHandle. Individual pointers can then be shared with the musaMemPoolExportPointer and musaMemPoolImportPointer APIs. The implementation of what the shareable handle is and how it can be transferred is defined by the requested handle type.: To create an IPC capable mempool, create a mempool with a CUmemAllocationHandleType other than musaMemHandleTypeNone. handle_out - pointer to the location in which to store the requested handle pool - pool to export handleType - the type of handle to create flags - must be 0 musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory muMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolExportPointer, musaMemPoolImportPointer

Parameters:

  • void * shareableHandle
  • musaMemPool_t memPool
  • enum musaMemAllocationHandleType handleType: - the type of handle to create
  • unsigned int flags: - must be 0

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

See also:

muMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolExportPointer, musaMemPoolImportPointer

musaMemPoolImportPointer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolImportPointer(void **ptr, musaMemPool_t memPool, struct musaMemPoolPtrExportData *exportData)

Import a memory pool allocation from another process.

Returns in ptr_out a pointer to the imported memory. The imported memory must not be accessed before the allocation operation completes in the exporting process. The imported memory must be freed from all importing processes before being freed in the exporting process. The pointer may be freed with musaFree or musaFreeAsync. If musaFreeAsync is used, the free must be completed on the importing process before the free operation on the exporting process. The musaFreeAsync api may be used in the exporting process before the musaFreeAsync operation completes in its stream as long as the musaFreeAsync in the exporting process specifies a stream with a stream dependency on the importing process's musaFreeAsync. ptr_out - pointer to imported memory pool - pool from which to import shareData - data specifying the memory to import MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_OUT_OF_MEMORY muMemPoolImportPointer, musaMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolExportPointer

Parameters:

  • void ** ptr
  • musaMemPool_t memPool
  • struct musaMemPoolPtrExportData * exportData

Returns:

MUSA_SUCCESS, MUSA_ERROR_INVALID_VALUE, MUSA_ERROR_NOT_INITIALIZED, MUSA_ERROR_OUT_OF_MEMORY

See also:

muMemPoolImportPointer, musaMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolExportPointer

musaMemPoolExportPointer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaMemPoolExportPointer(struct musaMemPoolPtrExportData *exportData, void *ptr)

Export data to share a memory pool allocation between processes.

Constructs shareData_out for sharing a specific allocation from an already shared memory pool. The recipient process can import the allocation with the musaMemPoolImportPointer api. The data is not a handle and may be shared through any IPC mechanism. shareData_out - Returned export data ptr - pointer to memory being exported musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory muMemPoolExportPointer, musaMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolImportPointer

Parameters:

  • struct musaMemPoolPtrExportData * exportData
  • void * ptr: - pointer to memory being exported

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorOutOfMemory

See also:

muMemPoolExportPointer, musaMemPoolExportToShareableHandle, musaMemPoolImportFromShareableHandle, musaMemPoolImportPointer

musaDeviceGetDefaultMemPool

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGetDefaultMemPool(musaMemPool_t *memPool, int device)

Returns the default mempool of a device.

The default mempool of a device contains device memory from that device. musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaErrorNotSupported muDeviceGetDefaultMemPool, musaMallocAsync, musaMemPoolTrimTo, musaMemPoolGetAttribute, musaDeviceSetMemPool, musaMemPoolSetAttribute, musaMemPoolSetAccess

Parameters:

  • musaMemPool_t * memPool
  • int device

Returns:

musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue musaErrorNotSupported

See also:

muDeviceGetDefaultMemPool, musaMallocAsync, musaMemPoolTrimTo, musaMemPoolGetAttribute, musaDeviceSetMemPool, musaMemPoolSetAttribute, musaMemPoolSetAccess

musaDeviceGetMemPool

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGetMemPool(musaMemPool_t *memPool, int device)

Gets the current mempool for a device.

Returns the last pool provided to musaDeviceSetMemPool for this device or the device's default memory pool if musaDeviceSetMemPool has never been called. By default the current mempool is the default mempool for a device, otherwise the returned pool must have been set with muDeviceSetMemPool or musaDeviceSetMemPool. musaSuccess, musaErrorInvalidValue musaErrorNotSupported muDeviceGetMemPool, musaDeviceGetDefaultMemPool, musaDeviceSetMemPool

Parameters:

  • musaMemPool_t * memPool
  • int device

Returns:

musaSuccess, musaErrorInvalidValue musaErrorNotSupported

See also:

muDeviceGetMemPool, musaDeviceGetDefaultMemPool, musaDeviceSetMemPool

musaDeviceSetMemPool

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceSetMemPool(int device, musaMemPool_t memPool)

Sets the current memory pool of a device.

The memory pool must be local to the specified device. Unless a mempool is specified in the musaMallocAsync call, musaMallocAsync allocates from the current mempool of the provided stream's device. By default, a device's current memory pool is its default memory pool. Use musaMallocFromPoolAsync to specify asynchronous allocations from a device different than the one the stream runs on. musaSuccess, musaErrorInvalidValue musaErrorInvalidDevice musaErrorNotSupported muDeviceSetMemPool, musaDeviceGetMemPool, musaDeviceGetDefaultMemPool, musaMemPoolCreate, musaMemPoolDestroy, musaMallocFromPoolAsync

Parameters:

  • int device
  • musaMemPool_t memPool

Returns:

musaSuccess, musaErrorInvalidValue musaErrorInvalidDevice musaErrorNotSupported

See also:

muDeviceSetMemPool, musaDeviceGetMemPool, musaDeviceGetDefaultMemPool, musaMemPoolCreate, musaMemPoolDestroy, musaMallocFromPoolAsync

musaDeviceGraphMemTrim

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGraphMemTrim(int device)

Free unused memory that was cached on the specified device for use with graphs back to the OS.

Blocks which are not in use by a graph that is either currently executing or scheduled to execute are freed back to the operating system. device - The device for which cached memory should be freed. musaSuccess, musaErrorInvalidValue musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync

Parameters:

  • int device: - The device for which cached memory should be freed.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGetGraphMemAttribute, musaDeviceSetGraphMemAttribute, musaMallocAsync, musaFreeAsync

musaDeviceGetGraphMemAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceGetGraphMemAttribute(int device, enum musaGraphMemAttributeType attr, void *value)

Query asynchronous allocation attributes related to graphs.

Valid attributes are: musaGraphMemAttrUsedMemCurrent: Amount of memory, in bytes, currently associated with graphs musaGraphMemAttrUsedMemHigh: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero. musaGraphMemAttrReservedMemCurrent: Amount of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator. musaGraphMemAttrReservedMemHigh: High watermark of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator. device - Specifies the scope of the query attr - attribute to get value - retrieved value musaSuccess, musaErrorInvalidDevice musaDeviceSetGraphMemAttribute, musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGraphMemTrim, musaMallocAsync, musaFreeAsync

Parameters:

  • int device: - Specifies the scope of the query
  • enum musaGraphMemAttributeType attr: - attribute to get
  • void * value: - retrieved value

Returns:

musaSuccess, musaErrorInvalidDevice

See also:

musaDeviceSetGraphMemAttribute, musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGraphMemTrim, musaMallocAsync, musaFreeAsync

musaDeviceSetGraphMemAttribute

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDeviceSetGraphMemAttribute(int device, enum musaGraphMemAttributeType attr, void *value)

Set asynchronous allocation attributes related to graphs.

Valid attributes are: musaGraphMemAttrUsedMemHigh: High watermark of memory, in bytes, associated with graphs since the last time it was reset. High watermark can only be reset to zero. musaGraphMemAttrReservedMemHigh: High watermark of memory, in bytes, currently allocated for use by the MUSA graphs asynchronous allocator. device - Specifies the scope of the query attr - attribute to get value - pointer to value to set musaSuccess, musaErrorInvalidDevice musaDeviceGetGraphMemAttribute, musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGraphMemTrim, musaMallocAsync, musaFreeAsync

Parameters:

  • int device: - Specifies the scope of the query
  • enum musaGraphMemAttributeType attr: - attribute to get
  • void * value: - pointer to value to set

Returns:

musaSuccess, musaErrorInvalidDevice

See also:

musaDeviceGetGraphMemAttribute, musaGraphAddMemAllocNode, musaGraphAddMemFreeNode, musaDeviceGraphMemTrim, musaMallocAsync, musaFreeAsync

musaStreamAddCallback

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamAddCallback(musaStream_t stream, musaStreamCallback_t callback, void *userData, unsigned int flags)

Add a callback to a compute stream.

This function is slated for eventual deprecation and removal. If you do not require the callback to execute in case of a device error, consider using musaLaunchHostFunc. Additionally, this function is not supported with musaStreamBeginCapture and musaStreamEndCapture, unlike musaLaunchHostFunc. Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each musaStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished. The callback may be passed musaSuccess or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate musaError_t. Callbacks must not make any MUSA API calls. Attempting to use MUSA APIs may result in musaErrorNotPermitted. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized. For the purposes of Unified Memory, callback execution makes a number of guarantees: The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory attached to the callback stream. The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately prior to the callback. It thus synchronizes streams which have been "joined" prior to the callback. Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been properly ordered with an event. Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream. stream - Stream to add callback to callback - The function to call once preceding stream operations are complete userData - User specified data to be passed to the callback function flags - Reserved for future use, must be 0 musaSuccess, musaErrorInvalidResourceHandle, musaErrorInvalidValue, musaErrorNotSupported musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamDestroy, musaMallocManaged, musaStreamAttachMemAsync, musaLaunchHostFunc, muStreamAddCallback

Parameters:

  • musaStream_t stream: - Stream to add callback to
  • musaStreamCallback_t callback: - The function to call once preceding stream operations are complete
  • void * userData: - User specified data to be passed to the callback function
  • unsigned int flags: - Reserved for future use, must be 0

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorInvalidValue, musaErrorNotSupported

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamDestroy, musaMallocManaged, musaStreamAttachMemAsync, musaLaunchHostFunc, muStreamAddCallback

musaStreamCreate

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamCreate(musaStream_t *pStream)

Create an asynchronous stream.

Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. pStream - Pointer to new stream identifier musaSuccess, musaErrorInvalidValue musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate

Parameters:

  • musaStream_t * pStream: - Pointer to new stream identifier

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate

musaStreamBeginCapture

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamBeginCapture(musaStream_t stream, enum musaStreamCaptureMode mode)

Begins graph capture on a stream.

Begin graph capture on stream. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into a graph, which will be returned via musaStreamEndCapture. Capture may not be initiated if stream is musaStreamLegacy. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via musaStreamIsCapturing. A unique id representing the capture sequence may be queried via musaStreamGetCaptureInfo. If mode is not musaStreamCaptureModeRelaxed, musaStreamEndCapture must be called on this stream from the same thread. Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. stream - Stream in which to initiate capture mode - Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode. musaSuccess, musaErrorInvalidValue musaStreamCreate, musaStreamIsCapturing, musaStreamEndCapture, musaThreadExchangeStreamCaptureMode

Parameters:

  • musaStream_t stream: - Stream in which to initiate capture
  • enum musaStreamCaptureMode mode: - Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamCreate, musaStreamIsCapturing, musaStreamEndCapture, musaThreadExchangeStreamCaptureMode

musaStreamBeginCaptureToGraph

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamBeginCaptureToGraph(musaStream_t stream, musaGraph_t graph, const musaGraphNode_t *dependencies, const musaGraphEdgeData *dependencyData, size_t numDependencies, enum musaStreamCaptureMode mode)

Begins graph capture on a stream to an existing graph.

Begin graph capture on stream. When a stream is in capture mode, all operations pushed into the stream will not be executed, but will instead be captured into graph, which will be returned via musaStreamEndCapture. Capture may not be initiated if stream is musaStreamLegacy. Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode. The capture mode may be queried via musaStreamIsCapturing. A unique id representing the capture sequence may be queried via musaStreamGetCaptureInfo. If mode is not musaStreamCaptureModeRelaxed, musaStreamEndCapture must be called on this stream from the same thread. Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects. stream - Stream in which to initiate capture. graph - Graph to capture into. dependencies - Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0. dependencyData - Optional array of data associated with each dependency. numDependencies - Number of dependencies. mode - Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode. musaSuccess, musaErrorInvalidValue musaStreamCreate, musaStreamIsCapturing, musaStreamEndCapture, musaThreadExchangeStreamCaptureMode

Parameters:

  • musaStream_t stream: - Stream in which to initiate capture.
  • musaGraph_t graph: - Graph to capture into.
  • const musaGraphNode_t * dependencies: - Dependencies of the first node captured in the stream. Can be NULL if numDependencies is 0.
  • const musaGraphEdgeData * dependencyData: - Optional array of data associated with each dependency.
  • size_t numDependencies: - Number of dependencies.
  • enum musaStreamCaptureMode mode: - Controls the interaction of this capture sequence with other API calls that are potentially unsafe. For more details see musaThreadExchangeStreamCaptureMode.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamCreate, musaStreamIsCapturing, musaStreamEndCapture, musaThreadExchangeStreamCaptureMode

musaThreadExchangeStreamCaptureMode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaThreadExchangeStreamCaptureMode(enum musaStreamCaptureMode *mode)

Swaps the stream capture interaction mode for a thread.

Sets the calling thread's stream capture interaction mode to the value contained in *mode, and overwrites *mode with the previous mode for the thread. To facilitate deterministic behavior across function or module boundaries, callers are encouraged to use this API in a push-pop fashion: musaStreamCaptureMode mode = desiredMode; musaThreadExchangeStreamCaptureMode(&mode);... musaThreadExchangeStreamCaptureMode(&mode); // restore previous mode During stream capture (see musaStreamBeginCapture), some actions, such as a call to musaMalloc, may be unsafe. In the case of musaMalloc, the operation is not enqueued asynchronously to a stream, and is not observed by stream capture. Therefore, if the sequence of operations captured via musaStreamBeginCapture depended on the allocation being replayed whenever the graph is launched, the captured graph would be invalid. Therefore, stream capture places restrictions on API calls that can be made within or concurrently to a musaStreamBeginCapture - musaStreamEndCapture sequence. This behavior can be controlled via this API and flags to musaStreamBeginCapture. A thread's mode is one of the following: musaStreamCaptureModeGlobal: This is the default mode. If the local thread has an ongoing capture sequence that was not initiated with musaStreamCaptureModeRelaxed at muStreamBeginCapture, or if any other thread has a concurrent capture sequence initiated with musaStreamCaptureModeGlobal, this thread is prohibited from potentially unsafe API calls. musaStreamCaptureModeThreadLocal: If the local thread has an ongoing capture sequence not initiated with musaStreamCaptureModeRelaxed, it is prohibited from potentially unsafe API calls. Concurrent capture sequences in other threads are ignored. musaStreamCaptureModeRelaxed: The local thread is not prohibited from potentially unsafe API calls. Note that the thread is still prohibited from API calls which necessarily conflict with stream capture, for example, attempting musaEventQuery on an event that was last recorded inside a capture sequence. mode - Pointer to mode value to swap with the current mode musaSuccess, musaErrorInvalidValue musaStreamBeginCapture

Parameters:

  • enum musaStreamCaptureMode * mode: - Pointer to mode value to swap with the current mode

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamBeginCapture

musaStreamEndCapture

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamEndCapture(musaStream_t stream, musaGraph_t *pGraph)

Ends capture on a stream, returning the captured graph.

End capture on stream, returning the captured graph via pGraph. Capture must have been initiated on stream via a call to musaStreamBeginCapture. If capture was invalidated, due to a violation of the rules of stream capture, then a NULL graph will be returned. If the mode argument to musaStreamBeginCapture was not musaStreamCaptureModeRelaxed, this call must be from the same thread as musaStreamBeginCapture. stream - Stream to query pGraph - The captured graph musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureWrongThread musaStreamCreate, musaStreamBeginCapture, musaStreamIsCapturing, musaGraphDestroy

Parameters:

  • musaStream_t stream: - Stream to query
  • musaGraph_t * pGraph: - The captured graph

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureWrongThread

See also:

musaStreamCreate, musaStreamBeginCapture, musaStreamIsCapturing, musaGraphDestroy

musaStreamIsCapturing

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamIsCapturing(musaStream_t stream, enum musaStreamCaptureStatus *pCaptureStatus)

Returns a stream's capture status.

Return the capture status of stream via pCaptureStatus. After a successful call, *pCaptureStatus will contain one of the following: musaStreamCaptureStatusNone: The stream is not capturing. musaStreamCaptureStatusActive: The stream is capturing. musaStreamCaptureStatusInvalidated: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated with musaStreamEndCapture on the stream where it was initiated in order to continue using stream. Note that, if this is called on musaStreamLegacy (the "null stream") while a blocking stream on the same device is capturing, it will return musaErrorStreamCaptureImplicit and *pCaptureStatus is unspecified after the call. The blocking stream capture is not invalidated. When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated. The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing stream(s). stream - Stream to query pCaptureStatus - Returns the stream's capture status musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit musaStreamCreate, musaStreamBeginCapture, musaStreamEndCapture

Parameters:

  • musaStream_t stream: - Stream to query
  • enum musaStreamCaptureStatus * pCaptureStatus: - Returns the stream's capture status

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit

See also:

musaStreamCreate, musaStreamBeginCapture, musaStreamEndCapture

musaStreamGetCaptureInfo_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamGetCaptureInfo_v2(musaStream_t stream, enum musaStreamCaptureStatus *captureStatus_out, unsigned long long *id_out, musaGraph_t *graph_out, const musaGraphNode_t **dependencies_out, size_t *numDependencies_out)

Queries stream capture information.

stream Stream to query. captureStatus_out Returned capture status. id_out Returned capture identifier. graph_out Returned captured graph. dependencies_out Returned capture dependencies. numDependencies_out Returned dependency count. musaSuccess or a Runtime error code.

Parameters:

  • musaStream_t stream: Stream to query.
  • enum musaStreamCaptureStatus * captureStatus_out: Returned capture status.
  • unsigned long long * id_out: Returned capture identifier.
  • musaGraph_t * graph_out: Returned captured graph.
  • const musaGraphNode_t ** dependencies_out: Returned capture dependencies.
  • size_t * numDependencies_out: Returned dependency count.

Returns:

musaSuccess or a Runtime error code.

musaStreamGetCaptureInfo_v3

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamGetCaptureInfo_v3(musaStream_t stream, enum musaStreamCaptureStatus *captureStatus_out, unsigned long long *id_out, musaGraph_t *graph_out, const musaGraphNode_t **dependencies_out, const musaGraphEdgeData **edgeData_out, size_t *numDependencies_out)

Query a stream's capture state (12.3+)

Query stream state related to stream capture. If called on musaStreamLegacy (the "null stream") while a stream not created with musaStreamNonBlocking is capturing, returns musaErrorStreamCaptureImplicit. Valid data (other than capture status) is returned only if both of the following are true: the call returns musaSuccess the returned capture status is musaStreamCaptureStatusActive If edgeData_out is non-NULL then dependencies_out must be as well. If dependencies_out is non-NULL and edgeData_out is NULL, but there is non-zero edge data for one or more of the current stream dependencies, the call will return musaErrorLossyQuery. stream - The stream to query captureStatus_out - Location to return the capture status of the stream; required id_out - Optional location to return an id for the capture sequence, which is unique over the lifetime of the process graph_out - Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at musaStreamEndCapture. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at musaStreamEndCapture due to direct actions on the graph do not trigger musaErrorStreamCaptureUnjoined. dependencies_out - Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying. edgeData_out - Optional location to store a pointer to an array of graph edge data. This array parallels dependencies_out; the next node to be added has an edge to dependencies_out [i] with annotation edgeData_out [i] for each i. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. numDependencies_out - Optional location to store the size of the array returned in dependencies_out. musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit, musaErrorLossyQuery musaStreamBeginCapture, musaStreamIsCapturing, musaStreamUpdateCaptureDependencies

Parameters:

  • musaStream_t stream: - The stream to query
  • enum musaStreamCaptureStatus * captureStatus_out: - Location to return the capture status of the stream; required
  • unsigned long long * id_out: - Optional location to return an id for the capture sequence, which is unique over the lifetime of the process
  • musaGraph_t * graph_out: - Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at musaStreamEndCapture. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at musaStreamEndCapture due to direct actions on the graph do not trigger musaErrorStreamCaptureUnjoined.
  • const musaGraphNode_t ** dependencies_out: - Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying.
  • const musaGraphEdgeData ** edgeData_out: - Optional location to store a pointer to an array of graph edge data. This array parallels dependencies_out; the next node to be added has an edge to dependencies_out [i] with annotation edgeData_out [i] for each i. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated.
  • size_t * numDependencies_out: - Optional location to store the size of the array returned in dependencies_out.

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit, musaErrorLossyQuery

See also:

musaStreamBeginCapture, musaStreamIsCapturing, musaStreamUpdateCaptureDependencies

musaStreamGetCaptureInfo

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamGetCaptureInfo(musaStream_t stream, enum musaStreamCaptureStatus *captureStatus_out, unsigned long long *id_out __dv(0), musaGraph_t *graph_out __dv(0), const musaGraphNode_t **dependencies_out __dv(0), size_t *numDependencies_out __dv(0))

Query a stream's capture state.

Query stream state related to stream capture. If called on musaStreamLegacy (the "null stream") while a stream not created with musaStreamNonBlocking is capturing, returns musaErrorStreamCaptureImplicit. Valid data (other than capture status) is returned only if both of the following are true: the call returns musaSuccess the returned capture status is musaStreamCaptureStatusActive stream - The stream to query captureStatus_out - Location to return the capture status of the stream; required id_out - Optional location to return an id for the capture sequence, which is unique over the lifetime of the process graph_out - Optional location to return the graph being captured into. All operations other than destroy and node removal are permitted on the graph while the capture sequence is in progress. This API does not transfer ownership of the graph, which is transferred or destroyed at musaStreamEndCapture. Note that the graph handle may be invalidated before end of capture for certain errors. Nodes that are or become unreachable from the original stream at musaStreamEndCapture due to direct actions on the graph do not trigger musaErrorStreamCaptureUnjoined. dependencies_out - Optional location to store a pointer to an array of nodes. The next node to be captured in the stream will depend on this set of nodes, absent operations such as event wait which modify this set. The array pointer is valid until the next API call which operates on the stream or until the capture is terminated. The node handles may be copied out and are valid until they or the graph is destroyed. The driver-owned array may also be passed directly to APIs that operate on the graph (not the stream) without copying. numDependencies_out - Optional location to store the size of the array returned in dependencies_out. musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit musaStreamGetCaptureInfo_v3, musaStreamBeginCapture, musaStreamIsCapturing, musaStreamUpdateCaptureDependencies

Parameters:

  • musaStream_t stream: - The stream to query
  • enum musaStreamCaptureStatus * captureStatus_out: - Location to return the capture status of the stream; required
  • unsigned long long *id_out __dv
  • musaGraph_t *graph_out __dv
  • const musaGraphNode_t **dependencies_out __dv
  • size_t *numDependencies_out __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorStreamCaptureImplicit

See also:

musaStreamGetCaptureInfo_v3, musaStreamBeginCapture, musaStreamIsCapturing, musaStreamUpdateCaptureDependencies

musaStreamUpdateCaptureDependencies

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamUpdateCaptureDependencies(musaStream_t stream, musaGraphNode_t *dependencies, size_t numDependencies, unsigned int flags __dv(0))

Update the set of dependencies in a capturing stream (11.3+)

Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the stream will depend on. Valid flags are musaStreamAddCaptureDependencies and musaStreamSetCaptureDependencies. These control whether the set passed to the API is added to the existing set or replaces it. A flags value of 0 defaults to musaStreamAddCaptureDependencies. Nodes that are removed from the dependency set via this API do not result in musaErrorStreamCaptureUnjoined if they are unreachable from the stream at musaStreamEndCapture. Returns musaErrorIllegalState if the stream is not capturing. This API is new in MUSA 11.3. Developers requiring compatibility across minor versions of the MUSA driver to 11.0 should not use this API or provide a fallback. stream - The stream to update dependencies - The set of dependencies to add numDependencies - The size of the dependencies array flags - See above musaSuccess, musaErrorInvalidValue, musaErrorIllegalState musaStreamBeginCapture, musaStreamGetCaptureInfo,

Parameters:

  • musaStream_t stream: - The stream to update
  • musaGraphNode_t * dependencies: - The set of dependencies to add
  • size_t numDependencies: - The size of the dependencies array
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorIllegalState

See also:

musaStreamBeginCapture, musaStreamGetCaptureInfo,

musaStreamCreateWithFlags

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamCreateWithFlags(musaStream_t *pStream, unsigned int flags)

Create an asynchronous stream.

Creates a new asynchronous stream on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. The flags argument determines the behaviors of the stream. Valid values for flags are musaStreamDefault: Default stream creation flag. musaStreamNonBlocking: Specifies that work running in the created stream may run concurrently with work in stream 0 (the NULL stream), and that the created stream should perform no implicit synchronization with stream 0. pStream - Pointer to new stream identifier flags - for stream creation musaSuccess, musaErrorInvalidValue musaStreamCreate, musaStreamCreateWithPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate

Parameters:

  • musaStream_t * pStream: - Pointer to new stream identifier
  • unsigned int flags: - Parameters for stream creation

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamCreate, musaStreamCreateWithPriority, musaStreamGetFlags, musaStreamGetDevice, musaStreamQuery, musaStreamSynchronize, musaStreamWaitEvent, musaStreamAddCallback, musaSetDevice, musaStreamDestroy, muStreamCreate

musaStreamCreateWithPriority

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamCreateWithPriority(musaStream_t *pStream, unsigned int flags, int priority)

Create an asynchronous stream with the specified priority.

Creates a stream with the specified priority and returns a handle in pStream. The stream is created on the context that is current to the calling host thread. If no context is current to the calling host thread, then the primary context for a device is selected, made current to the calling thread, and initialized before creating a stream on it. This affects the scheduling priority of work in the stream. Priorities provide a hint to preferentially run work with higher priority when possible, but do not preempt already-running work or provide any other functional guarantee on execution order. priority follows a convention where lower numbers represent higher priorities. '0' represents default priority. The range of meaningful numerical priorities can be queried using musaDeviceGetStreamPriorityRange. If the specified priority is outside the numerical range returned by musaDeviceGetStreamPriorityRange, it will automatically be clamped to the lowest or the highest number in the range. pStream - Pointer to new stream identifier flags - Flags for stream creation. See musaStreamCreateWithFlags for a list of valid flags that can be passed priority - Priority of the stream. Lower numbers represent higher priorities. See musaDeviceGetStreamPriorityRange for more information about the meaningful stream priorities that can be passed. musaSuccess, musaErrorInvalidValue Stream priorities are supported only on GPUs with compute capability 3.5 or higher. In the current implementation, only compute kernels launched in priority streams are affected by the stream's priority. Stream priorities have no effect on host-to-device and device-to-host memory operations. musaStreamCreate, musaStreamCreateWithFlags, musaDeviceGetStreamPriorityRange, musaStreamGetPriority, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamSynchronize, musaSetDevice, musaStreamDestroy, muStreamCreateWithPriority

Parameters:

  • musaStream_t * pStream: - Pointer to new stream identifier
  • unsigned int flags: - Flags for stream creation. See musaStreamCreateWithFlags for a list of valid flags that can be passed
  • int priority: - Priority of the stream. Lower numbers represent higher priorities. See musaDeviceGetStreamPriorityRange for more information about the meaningful stream priorities that can be passed.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaDeviceGetStreamPriorityRange, musaStreamGetPriority, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamSynchronize, musaSetDevice, musaStreamDestroy, muStreamCreateWithPriority

musaStreamDestroy

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamDestroy(musaStream_t stream)

Destroys and cleans up an asynchronous stream.

Destroys and cleans up the asynchronous stream specified by stream. In case the device is still doing work in the stream stream when musaStreamDestroy() is called, the function will return immediately and the resources associated with stream will be released automatically once the device has completed all work in stream. stream - Stream identifier musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, muStreamDestroy

Parameters:

  • musaStream_t stream: - Stream identifier

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, muStreamDestroy

musaStreamQuery

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamQuery(musaStream_t stream)

Queries an asynchronous stream for completion status.

Returns musaSuccess if all operations in stream have completed, or musaErrorNotReady if not. For the purposes of Unified Memory, a return value of musaSuccess is equivalent to having called musaStreamSynchronize(). stream - Stream identifier musaSuccess, musaErrorNotReady, musaErrorInvalidResourceHandle musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamQuery

Parameters:

  • musaStream_t stream: - Stream identifier

Returns:

musaSuccess, musaErrorNotReady, musaErrorInvalidResourceHandle

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamQuery

musaStreamSynchronize

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaStreamSynchronize(musaStream_t stream)

Waits for stream tasks to complete.

Blocks until stream has completed all operations. If the musaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the stream is finished with all of its tasks. stream - Stream identifier musaSuccess, musaErrorInvalidResourceHandle musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamDestroy, muStreamSynchronize

Parameters:

  • musaStream_t stream: - Stream identifier

Returns:

musaSuccess, musaErrorInvalidResourceHandle

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamWaitEvent, musaStreamAddCallback, musaStreamDestroy, muStreamSynchronize

musaStreamWaitEvent

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamWaitEvent(musaStream_t stream, musaEvent_t event, unsigned int flags __dv(0))

Make a compute stream wait on an event.

Makes all future work submitted to stream wait for all work captured in event. See musaEventRecord() for details on what is captured by an event. The synchronization will be performed efficiently on the device when applicable. event may be from a different device than stream. flags include: musaEventWaitDefault: Default event creation flag. musaEventWaitExternal: Event is captured in the graph as an external event node when performing stream capture. stream - Stream to wait event - Event to wait on flags - for the operation(See above) musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamWaitEvent

Parameters:

  • musaStream_t stream: - Stream to wait
  • musaEvent_t event: - Event to wait on
  • unsigned int flags __dv

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamQuery, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, muStreamWaitEvent

musaStreamGetFlags

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamGetFlags(musaStream_t hStream, unsigned int *flags)

Query the flags of a stream.

Query the flags of a stream. The flags are returned in flags. See musaStreamCreateWithFlags for a list of valid flags. hStream - Handle to the stream to be queried flags - Pointer to an unsigned integer in which the stream's flags are returned musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetDevice, muStreamGetFlags

Parameters:

  • musaStream_t hStream: - Handle to the stream to be queried
  • unsigned int * flags: - Pointer to an unsigned integer in which the stream's flags are returned

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetDevice, muStreamGetFlags

musaStreamGetPriority

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamGetPriority(musaStream_t hStream, int *priority)

Query the priority of a stream.

Query the priority of a stream. The priority is returned in in priority. Note that if the stream was created with a priority outside the meaningful numerical range returned by musaDeviceGetStreamPriorityRange, this function returns the clamped priority. See musaStreamCreateWithPriority for details about priority clamping. hStream - Handle to the stream to be queried priority - Pointer to a signed integer in which the stream's priority is returned musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreateWithPriority, musaDeviceGetStreamPriorityRange, musaStreamGetFlags, musaStreamGetDevice, muStreamGetPriority

Parameters:

  • musaStream_t hStream: - Handle to the stream to be queried
  • int * priority: - Pointer to a signed integer in which the stream's priority is returned

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreateWithPriority, musaDeviceGetStreamPriorityRange, musaStreamGetFlags, musaStreamGetDevice, muStreamGetPriority

musaStreamGetId

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamGetId(musaStream_t hStream, unsigned long long *streamId)

Query the Id of a stream.

Query the Id of a stream. The Id is returned in streamId. The Id is unique for the life of the program. The stream handle hStream can refer to any of the following: a stream created via any of the MUSA runtime APIs such as musaStreamCreate, musaStreamCreateWithFlags and musaStreamCreateWithPriority, or their driver API equivalents such as muStreamCreate or muStreamCreateWithPriority. Passing an invalid handle will result in undefined behavior. any of the special streams such as the NULL stream, musaStreamLegacy and musaStreamPerThread respectively. The driver API equivalents of these are also accepted which are NULL, MU_STREAM_LEGACY and MU_STREAM_PER_THREAD. hStream - Handle to the stream to be queried streamId - Pointer to an unsigned long long in which the stream Id is returned musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId

Parameters:

  • musaStream_t hStream: - Handle to the stream to be queried
  • unsigned long long * streamId: - Pointer to an unsigned long long in which the stream Id is returned

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreateWithPriority, musaStreamCreateWithFlags, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId

musaStreamGetDevice

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamGetDevice(musaStream_t hStream, int *device)

Query the device of a stream.

Returns in *device the device of the stream. hStream - Handle to the stream to be queried device - Returns the device to which the stream belongs musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable, musaSetDevice, musaGetDevice, musaStreamCreate, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId

Parameters:

  • musaStream_t hStream: - Handle to the stream to be queried
  • int * device: - Returns the device to which the stream belongs

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorDeviceUnavailable,

See also:

musaSetDevice, musaGetDevice, musaStreamCreate, musaStreamGetPriority, musaStreamGetFlags, muStreamGetId

musaStreamAttachMemAsync

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamAttachMemAsync(musaStream_t stream, void *devPtr, size_t length __dv(0), unsigned int flags)

Attach memory to a stream asynchronously.

Enqueues an operation in stream to specify stream association of length bytes of memory starting from devPtr. This function is a stream-ordered operation, meaning that it is dependent on, and will only take effect when, previous work in stream has completed. Any previous association is automatically replaced. devPtr must point to an one of the following types of memories: managed memory declared using the managed keyword or allocated with musaMallocManaged. a valid host-accessible region of system-allocated pageable memory. This type of memory may only be specified if the device associated with the stream reports a non-zero value for the device attribute musaDevAttrPageableMemoryAccess. For managed allocations, length must be either zero or the entire allocation's size. Both indicate that the entire allocation's stream association is being changed. Currently, it is not possible to change stream association for a portion of a managed allocation. For pageable allocations, length must be non-zero. The stream association is specified using flags which must be one of musaMemAttachGlobal, musaMemAttachHost or musaMemAttachSingle. The default value for flags is musaMemAttachSingle If the musaMemAttachGlobal flag is specified, the memory can be accessed by any stream on any device. If the musaMemAttachHost flag is specified, the program makes a guarantee that it won't access the memory on the device from any stream on a device that has a zero value for the device attribute musaDevAttrConcurrentManagedAccess. If the musaMemAttachSingle flag is specified and stream is associated with a device that has a zero value for the device attribute musaDevAttrConcurrentManagedAccess, the program makes a guarantee that it will only access the memory on the device from stream. It is illegal to attach singly to the NULL stream, because the NULL stream is a virtual global stream and not a specific stream. An error will be returned in this case. When memory is associated with a single stream, the Unified Memory system will allow CPU access to this memory region so long as all operations in stream have completed, regardless of whether other streams are active. In effect, this constrains exclusive ownership of the managed memory region by an active GPU to per-stream activity instead of whole-GPU activity. Accessing memory on the device from streams that are not associated with it will produce undefined results. No error checking is performed by the Unified Memory system to ensure that kernels launched into other streams do not access this region. It is a program's responsibility to order calls to musaStreamAttachMemAsync via events, synchronization or other means to ensure legal access to memory at all times. Data visibility and coherency will be changed appropriately for all kernels which follow a stream-association change. If stream is destroyed while data is associated with it, the association is removed and the association reverts to the default visibility of the allocation as specified at musaMallocManaged. For managed variables, the default association is always musaMemAttachGlobal. Note that destroying a stream is an asynchronous operation, and as a result, the change to default association won't happen until all work in the stream has completed. stream - Stream in which to enqueue the attach operation devPtr - Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory) length - Length of memory (defaults to zero) flags - Must be one of musaMemAttachGlobal, musaMemAttachHost or musaMemAttachSingle (defaults to musaMemAttachSingle) musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, musaMallocManaged, muStreamAttachMemAsync

Parameters:

  • musaStream_t stream: - Stream in which to enqueue the attach operation
  • void * devPtr: - Pointer to memory (must be a pointer to managed memory or to a valid host-accessible region of system-allocated memory)
  • size_t length __dv
  • unsigned int flags: - Must be one of musaMemAttachGlobal, musaMemAttachHost or musaMemAttachSingle (defaults to musaMemAttachSingle)

Returns:

musaSuccess, musaErrorNotReady, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaStreamCreate, musaStreamCreateWithFlags, musaStreamWaitEvent, musaStreamSynchronize, musaStreamAddCallback, musaStreamDestroy, musaMallocManaged, muStreamAttachMemAsync

musaStreamSetAttribute

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamSetAttribute(musaStream_t hStream, musaStreamAttrID attr, const musaStreamAttrValue *value)

Sets stream attribute.

Sets attribute attr on hStream from corresponding attribute of value. The updated attribute will be applied to subsequent work submitted to the stream. It will not affect previously submitted work. hStream attr value musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaAccessPolicyWindow

Parameters:

  • musaStream_t hStream
  • musaStreamAttrID attr
  • const musaStreamAttrValue * value

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaAccessPolicyWindow

musaStreamGetAttribute

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamGetAttribute(musaStream_t hStream, musaStreamAttrID attr, musaStreamAttrValue *value_out)

Queries stream attribute.

Queries attribute attr from hStream and stores it in corresponding member of value_out. hStream attr value_out musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaAccessPolicyWindow

Parameters:

  • musaStream_t hStream
  • musaStreamAttrID attr
  • musaStreamAttrValue * value_out

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaAccessPolicyWindow

musaStreamCopyAttributes

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaStreamCopyAttributes(musaStream_t dst, musaStream_t src)

Copies attributes from source stream to destination stream.

Copies attributes from source stream src to destination stream dst. Both streams must have the same context. dst Destination stream src Source stream For attributes see musaStreamAttrID musaSuccess, musaErrorNotSupported musaAccessPolicyWindow

Parameters:

  • musaStream_t dst: Destination stream
  • musaStream_t src: Source stream For attributes see musaStreamAttrID

Returns:

musaSuccess, musaErrorNotSupported

See also:

musaAccessPolicyWindow

musaCtxResetPersistingL2Cache

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaCtxResetPersistingL2Cache(void)

Resets all persisting lines in cache to normal status.

Resets all persisting lines in cache to normal status. Takes effect on function return. musaSuccess, musaAccessPolicyWindow

Returns:

musaSuccess,

See also:

musaAccessPolicyWindow

musaCreateTextureObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaCreateTextureObject(musaTextureObject_t *pTexObject, const struct musaResourceDesc *pResDesc, const struct musaTextureDesc *pTexDesc, const struct musaResourceViewDesc *pResViewDesc)

Creates a texture object.

Creates a texture object and returns it in pTexObject. pResDesc describes the data to texture from. pTexDesc describes how the data should be sampled. pResViewDesc is an optional argument that specifies an alternate format for the data described by pResDesc, and also describes the subresource region to restrict access to when texturing. pResViewDesc can only be specified if the type of resource is a MUSA array or a MUSA mipmapped array not in a block compressed format. Texture objects are only supported on devices of compute capability 3.0 or higher. Additionally, a texture object is an opaque value, and, as such, should only be accessed through MUSA API calls. The musaResourceDesc structure is defined as: struct musaResourceDesc { enum musaResourceType resType; union { struct { musaArray_t array; } array; struct { musaMipmappedArray_t mipmap; } mipmap; struct { void *devPtr; struct musaChannelFormatDesc desc; size_t sizeInBytes; } linear; struct { void *devPtr; struct musaChannelFormatDesc desc; size_t width; size_t height; size_t pitchInBytes; } pitch2D; } res; }; where: musaResourceDescresType specifies the type of resource to texture from. CUresourceType is defined as: enum musaResourceType { musaResourceTypeArray = 0x00, musaResourceTypeMipmappedArray = 0x01, musaResourceTypeLinear = 0x02, musaResourceTypePitch2D = 0x03 }; If musaResourceDescresType is set to musaResourceTypeArray, musaResourceDescresarrayarray must be set to a valid MUSA array handle. If musaResourceDescresType is set to musaResourceTypeMipmappedArray, musaResourceDescresmipmapmipmap must be set to a valid MUSA mipmapped array handle and musaTextureDescnormalizedCoords must be set to true. If musaResourceDescresType is set to musaResourceTypeLinear, musaResourceDescreslineardevPtr must be set to a valid device pointer, that is aligned to musaDeviceProptextureAlignment. musaResourceDescreslineardesc describes the format and the number of components per array element. musaResourceDescreslinearsizeInBytes specifies the size of the array in bytes. The total number of elements in the linear address range cannot exceed musaDevicePropmaxTexture1DLinear. The number of elements is computed as (sizeInBytes / sizeof(desc)). If musaResourceDescresType is set to musaResourceTypePitch2D, musaResourceDescrespitch2DdevPtr must be set to a valid device pointer, that is aligned to musaDeviceProptextureAlignment. musaResourceDescrespitch2Ddesc describes the format and the number of components per array element. musaResourceDescrespitch2Dwidth and musaResourceDescrespitch2Dheight specify the width and height of the array in elements, and cannot exceed musaDevicePropmaxTexture2DLinear[0] and musaDevicePropmaxTexture2DLinear[1] respectively. musaResourceDescrespitch2DpitchInBytes specifies the pitch between two rows in bytes and has to be aligned to musaDeviceProptexturePitchAlignment. Pitch cannot exceed musaDevicePropmaxTexture2DLinear[2]. The musaTextureDesc struct is defined as struct musaTextureDesc { enum musaTextureAddressMode addressMode[3]; enum musaTextureFilterMode filterMode; enum musaTextureReadMode readMode; int sRGB; float borderColor[4]; int normalizedCoords; unsigned int maxAnisotropy; enum musaTextureFilterMode mipmapFilterMode; float mipmapLevelBias; float minMipmapLevelClamp; float maxMipmapLevelClamp; int disableTrilinearOptimization; int seamlessCubemap; }; where musaTextureDescaddressMode specifies the addressing mode for each dimension of the texture data. musaTextureAddressMode is defined as: enum musaTextureAddressMode { musaAddressModeWrap = 0, musaAddressModeClamp = 1, musaAddressModeMirror = 2, musaAddressModeBorder = 3 }; This is ignored if musaResourceDescresType is musaResourceTypeLinear. Also, if musaTextureDescnormalizedCoords is set to zero, musaAddressModeWrap and musaAddressModeMirror won't be supported and will be switched to musaAddressModeClamp. musaTextureDescfilterMode specifies the filtering mode to be used when fetching from the texture. musaTextureFilterMode is defined as: enum musaTextureFilterMode { musaFilterModePoint = 0, musaFilterModeLinear = 1 }; This is ignored if musaResourceDescresType is musaResourceTypeLinear. musaTextureDescreadMode specifies whether integer data should be converted to floating point or not. musaTextureReadMode is defined as: enum musaTextureReadMode { musaReadModeElementType = 0, musaReadModeNormalizedFloat = 1 }; Note that this applies only to 8-bit and 16-bit integer formats. 32-bit integer format would not be promoted, regardless of whether or not this musaTextureDescreadMode is set musaReadModeNormalizedFloat is specified. musaTextureDescsRGB specifies whether sRGB to linear conversion should be performed during texture fetch. musaTextureDescborderColor specifies the float values of color. where: musaTextureDescborderColor[0] contains value of 'R', musaTextureDescborderColor[1] contains value of 'G', musaTextureDescborderColor[2] contains value of 'B', musaTextureDescborderColor[3] contains value of 'A' Note that application using integer border color values will need to <reinterpret_cast> these values to float. The values are set only when the addressing mode specified by musaTextureDescaddressMode is musaAddressModeBorder. musaTextureDescnormalizedCoords specifies whether the texture coordinates will be normalized or not. musaTextureDescmaxAnisotropy specifies the maximum anistropy ratio to be used when doing anisotropic filtering. This value will be clamped to the range [1,16]. musaTextureDescmipmapFilterMode specifies the filter mode when the calculated mipmap level lies between two defined mipmap levels. musaTextureDescmipmapLevelBias specifies the offset to be applied to the calculated mipmap level. musaTextureDescminMipmapLevelClamp specifies the lower end of the mipmap level range to clamp access to. musaTextureDescmaxMipmapLevelClamp specifies the upper end of the mipmap level range to clamp access to. musaTextureDescdisableTrilinearOptimization specifies whether the trilinear filtering optimizations will be disabled. musaTextureDescseamlessCubemap specifies whether seamless cube map filtering is enabled. This flag can only be specified if the underlying resource is a MUSA array or a MUSA mipmapped array that was created with the flag musaArrayCubemap. When seamless cube map filtering is enabled, texture address modes specified by musaTextureDescaddressMode are ignored. Instead, if the musaTextureDescfilterMode is set to musaFilterModePoint the address mode musaAddressModeClamp will be applied for all dimensions. If the musaTextureDescfilterMode is set to musaFilterModeLinear seamless cube map filtering will be performed when sampling along the cube face borders. The musaResourceViewDesc struct is defined as struct musaResourceViewDesc { enum musaResourceViewFormat format; size_t width; size_t height; size_t depth; unsigned int firstMipmapLevel; unsigned int lastMipmapLevel; unsigned int firstLayer; unsigned int lastLayer; }; where: musaResourceViewDescformat specifies how the data contained in the MUSA array or MUSA mipmapped array should be interpreted. Note that this can incur a change in size of the texture data. If the resource view format is a block compressed format, then the underlying MUSA array or MUSA mipmapped array has to have a 32-bit unsigned integer format with 2 or 4 channels, depending on the block compressed format. For ex., BC1 and BC4 require the underlying MUSA array to have a 32-bit unsigned int with 2 channels. The other BC formats require the underlying resource to have the same 32-bit unsigned int format but with 4 channels. musaResourceViewDescwidth specifies the new width of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original width of the resource. For non block compressed formats, this value has to be equal to that of the original resource. musaResourceViewDescheight specifies the new height of the texture data. If the resource view format is a block compressed format, this value has to be 4 times the original height of the resource. For non block compressed formats, this value has to be equal to that of the original resource. musaResourceViewDescdepth specifies the new depth of the texture data. This value has to be equal to that of the original resource. musaResourceViewDescfirstMipmapLevel specifies the most detailed mipmap level. This will be the new mipmap level zero. For non-mipmapped resources, this value has to be zero.musaTextureDescminMipmapLevelClamp and musaTextureDescmaxMipmapLevelClamp will be relative to this value. For ex., if the firstMipmapLevel is set to 2, and a minMipmapLevelClamp of 1.2 is specified, then the actual minimum mipmap level clamp will be 3.2. musaResourceViewDesclastMipmapLevel specifies the least detailed mipmap level. For non-mipmapped resources, this value has to be zero. musaResourceViewDescfirstLayer specifies the first layer index for layered textures. This will be the new layer zero. For non-layered resources, this value has to be zero. musaResourceViewDesclastLayer specifies the last layer index for layered textures. For non-layered resources, this value has to be zero. pTexObject - Texture object to create pResDesc - Resource descriptor pTexDesc - Texture descriptor pResViewDesc - Resource view descriptor musaSuccess, musaErrorInvalidValue musaDestroyTextureObject, muTexObjectCreate

Parameters:

  • musaTextureObject_t * pTexObject: - Texture object to create
  • const struct musaResourceDesc * pResDesc: - Resource descriptor
  • const struct musaTextureDesc * pTexDesc: - Texture descriptor
  • const struct musaResourceViewDesc * pResViewDesc: - Resource view descriptor

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaDestroyTextureObject, muTexObjectCreate

musaDestroyTextureObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDestroyTextureObject(musaTextureObject_t texObject)

Destroys a texture object.

Destroys the texture object specified by texObject. texObject - Texture object to destroy musaSuccess, musaErrorInvalidValue musaCreateTextureObject, muTexObjectDestroy

Parameters:

  • musaTextureObject_t texObject: - Texture object to destroy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateTextureObject, muTexObjectDestroy

musaGetTextureObjectResourceDesc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetTextureObjectResourceDesc(struct musaResourceDesc *pResDesc, musaTextureObject_t texObject)

Returns a texture object's resource descriptor.

Returns the resource descriptor for the texture object specified by texObject. pResDesc - Resource descriptor texObject - Texture object musaSuccess, musaErrorInvalidValue musaCreateTextureObject, muTexObjectGetResourceDesc

Parameters:

  • struct musaResourceDesc * pResDesc: - Resource descriptor
  • musaTextureObject_t texObject: - Texture object

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateTextureObject, muTexObjectGetResourceDesc

musaGetTextureObjectTextureDesc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetTextureObjectTextureDesc(struct musaTextureDesc *pTexDesc, musaTextureObject_t texObject)

Returns a texture object's texture descriptor.

Returns the texture descriptor for the texture object specified by texObject. pTexDesc - Texture descriptor texObject - Texture object musaSuccess, musaErrorInvalidValue musaCreateTextureObject, muTexObjectGetTextureDesc

Parameters:

  • struct musaTextureDesc * pTexDesc: - Texture descriptor
  • musaTextureObject_t texObject: - Texture object

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateTextureObject, muTexObjectGetTextureDesc

musaGetTextureObjectResourceViewDesc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetTextureObjectResourceViewDesc(struct musaResourceViewDesc *pResViewDesc, musaTextureObject_t texObject)

Returns a texture object's resource view descriptor.

Returns the resource view descriptor for the texture object specified by texObject. If no resource view was specified, musaErrorInvalidValue is returned. pResViewDesc - Resource view descriptor texObject - Texture object musaSuccess, musaErrorInvalidValue musaCreateTextureObject, muTexObjectGetResourceViewDesc

Parameters:

  • struct musaResourceViewDesc * pResViewDesc: - Resource view descriptor
  • musaTextureObject_t texObject: - Texture object

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateTextureObject, muTexObjectGetResourceViewDesc

musaCreateChannelDesc

Header: musa_runtime_api.h

__host__ struct musaChannelFormatDesc MUSARTAPI musaCreateChannelDesc(int x, int y, int z, int w, enum musaChannelFormatKind f)

Returns a channel descriptor using the specified format.

Returns a channel descriptor with format f and number of bits of each component x, y, z, and w. The musaChannelFormatDesc is defined as: struct musaChannelFormatDesc { int x, y, z, w; enum musaChannelFormatKind f; }; where musaChannelFormatKind is one of musaChannelFormatKindSigned, musaChannelFormatKindUnsigned, or musaChannelFormatKindFloat. x - X component y - Y component z - Z component w - W component f - Channel format Channel descriptor with format f musaCreateChannelDesc (C++ API), musaGetChannelDesc, musaCreateTextureObject, musaCreateSurfaceObject

Parameters:

  • int x: - X component
  • int y: - Y component
  • int z: - Z component
  • int w: - W component
  • enum musaChannelFormatKind f: - Channel format

Returns:

Channel descriptor with format f

See also:

musaCreateChannelDesc (C++ API), musaGetChannelDesc, musaCreateTextureObject, musaCreateSurfaceObject

musaGetChannelDesc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetChannelDesc(struct musaChannelFormatDesc *desc, musaArray_const_t array)

Get the channel descriptor of an array.

Returns in *desc the channel descriptor of the MUSA array array. desc - Channel format array - Memory array on device musaSuccess, musaErrorInvalidValue musaCreateChannelDesc (C API), musaCreateTextureObject, musaCreateSurfaceObject

Parameters:

  • struct musaChannelFormatDesc * desc: - Channel format
  • musaArray_const_t array: - Memory array on device

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateChannelDesc (C API), musaCreateTextureObject, musaCreateSurfaceObject

musaCreateSurfaceObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaCreateSurfaceObject(musaSurfaceObject_t *pSurfObject, const struct musaResourceDesc *pResDesc)

Creates a surface object.

Creates a surface object and returns it in pSurfObject. pResDesc describes the data to perform surface load/stores on. musaResourceDescresType must be musaResourceTypeArray and musaResourceDescresarrayarray must be set to a valid MUSA array handle. Surface objects are only supported on devices of compute capability 3.0 or higher. Additionally, a surface object is an opaque value, and, as such, should only be accessed through MUSA API calls. pSurfObject - Surface object to create pResDesc - Resource descriptor musaSuccess, musaErrorInvalidValue, musaErrorInvalidChannelDescriptor, musaErrorInvalidResourceHandle musaDestroySurfaceObject, muSurfObjectCreate

Parameters:

  • musaSurfaceObject_t * pSurfObject: - Surface object to create
  • const struct musaResourceDesc * pResDesc: - Resource descriptor

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidChannelDescriptor, musaErrorInvalidResourceHandle

See also:

musaDestroySurfaceObject, muSurfObjectCreate

musaDestroySurfaceObject

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDestroySurfaceObject(musaSurfaceObject_t surfObject)

Destroys a surface object.

Destroys the surface object specified by surfObject. surfObject - Surface object to destroy musaSuccess, musaErrorInvalidValue musaCreateSurfaceObject, muSurfObjectDestroy

Parameters:

  • musaSurfaceObject_t surfObject: - Surface object to destroy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateSurfaceObject, muSurfObjectDestroy

musaGetSurfaceObjectResourceDesc

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGetSurfaceObjectResourceDesc(struct musaResourceDesc *pResDesc, musaSurfaceObject_t surfObject)

Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject.

pResDesc - Resource descriptor surfObject - Surface object musaSuccess, musaErrorInvalidValue musaCreateSurfaceObject, muSurfObjectGetResourceDesc

Parameters:

  • struct musaResourceDesc * pResDesc: - Resource descriptor
  • musaSurfaceObject_t surfObject: - Surface object

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaCreateSurfaceObject, muSurfObjectGetResourceDesc

musaDriverGetVersion

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDriverGetVersion(int *driverVersion)

Returns the latest version of MUSA supported by the driver.

Returns in *driverVersion the latest version of MUSA supported by the driver. The version is returned as (1000 major + 10 minor). For example, MUSA 9.2 would be represented by 9020. If no driver is installed, then 0 is returned as the driver version. This function automatically returns musaErrorInvalidValue if driverVersion is NULL. driverVersion - Returns the MUSA driver version. musaSuccess, musaErrorInvalidValue musaRuntimeGetVersion, muDriverGetVersion

Parameters:

  • int * driverVersion: - Returns the MUSA driver version.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaRuntimeGetVersion, muDriverGetVersion

musaRuntimeGetVersion

Header: musa_runtime_api.h

__host__ __musart_builtin__ musaError_t MUSARTAPI musaRuntimeGetVersion(int *runtimeVersion)

Returns the MUSA Runtime version.

Returns in *runtimeVersion the version number of the current MUSA Runtime instance. The version is returned as (1000 major + 10 minor). For example, MUSA 9.2 would be represented by 9020. As of MUSA 12.0, this function no longer initializes MUSA. The purpose of this API is solely to return a compile-time constant stating the MUSA Toolkit version in the above format. This function automatically returns musaErrorInvalidValue if the runtimeVersion argument is NULL. runtimeVersion - Returns the MUSA Runtime version. musaSuccess, musaErrorInvalidValue musaDriverGetVersion, muDriverGetVersion

Parameters:

  • int * runtimeVersion: - Returns the MUSA Runtime version.

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaDriverGetVersion, muDriverGetVersion

musaImportExternalSemaphore

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaImportExternalSemaphore(musaExternalSemaphore_t *extSem_out, const struct musaExternalSemaphoreHandleDesc *semHandleDesc)

Imports an external semaphore.

Imports an externally allocated synchronization object and returns a handle to that in extSem_out. The properties of the handle being imported must be described in semHandleDesc. The musaExternalSemaphoreHandleDesc is defined as follows: typedef struct musaExternalSemaphoreHandleDesc_st { musaExternalSemaphoreHandleType type; union { int fd; struct { void *handle; const void name; } win32; const void MtSciSyncObj; } handle; unsigned int flags; } musaExternalSemaphoreHandleDesc; where musaExternalSemaphoreHandleDesctype specifies the type of handle being imported. musaExternalSemaphoreHandleType is defined as: typedef enum musaExternalSemaphoreHandleType_enum { musaExternalSemaphoreHandleTypeOpaqueFd = 1, musaExternalSemaphoreHandleTypeOpaqueWin32 = 2, musaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3, musaExternalSemaphoreHandleTypeD3D12Fence = 4, musaExternalSemaphoreHandleTypeD3D11Fence = 5, musaExternalSemaphoreHandleTypeMtSciSync = 6, musaExternalSemaphoreHandleTypeKeyedMutex = 7, musaExternalSemaphoreHandleTypeKeyedMutexKmt = 8, musaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9, musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10 } musaExternalSemaphoreHandleType; If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeOpaqueFd, then musaExternalSemaphoreHandleDeschandlefd must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeOpaqueWin32, then exactly one of musaExternalSemaphoreHandleDeschandlewin32handle and musaExternalSemaphoreHandleDeschandlewin32name must not be NULL. If musaExternalSemaphoreHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalSemaphoreHandleDeschandlewin32name is not NULL, then it must name a valid synchronization object. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeOpaqueWin32Kmt, then musaExternalSemaphoreHandleDeschandlewin32handle must be non-NULL and musaExternalSemaphoreHandleDeschandlewin32name must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the synchronization object are destroyed. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeD3D12Fence, then exactly one of musaExternalSemaphoreHandleDeschandlewin32handle and musaExternalSemaphoreHandleDeschandlewin32name must not be NULL. If musaExternalSemaphoreHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12DeviceCreateSharedHandle when referring to a ID3D12Fence object. This handle holds a reference to the underlying object. If musaExternalSemaphoreHandleDeschandlewin32name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D12Fence object. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeD3D11Fence, then exactly one of musaExternalSemaphoreHandleDeschandlewin32handle and musaExternalSemaphoreHandleDeschandlewin32name must not be NULL. If musaExternalSemaphoreHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D11FenceCreateSharedHandle. If musaExternalSemaphoreHandleDeschandlewin32name is not NULL, then it must name a valid synchronization object that refers to a valid ID3D11Fence object. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeMtSciSync, then musaExternalSemaphoreHandleDeschandlemtSciSyncObj represents a valid MtSciSyncObj. musaExternalSemaphoreHandleTypeKeyedMutex, then exactly one of musaExternalSemaphoreHandleDeschandlewin32handle and musaExternalSemaphoreHandleDeschandlewin32name must not be NULL. If musaExternalSemaphoreHandleDeschandlewin32handle is not NULL, then it represent a valid shared NT handle that is returned by IDXGIResource1CreateSharedHandle when referring to a IDXGIKeyedMutex object. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeKeyedMutexKmt, then musaExternalSemaphoreHandleDeschandlewin32handle must be non-NULL and musaExternalSemaphoreHandleDeschandlewin32name must be NULL. The handle specified must represent a valid KMT handle that is returned by IDXGIResourceGetSharedHandle when referring to a IDXGIKeyedMutex object. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeTimelineSemaphoreFd, then musaExternalSemaphoreHandleDeschandlefd must be a valid file descriptor referencing a synchronization object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If musaExternalSemaphoreHandleDesctype is musaExternalSemaphoreHandleTypeTimelineSemaphoreWin32, then exactly one of musaExternalSemaphoreHandleDeschandlewin32handle and musaExternalSemaphoreHandleDeschandlewin32name must not be NULL. If musaExternalSemaphoreHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that references a synchronization object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalSemaphoreHandleDeschandlewin32name is not NULL, then it must name a valid synchronization object. extSem_out - Returned handle to an external semaphore semHandleDesc - Semaphore import handle descriptor musaSuccess, musaErrorInvalidResourceHandle, musaErrorOperatingSystem musaDestroyExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaExternalSemaphore_t * extSem_out: - Returned handle to an external semaphore
  • const struct musaExternalSemaphoreHandleDesc * semHandleDesc: - Semaphore import handle descriptor

Returns:

musaSuccess, musaErrorInvalidResourceHandle, musaErrorOperatingSystem

See also:

musaDestroyExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaSignalExternalSemaphoresAsync_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaSignalExternalSemaphoresAsync_v2(const musaExternalSemaphore_t *extSemArray, const struct musaExternalSemaphoreSignalParams *paramsArray, unsigned int numExtSems, musaStream_t stream)

Signals external semaphores asynchronously.

extSemArray External semaphore array. paramsArray Signal parameter array. numExtSems Number of semaphores. stream Stream used for the operation. musaSuccess or a Runtime error code.

Parameters:

  • const musaExternalSemaphore_t * extSemArray: External semaphore array.
  • const struct musaExternalSemaphoreSignalParams * paramsArray: Signal parameter array.
  • unsigned int numExtSems: Number of semaphores.
  • musaStream_t stream: Stream used for the operation.

Returns:

musaSuccess or a Runtime error code.

musaWaitExternalSemaphoresAsync_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaWaitExternalSemaphoresAsync_v2(const musaExternalSemaphore_t *extSemArray, const struct musaExternalSemaphoreWaitParams *paramsArray, unsigned int numExtSems, musaStream_t stream)

Waits on external semaphores asynchronously.

extSemArray External semaphore array. paramsArray Wait parameter array. numExtSems Number of semaphores. stream Stream used for the operation. musaSuccess or a Runtime error code.

Parameters:

  • const musaExternalSemaphore_t * extSemArray: External semaphore array.
  • const struct musaExternalSemaphoreWaitParams * paramsArray: Wait parameter array.
  • unsigned int numExtSems: Number of semaphores.
  • musaStream_t stream: Stream used for the operation.

Returns:

musaSuccess or a Runtime error code.

musaDestroyExternalSemaphore

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDestroyExternalSemaphore(musaExternalSemaphore_t extSem)

Destroys an external semaphore.

Destroys an external semaphore object and releases any references to the underlying resource. Any outstanding signals or waits must have completed before the semaphore is destroyed. extSem - External semaphore to be destroyed musaSuccess, musaErrorInvalidResourceHandle musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaExternalSemaphore_t extSem: - External semaphore to be destroyed

Returns:

musaSuccess, musaErrorInvalidResourceHandle

See also:

musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaImportExternalMemory

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaImportExternalMemory(musaExternalMemory_t *extMem_out, const struct musaExternalMemoryHandleDesc *memHandleDesc)

Imports an external memory object.

Imports an externally allocated memory object and returns a handle to that in extMem_out. The properties of the handle being imported must be described in memHandleDesc. The musaExternalMemoryHandleDesc structure is defined as follows: typedef struct musaExternalMemoryHandleDesc_st { musaExternalMemoryHandleType type; union { int fd; struct { void *handle; const void *name; } win32; const void *mtSciBufObject; } handle; unsigned long long size; unsigned int flags; } musaExternalMemoryHandleDesc; where musaExternalMemoryHandleDesctype specifies the type of handle being imported. musaExternalMemoryHandleType is defined as: typedef enum musaExternalMemoryHandleType_enum { musaExternalMemoryHandleTypeOpaqueFd = 1, musaExternalMemoryHandleTypeOpaqueWin32 = 2, musaExternalMemoryHandleTypeOpaqueWin32Kmt = 3, musaExternalMemoryHandleTypeD3D12Heap = 4, musaExternalMemoryHandleTypeD3D12Resource = 5, musaExternalMemoryHandleTypeD3D11Resource = 6, musaExternalMemoryHandleTypeD3D11ResourceKmt = 7, musaExternalMemoryHandleTypeMtSciBuf = 8 } musaExternalMemoryHandleType; If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeOpaqueFd, then musaExternalMemoryHandleDeschandlefd must be a valid file descriptor referencing a memory object. Ownership of the file descriptor is transferred to the MUSA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeOpaqueWin32, then exactly one of musaExternalMemoryHandleDeschandlewin32handle and musaExternalMemoryHandleDeschandlewin32name must not be NULL. If musaExternalMemoryHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that references a memory object. Ownership of this handle is not transferred to MUSA after the import operation, so the application must release the handle using the appropriate system call. If musaExternalMemoryHandleDeschandlewin32name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeOpaqueWin32Kmt, then musaExternalMemoryHandleDeschandlewin32handle must be non-NULL and musaExternalMemoryHandleDeschandlewin32name must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the memory object are destroyed. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeD3D12Heap, then exactly one of musaExternalMemoryHandleDeschandlewin32handle and musaExternalMemoryHandleDeschandlewin32name must not be NULL. If musaExternalMemoryHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12DeviceCreateSharedHandle when referring to a ID3D12Heap object. This handle holds a reference to the underlying object. If musaExternalMemoryHandleDeschandlewin32name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeD3D12Resource, then exactly one of musaExternalMemoryHandleDeschandlewin32handle and musaExternalMemoryHandleDeschandlewin32name must not be NULL. If musaExternalMemoryHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12DeviceCreateSharedHandle when referring to a ID3D12Resource object. This handle holds a reference to the underlying object. If musaExternalMemoryHandleDeschandlewin32name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeD3D11Resource,then exactly one of musaExternalMemoryHandleDeschandlewin32handle and musaExternalMemoryHandleDeschandlewin32name must not be NULL. If musaExternalMemoryHandleDeschandlewin32handle is not NULL, then it must represent a valid shared NT handle that is returned by IDXGIResource1CreateSharedHandle when referring to a ID3D11Resource object. If musaExternalMemoryHandleDeschandlewin32name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeD3D11ResourceKmt, then musaExternalMemoryHandleDeschandlewin32handle must be non-NULL and musaExternalMemoryHandleDeschandlewin32name must be NULL. The handle specified must be a valid shared KMT handle that is returned by IDXGIResourceGetSharedHandle when referring to a ID3D11Resource object. If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeMtSciBuf, then musaExternalMemoryHandleDeschandlemtSciBufObject must be NON-NULL and reference a valid MtSciBuf object. If the MtSciBuf object imported into MUSA is also mapped by other drivers, then the application must use musaWaitExternalSemaphoresAsync or musaSignalExternalSemaphoresAsync as approprriate barriers to maintain coherence between MUSA and the other drivers. See musaExternalSemaphoreWaitSkipMtSciBufMemSync and musaExternalSemaphoreSignalSkipMtSciBufMemSync for memory synchronization. The size of the memory object must be specified in musaExternalMemoryHandleDescsize. Specifying the flag musaExternalMemoryDedicated in musaExternalMemoryHandleDescflags indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of this extension. This flag must be set if musaExternalMemoryHandleDesctype is one of the following: musaExternalMemoryHandleTypeD3D12Resource musaExternalMemoryHandleTypeD3D11Resource musaExternalMemoryHandleTypeD3D11ResourceKmt extMem_out - Returned handle to an external memory object memHandleDesc - Memory import handle descriptor musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorOperatingSystem If the Vulkan memory imported into MUSA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs, please refer to "Synchronization and Cache Control" chapter from Vulkan specification. musaDestroyExternalMemory, musaExternalMemoryGetMappedBuffer, musaExternalMemoryGetMappedMipmappedArray

Parameters:

  • musaExternalMemory_t * extMem_out: - Returned handle to an external memory object
  • const struct musaExternalMemoryHandleDesc * memHandleDesc: - Memory import handle descriptor

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorOperatingSystem

See also:

musaDestroyExternalMemory, musaExternalMemoryGetMappedBuffer, musaExternalMemoryGetMappedMipmappedArray

musaExternalMemoryGetMappedBuffer

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaExternalMemoryGetMappedBuffer(void **devPtr, musaExternalMemory_t extMem, const struct musaExternalMemoryBufferDesc *bufferDesc)

Maps a buffer onto an imported memory object.

Maps a buffer onto an imported memory object and returns a device pointer in devPtr. The properties of the buffer being mapped must be described in bufferDesc. The musaExternalMemoryBufferDesc structure is defined as follows: typedef struct musaExternalMemoryBufferDesc_st { unsigned long long offset; unsigned long long size; unsigned int flags; } musaExternalMemoryBufferDesc; where musaExternalMemoryBufferDescoffset is the offset in the memory object where the buffer's base address is. musaExternalMemoryBufferDescsize is the size of the buffer. musaExternalMemoryBufferDescflags must be zero. The offset and size have to be suitably aligned to match the requirements of the external API. Mapping two buffers whose ranges overlap may or may not result in the same virtual address being returned for the overlapped portion. In such cases, the application must ensure that all accesses to that region from the GPU are volatile. Otherwise writes made via one address are not guaranteed to be visible via the other address, even if they're issued by the same thread. It is recommended that applications map the combined range instead of mapping separate buffers and then apply the appropriate offsets to the returned pointer to derive the individual buffers. The returned pointer devPtr must be freed using musaFree. devPtr - Returned device pointer to buffer extMem - Handle to external memory object bufferDesc - Buffer descriptor musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaImportExternalMemory, musaDestroyExternalMemory, musaExternalMemoryGetMappedMipmappedArray

Parameters:

  • void ** devPtr: - Returned device pointer to buffer
  • musaExternalMemory_t extMem: - Handle to external memory object
  • const struct musaExternalMemoryBufferDesc * bufferDesc: - Buffer descriptor

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaImportExternalMemory, musaDestroyExternalMemory, musaExternalMemoryGetMappedMipmappedArray

musaExternalMemoryGetMappedMipmappedArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaExternalMemoryGetMappedMipmappedArray(musaMipmappedArray_t *mipmap, musaExternalMemory_t extMem, const struct musaExternalMemoryMipmappedArrayDesc *mipmapDesc)

Maps a MUSA mipmapped array onto an external memory object.

Maps a MUSA mipmapped array onto an external object and returns a handle to it in mipmap. The properties of the MUSA mipmapped array being mapped must be described in mipmapDesc. The structure musaExternalMemoryMipmappedArrayDesc is defined as follows: typedef struct musaExternalMemoryMipmappedArrayDesc_st { unsigned long long offset; musaChannelFormatDesc formatDesc; musaExtent extent; unsigned int flags; unsigned int numLevels; } musaExternalMemoryMipmappedArrayDesc; where musaExternalMemoryMipmappedArrayDescoffset is the offset in the memory object where the base level of the mipmap chain is. musaExternalMemoryMipmappedArrayDescformatDesc describes the format of the data. musaExternalMemoryMipmappedArrayDescextent specifies the dimensions of the base level of the mipmap chain. musaExternalMemoryMipmappedArrayDescflags are flags associated with MUSA mipmapped arrays. For further details, please refer to the documentation for musaMalloc3DArray. Note that if the mipmapped array is bound as a color target in the graphics API, then the flag musaArrayColorAttachment must be specified in musaExternalMemoryMipmappedArrayDescflags. musaExternalMemoryMipmappedArrayDescnumLevels specifies the total number of levels in the mipmap chain. The returned MUSA mipmapped array must be freed using musaFreeMipmappedArray. mipmap - Returned MUSA mipmapped array extMem - Handle to external memory object mipmapDesc - MUSA array descriptor musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaImportExternalMemory, musaDestroyExternalMemory, musaExternalMemoryGetMappedBuffer If musaExternalMemoryHandleDesctype is musaExternalMemoryHandleTypeMtSciBuf, then musaExternalMemoryMipmappedArrayDescnumLevels must not be greater than 1.

Parameters:

  • musaMipmappedArray_t * mipmap: - Returned MUSA mipmapped array
  • musaExternalMemory_t extMem: - Handle to external memory object
  • const struct musaExternalMemoryMipmappedArrayDesc * mipmapDesc: - MUSA array descriptor

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaImportExternalMemory, musaDestroyExternalMemory, musaExternalMemoryGetMappedBuffer

musaDestroyExternalMemory

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaDestroyExternalMemory(musaExternalMemory_t extMem)

Destroys an external memory object.

Destroys the specified external memory object. Any existing buffers and MUSA mipmapped arrays mapped onto this object must no longer be used and must be explicitly freed using musaFree and musaFreeMipmappedArray respectively. extMem - External memory object to be destroyed musaSuccess, musaErrorInvalidResourceHandle musaImportExternalMemory, musaExternalMemoryGetMappedBuffer, musaExternalMemoryGetMappedMipmappedArray

Parameters:

  • musaExternalMemory_t extMem: - External memory object to be destroyed

Returns:

musaSuccess, musaErrorInvalidResourceHandle

See also:

musaImportExternalMemory, musaExternalMemoryGetMappedBuffer, musaExternalMemoryGetMappedMipmappedArray

musaGraphicsGLRegisterImage

Header: musa_gl_interop.h

__host__ musaError_t MUSARTAPI musaGraphicsGLRegisterImage(struct musaGraphicsResource **resource, GLuint image, GLenum target, unsigned int flags)

Gets the MUSA devices associated with the current OpenGL context.

Returns in *pMusaDeviceCount the number of MUSA-compatible devices corresponding to the current OpenGL context. Also returns in *pMusaDevices at most musaDeviceCount of the MUSA-compatible devices corresponding to the current OpenGL context. If any of the GPUs being used by the current OpenGL context are not MUSA capable then the call will return musaErrorNoDevice. pMusaDeviceCount - Returned number of MUSA devices corresponding to the current OpenGL context pMusaDevices - Returned MUSA devices corresponding to the current OpenGL context musaDeviceCount - The size of the output device array pMusaDevices deviceList - The set of devices to return. This set may be musaGLDeviceListAll for all devices, musaGLDeviceListCurrentFrame for the devices used to render the current frame (in SLI), or musaGLDeviceListNextFrame for the devices used to render the next frame (in SLI). musaSuccess, musaErrorNoDevice, musaErrorInvalidGraphicsContext, musaErrorUnknown This function is not supported on Mac OS X. musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, musaGraphicsResourceGetMappedPointer, muGLGetDevices Register an OpenGL texture or renderbuffer object Registers the texture or renderbuffer object specified by image for access by MUSA. A handle to the registered object is returned as resource. target must match the type of the object, and must be one of GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_3D, GL_TEXTURE_2D_ARRAY, or GL_RENDERBUFFER. The register flags flags specify the intended usage, as follows: musaGraphicsRegisterFlagsNone: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by MUSA. This is the default value. musaGraphicsRegisterFlagsReadOnly: Specifies that MUSA will not write to this resource. musaGraphicsRegisterFlagsWriteDiscard: Specifies that MUSA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved. musaGraphicsRegisterFlagsSurfaceLoadStore: Specifies that MUSA will bind this resource to a surface reference. musaGraphicsRegisterFlagsTextureGather: Specifies that MUSA will perform texture gather operations on this resource. The following image formats are supported. For brevity's sake, the list is abbreviated. For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats {GL_R8, GL_R16, GL_RG8, GL_RG16}: GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I} {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT} The following image classes are currently disallowed: Textures with borders Multisampled renderbuffers resource - Pointer to the returned object handle image - name of texture or renderbuffer object to be registered target - Identifies the type of object specified by image flags - Register flags musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, muGraphicsGLRegisterImage

Parameters:

  • struct musaGraphicsResource ** resource: - Pointer to the returned object handle
  • GLuint image: - name of texture or renderbuffer object to be registered
  • GLenum target: - Identifies the type of object specified by image
  • unsigned int flags: - Register flags

Returns:

musaSuccess, musaErrorNoDevice, musaErrorInvalidGraphicsContext, musaErrorUnknown musaSuccess, musaErrorInvalidDevice, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, musaGraphicsResourceGetMappedPointer, muGLGetDevices musaGraphicsUnregisterResource, musaGraphicsMapResources, musaGraphicsSubResourceGetMappedArray, muGraphicsGLRegisterImage

musaGraphicsSubResourceGetMappedArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsSubResourceGetMappedArray(musaArray_t *array, musaGraphicsResource_t resource, unsigned int arrayIndex, unsigned int mipLevel)

Get an array through which to access a subresource of a mapped graphics resource.

Returns in *array an array through which the subresource of the mapped graphics resource resource which corresponds to array index arrayIndex and mipmap level mipLevel may be accessed. The value set in array may change every time that resource is mapped. If resource is not a texture then it cannot be accessed via an array and musaErrorUnknown is returned. If arrayIndex is not a valid array index for resource then musaErrorInvalidValue is returned. If mipLevel is not a valid mipmap level for resource then musaErrorInvalidValue is returned. If resource is not mapped then musaErrorUnknown is returned. array - Returned array through which a subresource of resource may be accessed resource - Mapped resource to access arrayIndex - Array index for array textures or cubemap face index as defined by musaGraphicsCubeFace for cubemap textures for the subresource to access mipLevel - Mipmap level for the subresource to access musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsResourceGetMappedPointer, muGraphicsSubResourceGetMappedArray

Parameters:

  • musaArray_t * array: - Returned array through which a subresource of resource may be accessed
  • musaGraphicsResource_t resource: - Mapped resource to access
  • unsigned int arrayIndex: - Array index for array textures or cubemap face index as defined by musaGraphicsCubeFace for cubemap textures for the subresource to access
  • unsigned int mipLevel: - Mipmap level for the subresource to access

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsResourceGetMappedPointer, muGraphicsSubResourceGetMappedArray

musaGraphAddNode_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddNode_v2(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, const musaGraphEdgeData *dependencyData, size_t numDependencies, struct musaGraphNodeParams *nodeParams)

Adds a node of arbitrary type to a graph (12.3+)

Creates a new node in graph described by nodeParams with numDependencies dependencies specified via pDependencies. numDependencies may be 0. pDependencies may be null if numDependencies is 0. pDependencies may not have any duplicate entries. nodeParams is a tagged union. The node type should be specified in the type field, and type-specific parameters in the corresponding union member. All unused bytes - that is, reserved0 and all bytes past the utilized union member - must be set to zero. It is recommended to use brace initialization or memset to ensure all bytes are initialized. Note that for some node types, nodeParams may contain "out parameters" which are modified during the call, such as nodeParams->alloc.dptr. A handle to the new node will be returned in phGraphNode. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node dependencyData - Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies. numDependencies - Number of dependencies nodeParams - Specification of the node musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported musaGraphCreate, musaGraphNodeSetParams, musaGraphExecNodeSetParams

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • const musaGraphEdgeData * dependencyData: - Optional edge data for the dependencies. If NULL, the data is assumed to be default (zeroed) for all dependencies.
  • size_t numDependencies: - Number of dependencies
  • struct musaGraphNodeParams * nodeParams: - Specification of the node

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidDeviceFunction, musaErrorNotSupported

See also:

musaGraphCreate, musaGraphNodeSetParams, musaGraphExecNodeSetParams

musaGraphGetEdges_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphGetEdges_v2(musaGraph_t graph, musaGraphNode_t *from, musaGraphNode_t *to, musaGraphEdgeData *edgeData, size_t *numEdges)

Returns a graph's dependency edges (12.3+)

Returns a list of graph's dependency edges. Edges are returned via corresponding indices in from, to and edgeData; that is, the node in to [i] has a dependency on the node in from [i] with data edgeData [i]. from and to may both be NULL, in which case this function only returns the number of edges in numEdges. Otherwise, numEdges entries will be filled in. If numEdges is higher than the actual number of edges, the remaining entries in from and to will be set to NULL, and the number of edges actually returned will be written to numEdges. edgeData may alone be NULL, in which case the edges must all have default (zeroed) edge data. Attempting a losst query via NULL edgeData will result in musaErrorLossyQuery. If edgeData is non-NULL then from and to must be as well. graph - Graph to get the edges from from - Location to return edge endpoints to - Location to return edge endpoints edgeData - Optional location to return edge data numEdges - See description musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue musaGraphGetNodes, musaGraphGetRootNodes, musaGraphAddDependencies, musaGraphRemoveDependencies, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to get the edges from
  • musaGraphNode_t * from: - Location to return edge endpoints
  • musaGraphNode_t * to: - Location to return edge endpoints
  • musaGraphEdgeData * edgeData: - Optional location to return edge data
  • size_t * numEdges: - See description

Returns:

musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue

See also:

musaGraphGetNodes, musaGraphGetRootNodes, musaGraphAddDependencies, musaGraphRemoveDependencies, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphNodeGetDependentNodes_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphNodeGetDependentNodes_v2(musaGraphNode_t node, musaGraphNode_t *pDependentNodes, musaGraphEdgeData *edgeData, size_t *pNumDependentNodes)

Returns a node's dependent nodes (12.3+)

Returns a list of node's dependent nodes. pDependentNodes may be NULL, in which case this function will return the number of dependent nodes in pNumDependentNodes. Otherwise, pNumDependentNodes entries will be filled in. If pNumDependentNodes is higher than the actual number of dependent nodes, the remaining entries in pDependentNodes will be set to NULL, and the number of nodes actually obtained will be returned in pNumDependentNodes. Note that if an edge has non-zero (non-default) edge data and edgeData is NULL, this API will return musaErrorLossyQuery. If edgeData is non-NULL, then pDependentNodes must be as well. node - Node to query pDependentNodes - Pointer to return the dependent nodes edgeData - Optional pointer to return edge data for dependent nodes pNumDependentNodes - See description musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue musaGraphNodeGetDependencies, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

Parameters:

  • musaGraphNode_t node: - Node to query
  • musaGraphNode_t * pDependentNodes: - Pointer to return the dependent nodes
  • musaGraphEdgeData * edgeData: - Optional pointer to return edge data for dependent nodes
  • size_t * pNumDependentNodes: - See description

Returns:

musaSuccess, musaErrorLossyQuery, musaErrorInvalidValue

See also:

musaGraphNodeGetDependencies, musaGraphGetNodes, musaGraphGetRootNodes, musaGraphGetEdges, musaGraphAddDependencies, musaGraphRemoveDependencies

musaGraphAddDependencies_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddDependencies_v2(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, const musaGraphEdgeData *edgeData, size_t numDependencies)

Adds dependency edges to a graph. (12.3+)

The number of dependencies to be added is defined by numDependencies Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph. If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an existing dependency will return an error. graph - Graph to which dependencies are added from - Array of nodes that provide the dependencies to - Array of dependent nodes edgeData - Optional array of edge data. If NULL, default (zeroed) edge data is assumed. numDependencies - Number of dependencies to be added musaSuccess, musaErrorInvalidValue musaGraphRemoveDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph to which dependencies are added
  • const musaGraphNode_t * from: - Array of nodes that provide the dependencies
  • const musaGraphNode_t * to: - Array of dependent nodes
  • const musaGraphEdgeData * edgeData: - Optional array of edge data. If NULL, default (zeroed) edge data is assumed.
  • size_t numDependencies: - Number of dependencies to be added

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphRemoveDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphRemoveDependencies_v2

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphRemoveDependencies_v2(musaGraph_t graph, const musaGraphNode_t *from, const musaGraphNode_t *to, const musaGraphEdgeData *edgeData, size_t numDependencies)

Removes dependency edges from a graph. (12.3+)

The number of pDependencies to be removed is defined by numDependencies. Elements in pFrom and pTo at corresponding indices define a dependency. Each node in pFrom and pTo must belong to graph. If numDependencies is 0, elements in pFrom and pTo will be ignored. Specifying an edge that does not exist in the graph, with data matching edgeData, results in an error. edgeData is nullable, which is equivalent to passing default (zeroed) data for each edge. graph - Graph from which to remove dependencies from - Array of nodes that provide the dependencies to - Array of dependent nodes edgeData - Optional array of edge data. If NULL, edge data is assumed to be default (zeroed). numDependencies - Number of dependencies to be removed musaSuccess, musaErrorInvalidValue musaGraphAddDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

Parameters:

  • musaGraph_t graph: - Graph from which to remove dependencies
  • const musaGraphNode_t * from: - Array of nodes that provide the dependencies
  • const musaGraphNode_t * to: - Array of dependent nodes
  • const musaGraphEdgeData * edgeData: - Optional array of edge data. If NULL, edge data is assumed to be default (zeroed).
  • size_t numDependencies: - Number of dependencies to be removed

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddDependencies, musaGraphGetEdges, musaGraphNodeGetDependencies, musaGraphNodeGetDependentNodes

musaGraphInstantiateWithParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphInstantiateWithParams(musaGraphExec_t *pGraphExec, musaGraph_t graph, musaGraphInstantiateParams *instantiateParams)

Creates an executable graph from a graph.

Instantiates graph as an executable graph according to the instantiateParams structure. The graph is validated for any structural constraints or intra-node constraints which were not previously validated. If instantiation is successful, a handle to the instantiated graph is returned in pGraphExec. instantiateParams controls the behavior of instantiation and subsequent graph launches, as well as returning more detailed information in the event of an error. musaGraphInstantiateParams is defined as: typedef struct { unsigned long long flags; musaStream_t uploadStream; musaGraphNode_t errNode_out; musaGraphInstantiateResult result_out; } musaGraphInstantiateParams; The flags field controls the behavior of instantiation and subsequent graph launches. Valid flags are: musaGraphInstantiateFlagAutoFreeOnLaunch, which configures a graph containing memory allocation nodes to automatically free any unfreed memory allocations before the graph is relaunched. musaGraphInstantiateFlagUpload, which will perform an upload of the graph into uploadStream once the graph has been instantiated. musaGraphInstantiateFlagDeviceLaunch, which configures the graph for launch from the device. If this flag is passed, the executable graph handle returned can be used to launch the graph from both the host and device. This flag can only be used on platforms which support unified addressing. This flag cannot be used in conjunction with musaGraphInstantiateFlagAutoFreeOnLaunch. musaGraphInstantiateFlagUseNodePriority, which causes the graph to use the priorities from the per-node attributes rather than the priority of the launch stream during execution. Note that priorities are only available on kernel nodes, and are copied from stream priority during stream capture. If graph contains any allocation or free nodes, there can be at most one executable graph in existence for that graph at a time. An attempt to instantiate a second executable graph before destroying the first with musaGraphExecDestroy will result in an error. The same also applies if graph contains any device-updatable kernel nodes. If graph contains kernels which call device-side musaGraphLaunch() from multiple devices, this will result in an error. Graphs instantiated for launch on the device have additional restrictions which do not apply to host graphs: The graph's nodes must reside on a single device. The graph can only contain kernel nodes, memcpy nodes, memset nodes, and child graph nodes. The graph cannot be empty and must contain at least one kernel, memcpy, or memset node. Operation-specific restrictions are outlined below. Kernel nodes: Use of MUSA Dynamic Parallelism is not permitted. Cooperative launches are permitted as long as MPS is not in use. Memcpy nodes: Only copies involving device memory and/or pinned device-mapped host memory are permitted. Copies involving MUSA arrays are not permitted. Both operands must be accessible from the current device, and the current device must match the device of other nodes in the graph. In the event of an error, the result_out and errNode_out fields will contain more information about the nature of the error. Possible error reporting includes: musaGraphInstantiateError, if passed an invalid value or if an unexpected error occurred which is described by the return value of the function. errNode_out will be set to NULL. musaGraphInstantiateInvalidStructure, if the graph structure is invalid. errNode_out will be set to one of the offending nodes. musaGraphInstantiateNodeOperationNotSupported, if the graph is instantiated for device launch but contains a node of an unsupported node type, or a node which performs unsupported operations, such as use of MUSA dynamic parallelism within a kernel node. errNode_out will be set to this node. musaGraphInstantiateMultipleDevicesNotSupported, if the graph is instantiated for device launch but a node’s device differs from that of another node. This error can also be returned if a graph is not instantiated for device launch and it contains kernels which call device-side musaGraphLaunch() from multiple devices. errNode_out will be set to this node. If instantiation is successful, result_out will be set to musaGraphInstantiateSuccess, and hErrNode_out will be set to NULL. pGraphExec - Returns instantiated graph graph - Graph to instantiate instantiateParams - Instantiation parameters musaSuccess, musaErrorInvalidValue musaGraphCreate, musaGraphInstantiate, musaGraphInstantiateWithFlags, musaGraphExecDestroy

Parameters:

  • musaGraphExec_t * pGraphExec: - Returns instantiated graph
  • musaGraph_t graph: - Graph to instantiate
  • musaGraphInstantiateParams * instantiateParams: - Instantiation parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphCreate, musaGraphInstantiate, musaGraphInstantiateWithFlags, musaGraphExecDestroy

musaGraphicsResourceGetMappedMipmappedArray

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphicsResourceGetMappedMipmappedArray(musaMipmappedArray_t *mipmappedArray, musaGraphicsResource_t resource)

Get a mipmapped array through which to access a mapped graphics resource.

Returns in *mipmappedArray a mipmapped array through which the mapped graphics resource resource may be accessed. The value set in mipmappedArray may change every time that resource is mapped. If resource is not a texture then it cannot be accessed via an array and musaErrorUnknown is returned. If resource is not mapped then musaErrorUnknown is returned. mipmappedArray - Returned mipmapped array through which resource may be accessed resource - Mapped resource to access musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown musaGraphicsResourceGetMappedPointer, muGraphicsResourceGetMappedMipmappedArray

Parameters:

  • musaMipmappedArray_t * mipmappedArray: - Returned mipmapped array through which resource may be accessed
  • musaGraphicsResource_t resource: - Mapped resource to access

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorUnknown

See also:

musaGraphicsResourceGetMappedPointer, muGraphicsResourceGetMappedMipmappedArray

musaGraphAddExternalSemaphoresSignalNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddExternalSemaphoresSignalNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Creates an external semaphore signal node and adds it to a graph.

Creates a new external semaphore signal node and adds it to graph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. Performs a signal operation on a set of externally allocated semaphore objects when the node is launched. The operation(s) will occur after all of the node's dependencies have completed. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies nodeParams - for the node musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphExternalSemaphoresSignalNodeGetParams, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaExternalSemaphoreSignalNodeParams * nodeParams: - Parameters for the node

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphExternalSemaphoresSignalNodeGetParams, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphExternalSemaphoresSignalNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExternalSemaphoresSignalNodeGetParams(musaGraphNode_t hNode, struct musaExternalSemaphoreSignalNodeParams *params_out)

Returns an external semaphore signal node's parameters.

Returns the parameters of an external semaphore signal node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphExternalSemaphoresSignalNodeSetParams to update the parameters of this node. hNode - Node to get the parameters for params_out - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaLaunchKernel, musaGraphAddExternalSemaphoresSignalNode, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaGraphNode_t hNode: - Node to get the parameters for
  • struct musaExternalSemaphoreSignalNodeParams * params_out: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaLaunchKernel, musaGraphAddExternalSemaphoresSignalNode, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaGraphExternalSemaphoresSignalNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExternalSemaphoresSignalNodeSetParams(musaGraphNode_t hNode, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Sets an external semaphore signal node's parameters.

Sets the parameters of an external semaphore signal node hNode to nodeParams. hNode - Node to set the parameters for nodeParams - to copy musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaGraphNode_t hNode: - Node to set the parameters for
  • const struct musaExternalSemaphoreSignalNodeParams * nodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaGraphExternalSemaphoresSignalNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaGraphAddExternalSemaphoresWaitNode

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphAddExternalSemaphoresWaitNode(musaGraphNode_t *pGraphNode, musaGraph_t graph, const musaGraphNode_t *pDependencies, size_t numDependencies, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Creates an external semaphore wait node and adds it to a graph.

Creates a new external semaphore wait node and adds it to graph with numDependencies dependencies specified via dependencies and arguments specified in nodeParams. It is possible for numDependencies to be 0, in which case the node will be placed at the root of the graph. dependencies may not have any duplicate entries. A handle to the new node will be returned in pGraphNode. Performs a wait operation on a set of externally allocated semaphore objects when the node is launched. The node's dependencies will not be launched until the wait operation has completed. pGraphNode - Returns newly created node graph - Graph to which to add the node pDependencies - Dependencies of the node numDependencies - Number of dependencies nodeParams - for the node musaSuccess, musaErrorInvalidValue musaGraphAddNode, musaGraphExternalSemaphoresWaitNodeGetParams, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

Parameters:

  • musaGraphNode_t * pGraphNode: - Returns newly created node
  • musaGraph_t graph: - Graph to which to add the node
  • const musaGraphNode_t * pDependencies: - Dependencies of the node
  • size_t numDependencies: - Number of dependencies
  • const struct musaExternalSemaphoreWaitNodeParams * nodeParams: - Parameters for the node

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphAddNode, musaGraphExternalSemaphoresWaitNodeGetParams, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphCreate, musaGraphDestroyNode, musaGraphAddEventRecordNode, musaGraphAddEventWaitNode, musaGraphAddChildGraphNode, musaGraphAddEmptyNode, musaGraphAddKernelNode, musaGraphAddMemcpyNode, musaGraphAddMemsetNode

musaGraphExternalSemaphoresWaitNodeGetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExternalSemaphoresWaitNodeGetParams(musaGraphNode_t hNode, struct musaExternalSemaphoreWaitNodeParams *params_out)

Returns an external semaphore wait node's parameters.

Returns the parameters of an external semaphore wait node hNode in params_out. The extSemArray and paramsArray returned in params_out, are owned by the node. This memory remains valid until the node is destroyed or its parameters are modified, and should not be modified directly. Use musaGraphExternalSemaphoresSignalNodeSetParams to update the parameters of this node. hNode - Node to get the parameters for params_out - Pointer to return the parameters musaSuccess, musaErrorInvalidValue musaLaunchKernel, musaGraphAddExternalSemaphoresWaitNode, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaGraphNode_t hNode: - Node to get the parameters for
  • struct musaExternalSemaphoreWaitNodeParams * params_out: - Pointer to return the parameters

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaLaunchKernel, musaGraphAddExternalSemaphoresWaitNode, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaGraphExternalSemaphoresWaitNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExternalSemaphoresWaitNodeSetParams(musaGraphNode_t hNode, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Sets an external semaphore wait node's parameters.

Sets the parameters of an external semaphore wait node hNode to nodeParams. hNode - Node to set the parameters for nodeParams - to copy musaSuccess, musaErrorInvalidValue musaGraphNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

Parameters:

  • musaGraphNode_t hNode: - Node to set the parameters for
  • const struct musaExternalSemaphoreWaitNodeParams * nodeParams: - Parameters to copy

Returns:

musaSuccess, musaErrorInvalidValue

See also:

musaGraphNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaGraphExternalSemaphoresWaitNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync

musaGraphExecExternalSemaphoresSignalNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecExternalSemaphoresSignalNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, const struct musaExternalSemaphoreSignalNodeParams *nodeParams)

Sets the event for an event wait node in the given graphExec.

Sets the event of an event wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call. hGraphExec - The executable graph in which to set the specified node hNode - Event wait node from the graph from which graphExec was instantiated event - Updated event to use musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddEventWaitNode, musaGraphEventWaitNodeGetEvent, musaGraphEventRecordNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate Sets the parameters for an external semaphore signal node in the given graphExec Sets the parameters of an external semaphore signal node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated. hNode must not have been removed from the original graph. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call. Changing nodeParams->numExtSems is not supported. hGraphExec - The executable graph in which to set the specified node hNode - semaphore signal node from the graph from which graphExec was instantiated nodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t hNode: - semaphore signal node from the graph from which graphExec was instantiated
  • const struct musaExternalSemaphoreSignalNodeParams * nodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue, musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddEventWaitNode, musaGraphEventWaitNodeGetEvent, musaGraphEventRecordNodeSetEvent, musaEventRecordWithFlags, musaStreamWaitEvent, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate musaGraphExecNodeSetParams, musaGraphAddExternalSemaphoresSignalNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresWaitNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaGraphExecExternalSemaphoresWaitNodeSetParams

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaGraphExecExternalSemaphoresWaitNodeSetParams(musaGraphExec_t hGraphExec, musaGraphNode_t hNode, const struct musaExternalSemaphoreWaitNodeParams *nodeParams)

Sets the parameters for an external semaphore wait node in the given graphExec.

Sets the parameters of an external semaphore wait node in an executable graph hGraphExec. The node is identified by the corresponding node hNode in the non-executable graph, from which the executable graph was instantiated. hNode must not have been removed from the original graph. The modifications only affect future launches of hGraphExec. Already enqueued or running launches of hGraphExec are not affected by this call. hNode is also not modified by this call. Changing nodeParams->numExtSems is not supported. hGraphExec - The executable graph in which to set the specified node hNode - semaphore wait node from the graph from which graphExec was instantiated nodeParams - Updated to set musaSuccess, musaErrorInvalidValue, musaGraphExecNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

Parameters:

  • musaGraphExec_t hGraphExec: - The executable graph in which to set the specified node
  • musaGraphNode_t hNode: - semaphore wait node from the graph from which graphExec was instantiated
  • const struct musaExternalSemaphoreWaitNodeParams * nodeParams: - Updated Parameters to set

Returns:

musaSuccess, musaErrorInvalidValue,

See also:

musaGraphExecNodeSetParams, musaGraphAddExternalSemaphoresWaitNode, musaImportExternalSemaphore, musaSignalExternalSemaphoresAsync, musaWaitExternalSemaphoresAsync, musaGraphExecKernelNodeSetParams, musaGraphExecMemcpyNodeSetParams, musaGraphExecMemsetNodeSetParams, musaGraphExecHostNodeSetParams, musaGraphExecChildGraphNodeSetParams, musaGraphExecEventRecordNodeSetEvent, musaGraphExecEventWaitNodeSetEvent, musaGraphExecExternalSemaphoresSignalNodeSetParams, musaGraphExecUpdate, musaGraphInstantiate

musaKernelSetAttributeForDevice

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaKernelSetAttributeForDevice(musaKernel_t kernel, enum musaFuncAttribute attr, int value, int device)

Sets information about a kernel.

This call sets the value of a specified attribute attr on the kernel kernel for the requested device device to an integer value specified by value. This function returns musaSuccess if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result in an error (musaErrorInvalidValue) Note that attributes set using musaFuncSetAttribute() will override the attribute set by this API irrespective of whether the call to musaFuncSetAttribute() is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested that this call be used during the initialization path and not on each thread accessing kernel such as on kernel launches or on the critical path. Valid values for attr are: musaFuncAttributeMaxDynamicSharedMemorySize - The requested maximum size in bytes of dynamically-allocated shared memory. The sum of this value and the function attribute sharedSizeBytes cannot exceed the device attribute musaDevAttrMaxSharedMemoryPerBlockOptin. The maximal size of requestable dynamic shared memory may differ by GPU architecture. musaFuncAttributePreferredSharedMemoryCarveout - On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory. See musaDevAttrMaxSharedMemoryPerMultiprocessor. This is only a hint, and the driver can choose a different ratio if required to execute the function. musaFuncAttributeRequiredClusterWidth: The required cluster width in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterHeight: The required cluster height in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeRequiredClusterDepth: The required cluster depth in blocks. The width, height, and depth values must either all be 0 or all be positive. The validity of the cluster dimensions is checked at launch time. If the value is set during compile time, it cannot be set at runtime. Setting it at runtime will return musaErrorNotPermitted. musaFuncAttributeNonPortableClusterSizeAllowed: Indicates whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. musaFuncAttributeClusterSchedulingPolicyPreference: The block scheduling policy of a function. The value type is musaClusterSchedulingPolicy. The API has stricter locking requirements in comparison to its legacy counterpart musaFuncSetAttribute() due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously, the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency. kernel - Kernel to set attribute of attr - Attribute requested value - Value to set device - Device to set attribute of musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetKernel, musaLaunchKernel, musaFuncSetAttribute, muKernelSetAttribute

Parameters:

  • musaKernel_t kernel: - Kernel to set attribute of
  • enum musaFuncAttribute attr: - Attribute requested
  • int value: - Value to set
  • int device: - Device to set attribute of

Returns:

musaSuccess, musaErrorInvalidDeviceFunction, musaErrorInvalidValue

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetKernel, musaLaunchKernel, musaFuncSetAttribute, muKernelSetAttribute

musaLibraryEnumerateKernels

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryEnumerateKernels(musaKernel_t *kernels, unsigned int numKernels, musaLibrary_t lib)

Retrieve the kernel handles within a library.

Returns in kernels a maximum number of numKernels kernel handles within lib. The returned kernel handle becomes invalid when the library is unloaded. kernels - Buffer where the kernel handles are returned to numKernels - Maximum number of kernel handles may be returned to the buffer lib - Library to query from musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaLibraryGetKernelCount, muLibraryEnumerateKernels

Parameters:

  • musaKernel_t * kernels: - Buffer where the kernel handles are returned to
  • unsigned int numKernels: - Maximum number of kernel handles may be returned to the buffer
  • musaLibrary_t lib: - Library to query from

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaLibraryGetKernelCount, muLibraryEnumerateKernels

musaLibraryGetGlobal

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryGetGlobal(void **dptr, size_t *bytes, musaLibrary_t library, const char *name)

Returns a global device pointer.

Returns in *dptr and *bytes the base pointer and size of the global with name name for the requested library library and the current device. If no global for the requested name name exists, the call returns musaErrorSymbolNotFound. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored. The returned dptr cannot be passed to the Symbol APIs such as musaMemcpyToSymbol, musaMemcpyFromSymbol, musaGetSymbolAddress, or musaGetSymbolSize. dptr - Returned global device pointer for the requested library bytes - Returned global size in bytes library - Library to retrieve global from name - Name of global to retrieve musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaErrorDeviceUninitialized, musaErrorContextIsDestroyed musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetManaged, muLibraryGetGlobal

Parameters:

  • void ** dptr: - Returned global device pointer for the requested library
  • size_t * bytes: - Returned global size in bytes
  • musaLibrary_t library: - Library to retrieve global from
  • const char * name: - Name of global to retrieve

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaErrorDeviceUninitialized, musaErrorContextIsDestroyed

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetManaged, muLibraryGetGlobal

musaLibraryGetKernel

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryGetKernel(musaKernel_t *pKernel, musaLibrary_t library, const char *name)

Returns a kernel handle.

Returns in pKernel the handle of the kernel with name name located in library library. If kernel handle is not found, the call returns musaErrorSymbolNotFound. pKernel - Returned kernel handle library - Library to retrieve kernel from name - Name of kernel to retrieve musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, muLibraryGetKernel

Parameters:

  • musaKernel_t * pKernel: - Returned kernel handle
  • musaLibrary_t library: - Library to retrieve kernel from
  • const char * name: - Name of kernel to retrieve

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, muLibraryGetKernel

musaLibraryGetKernelCount

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryGetKernelCount(unsigned int *count, musaLibrary_t lib)

Returns the number of kernels within a library.

Returns in count the number of kernels in lib. count - Number of kernels found within the library lib - Library to query musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle musaLibraryEnumerateKernels, musaLibraryLoadFromFile, musaLibraryLoadData, muLibraryGetKernelCount

Parameters:

  • unsigned int * count: - Number of kernels found within the library
  • musaLibrary_t lib: - Library to query

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle

See also:

musaLibraryEnumerateKernels, musaLibraryLoadFromFile, musaLibraryLoadData, muLibraryGetKernelCount

musaLibraryGetManaged

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryGetManaged(void **dptr, size_t *bytes, musaLibrary_t library, const char *name)

Returns a pointer to managed memory.

Returns in *dptr and *bytes the base pointer and size of the managed memory with name name for the requested library library. If no managed memory with the requested name name exists, the call returns musaErrorSymbolNotFound. One of the parameters dptr or bytes (not both) can be NULL in which case it is ignored. Note that managed memory for library library is shared across devices and is registered when the library is loaded. The returned dptr cannot be passed to the Symbol APIs such as musaMemcpyToSymbol, musaMemcpyFromSymbol, musaGetSymbolAddress, or musaGetSymbolSize. dptr - Returned pointer to the managed memory bytes - Returned memory size in bytes library - Library to retrieve managed memory from name - Name of managed memory to retrieve musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetGlobal, muLibraryGetManaged

Parameters:

  • void ** dptr: - Returned pointer to the managed memory
  • size_t * bytes: - Returned memory size in bytes
  • musaLibrary_t library: - Library to retrieve managed memory from
  • const char * name: - Name of managed memory to retrieve

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, musaLibraryGetGlobal, muLibraryGetManaged

musaLibraryGetUnifiedFunction

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryGetUnifiedFunction(void **fptr, musaLibrary_t library, const char *symbol)

Returns a pointer to a unified function.

Returns in *fptr the function pointer to a unified function denoted by symbol. If no unified function with name symbol exists, the call returns musaErrorSymbolNotFound. If there is no device with attribute musaDevicePropunifiedFunctionPointers present in the system, the call may return musaErrorSymbolNotFound. fptr - Returned pointer to a unified function library - Library to retrieve function pointer memory from symbol - Name of function pointer to retrieve musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, muLibraryGetUnifiedFunction

Parameters:

  • void ** fptr: - Returned pointer to a unified function
  • musaLibrary_t library: - Library to retrieve function pointer memory from
  • const char * symbol: - Name of function pointer to retrieve

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue, musaErrorInvalidResourceHandle, musaErrorSymbolNotFound

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, musaLibraryUnload, muLibraryGetUnifiedFunction

musaLibraryLoadData

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryLoadData(musaLibrary_t *library, const void *code, enum musaJitOption *jitOptions, void **jitOptionsValues, unsigned int numJitOptions, enum musaLibraryOption *libraryOptions, void **libraryOptionValues, unsigned int numLibraryOptions)

Load a library with specified code and options.

Takes a pointer code and loads the corresponding library library based on the application defined library loading mode: If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with musaLibraryUnload(). If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch. These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section. The code may be a cubin or fatbin as output by mtcc, or a NULL-terminated PTX, either as output by mtcc or hand-written. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.mthreads.com/musa/nvrtc/index.html), nvjitlink (https://docs.mthreads.com/musa/nvjitlink/index.html), and nvfatbin (https://docs.mthreads.com/musa/nvfatbin/index.html) for more information on generating loadable code at runtime. Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total JIT options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues. Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions. library - Returned library code - Code to load jitOptions - Options for JIT jitOptionsValues - Option values for JIT numJitOptions - Number of options libraryOptions - Options for loading libraryOptionValues - Option values for loading numLibraryOptions - Number of options for loading musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound musaLibraryLoadFromFile, musaLibraryUnload, muLibraryLoadData

Parameters:

  • musaLibrary_t * library: - Returned library
  • const void * code: - Code to load
  • enum musaJitOption * jitOptions: - Options for JIT
  • void ** jitOptionsValues: - Option values for JIT
  • unsigned int numJitOptions: - Number of options
  • enum musaLibraryOption * libraryOptions: - Options for loading
  • void ** libraryOptionValues: - Option values for loading
  • unsigned int numLibraryOptions: - Number of options for loading

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound

See also:

musaLibraryLoadFromFile, musaLibraryUnload, muLibraryLoadData

musaLibraryLoadFromFile

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryLoadFromFile(musaLibrary_t *library, const char *fileName, enum musaJitOption *jitOptions, void **jitOptionsValues, unsigned int numJitOptions, enum musaLibraryOption *libraryOptions, void **libraryOptionValues, unsigned int numLibraryOptions)

Load a library with specified file and options.

Takes a pointer code and loads the corresponding library library based on the application defined library loading mode: If module loading is set to EAGER, via the environment variables described in "Module loading", library is loaded eagerly into all contexts at the time of the call and future contexts at the time of creation until the library is unloaded with musaLibraryUnload(). If the environment variables are set to LAZY, library is not immediately loaded onto all existent contexts and will only be loaded when a function is needed for that context, such as a kernel launch. These environment variables are described in the MUSA programming guide under the "MUSA environment variables" section. The file should be a cubin file as output by mtcc, or a PTX file either as output by mtcc or handwritten, or a fatbin file as output by mtcc. A fatbin should also contain relocatable code when doing separate compilation. Please also see the documentation for nvrtc (https://docs.mthreads.com/musa/nvrtc/index.html), nvjitlink (https://docs.mthreads.com/musa/nvjitlink/index.html), and nvfatbin (https://docs.mthreads.com/musa/nvfatbin/index.html) for more information on generating loadable code at runtime. Options are passed as an array via jitOptions and any corresponding parameters are passed in jitOptionsValues. The number of total options is supplied via numJitOptions. Any outputs will be returned via jitOptionsValues. Library load options are passed as an array via libraryOptions and any corresponding parameters are passed in libraryOptionValues. The number of total library load options is supplied via numLibraryOptions. library - Returned library fileName - File to load from jitOptions - Options for JIT jitOptionsValues - Option values for JIT numJitOptions - Number of options libraryOptions - Options for loading libraryOptionValues - Option values for loading numLibraryOptions - Number of options for loading musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound musaLibraryLoadData, musaLibraryUnload, muLibraryLoadFromFile

Parameters:

  • musaLibrary_t * library: - Returned library
  • const char * fileName: - File to load from
  • enum musaJitOption * jitOptions: - Options for JIT
  • void ** jitOptionsValues: - Option values for JIT
  • unsigned int numJitOptions: - Number of options
  • enum musaLibraryOption * libraryOptions: - Options for loading
  • void ** libraryOptionValues: - Option values for loading
  • unsigned int numLibraryOptions: - Number of options for loading

Returns:

musaSuccess, musaErrorInvalidValue, musaErrorMemoryAllocation, musaErrorInitializationError, musaErrorMusartUnloading, musaErrorInvalidPtx, musaErrorUnsupportedPtxVersion, musaErrorNoKernelImageForDevice, musaErrorSharedObjectSymbolNotFound, musaErrorSharedObjectInitFailed, musaErrorJitCompilerNotFound

See also:

musaLibraryLoadData, musaLibraryUnload, muLibraryLoadFromFile

musaLibraryUnload

Header: musa_runtime_api.h

__host__ musaError_t MUSARTAPI musaLibraryUnload(musaLibrary_t library)

Unloads a library.

Unloads the library specified with library library - Library to unload musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue musaLibraryLoadData, musaLibraryLoadFromFile, muLibraryUnload

Parameters:

  • musaLibrary_t library: - Library to unload

Returns:

musaSuccess, musaErrorMusartUnloading, musaErrorInitializationError, musaErrorInvalidValue

See also:

musaLibraryLoadData, musaLibraryLoadFromFile, muLibraryUnload