Handle

Handle#

MIOpen: Handle

Typedefs

typedef void *(* miopenAllocatorFunction) (void *context, size_t sizeBytes)
 Custom allocator function. More...
 
typedef void(* miopenDeallocatorFunction) (void *context, void *memory)
 Custom deallocator function. More...
 

Enumerations

enum  miopenStatus_t {
  miopenStatusSuccess = 0 ,
  miopenStatusNotInitialized = 1 ,
  miopenStatusInvalidValue = 2 ,
  miopenStatusBadParm = 3 ,
  miopenStatusAllocFailed = 4 ,
  miopenStatusInternalError = 5 ,
  miopenStatusNotImplemented = 6 ,
  miopenStatusUnknownError = 7 ,
  miopenStatusUnsupportedOp = 8 ,
  miopenStatusGpuOperationsSkipped = 9 ,
  miopenStatusVersionMismatch = 10
}
 
enum  miopenF8RoundingMode_t {
  miopenF8RoundingModeStandard = 0 ,
  miopenF8RoundingModeStochastic = 1
}
 

Functions

 MIOPEN_DECLARE_OBJECT (miopenHandle)
 Creates the miopenHandle_t type. More...
 
const char * miopenGetErrorString (miopenStatus_t error)
 Get character string for an error code. More...
 
miopenStatus_t miopenGetVersion (size_t *major, size_t *minor, size_t *patch)
 Method to return version of MIOpen. More...
 
miopenStatus_t miopenCreate (miopenHandle_t *handle)
 Method to create the MIOpen handle object. More...
 
miopenStatus_t miopenCreateWithStream (miopenHandle_t *handle, miopenAcceleratorQueue_t stream)
 Create a MIOpen handle with an accelerator stream. More...
 
miopenStatus_t miopenDestroy (miopenHandle_t handle)
 Destroys the MIOpen handle. More...
 
miopenStatus_t miopenSetStream (miopenHandle_t handle, miopenAcceleratorQueue_t streamID)
 Set accelerator command queue previously created. More...
 
miopenStatus_t miopenGetStream (miopenHandle_t handle, miopenAcceleratorQueue_t *streamID)
 Get the previously created accelerator command queue. More...
 
miopenStatus_t miopenSetAllocator (miopenHandle_t handle, miopenAllocatorFunction allocator, miopenDeallocatorFunction deallocator, void *allocatorContext)
 Set allocator for previously created miopenHandle. More...
 
miopenStatus_t miopenGetKernelTime (miopenHandle_t handle, float *time)
 Get time for last kernel launched. More...
 
miopenStatus_t miopenEnableProfiling (miopenHandle_t handle, bool enable)
 Enable profiling to retrieve kernel time. More...
 

Detailed Description

Typedef Documentation

◆ miopenAllocatorFunction

typedef void*(* miopenAllocatorFunction) (void *context, size_t sizeBytes)

Custom allocator function.

This function allow for user-defined custom allocator

Parameters
contextA pointer a context (input)
sizeBytesNumber of bytes to allocate (input)
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenDeallocatorFunction

typedef void(* miopenDeallocatorFunction) (void *context, void *memory)

Custom deallocator function.

This function allow for user-defined custom deallocation function

Parameters
contextA pointer context (input)
memoryA pointer allocated memory (input)
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

Enumeration Type Documentation

◆ miopenF8RoundingMode_t

◆ miopenStatus_t

Error codes that are returned by all MIOpen API calls.

Enumerator
miopenStatusSuccess 

No errors

miopenStatusNotInitialized 

Data not initialized.

miopenStatusInvalidValue 

Incorrect variable value.

miopenStatusBadParm 

Incorrect parameter detected.

miopenStatusAllocFailed 

Memory allocation error.

miopenStatusInternalError 

MIOpen failure.

miopenStatusNotImplemented 

Use of unimplemented feature.

miopenStatusUnknownError 

Unknown error occurred.

miopenStatusUnsupportedOp 

Unsupported operator for fusion.

miopenStatusGpuOperationsSkipped 

This is not an error.

miopenStatusVersionMismatch 

Version mismatch of the supplied binary data argment.

Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

Function Documentation

◆ MIOPEN_DECLARE_OBJECT()

MIOPEN_DECLARE_OBJECT ( miopenHandle  )

Creates the miopenHandle_t type.

◆ miopenCreate()

miopenStatus_t miopenCreate ( miopenHandle_t *  handle)

Method to create the MIOpen handle object.

This function creates a MIOpen handle. This is called at the very start to initialize the MIOpen environment.

Parameters
handleA pointer to a MIOpen handle type (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenCreateWithStream()

miopenStatus_t miopenCreateWithStream ( miopenHandle_t *  handle,
miopenAcceleratorQueue_t  stream 
)

Create a MIOpen handle with an accelerator stream.

The HIP side uses a hipStream_t type for the stream, while OpenCL will use a cl_command_queue.

Create a handle with a previously created accelerator command queue.

Parameters
handleA pointer to a MIOpen handle type (output)
streamAn accelerator queue type (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenDestroy()

miopenStatus_t miopenDestroy ( miopenHandle_t  handle)

Destroys the MIOpen handle.

This is called when breaking down the MIOpen environment.

Parameters
handleMIOpen handle (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenEnableProfiling()

miopenStatus_t miopenEnableProfiling ( miopenHandle_t  handle,
bool  enable 
)

Enable profiling to retrieve kernel time.

Enable or disable kernel profiling. This profiling is only for kernel time.

Parameters
handleMIOpen handle (input)
enableBoolean to toggle profiling (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenGetErrorString()

const char* miopenGetErrorString ( miopenStatus_t  error)

Get character string for an error code.

A function which returns a NULL terminated character string of the error code.

Parameters
errormiopenStatus_t type error status (input)
Returns
errorString
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenGetKernelTime()

miopenStatus_t miopenGetKernelTime ( miopenHandle_t  handle,
float *  time 
)

Get time for last kernel launched.

This function is used only when profiling mode has been enabled. Kernel timings are based on the MIOpen handle and is not thread-safe. In order to use multi-threaded profiling, create an MIOpen handle for each concurrent thread.

Parameters
handleMIOpen handle (input)
timePointer to a float type to contain kernel time in milliseconds (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenGetStream()

miopenStatus_t miopenGetStream ( miopenHandle_t  handle,
miopenAcceleratorQueue_t *  streamID 
)

Get the previously created accelerator command queue.

Creates a command queue for an accelerator device

Parameters
handleMIOpen handle (input)
streamIDPointer to a accelerator queue type (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenGetVersion()

miopenStatus_t miopenGetVersion ( size_t *  major,
size_t *  minor,
size_t *  patch 
)

Method to return version of MIOpen.

The output values of this call follow from the versioning format major.minor.patch

Pointers that are NULL will be ignored.

Parameters
majorMajor version number (output)
minorMinor version number (output)
patchPatch version number (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenSetAllocator()

miopenStatus_t miopenSetAllocator ( miopenHandle_t  handle,
miopenAllocatorFunction  allocator,
miopenDeallocatorFunction  deallocator,
void *  allocatorContext 
)

Set allocator for previously created miopenHandle.

Set a command queue for an accelerator device

Parameters
handleMIOpen handle
allocatorA callback function MIOpen will use for internal memory allocations. The provided callback function should allocate device memory with requested size and return a pointer to this memory. Passing 0 will restore the default MIOpen allocator and deallocator.
deallocatorA callback function MIOpen will use to for internal memory deallocation. The provided callback function should free the specified memory pointer
allocatorContextUser-specified pointer which is passed to allocator and deallocator This allows the callback function to access state set by the caller to this function, for example a stateful heap allocator or a c++ class.
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenSetStream()

miopenStatus_t miopenSetStream ( miopenHandle_t  handle,
miopenAcceleratorQueue_t  streamID 
)

Set accelerator command queue previously created.

Set a command queue for an accelerator device

Parameters
handleMIOpen handle (input)
streamIDAn accelerator queue type (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.