Cupti: CUPTI PC Sampling Utility API

# CUPTI PC Sampling Utility API

## Data Structures
struct | BufferInfo
| BufferInfo will be stored in the file for every buffer i.e for every call of UtilDumpPcSamplingBufferInFile() API. More...
struct | CUPTI::PcSamplingUtil::CUptiUtil_GetBufferInfoParams
| Params for CuptiUtilGetBufferInfo. More...
struct | CUPTI::PcSamplingUtil::CUptiUtil_GetHeaderDataParams
| Params for CuptiUtilGetHeaderData. More...
struct | CUPTI::PcSamplingUtil::CUptiUtil_GetPcSampDataParams
| Params for CuptiUtilGetPcSampData. More...
struct | CUPTI::PcSamplingUtil::CUptiUtil_MergePcSampDataParams
| Params for CuptiUtilMergePcSampData. More...
struct | CUPTI::PcSamplingUtil::CUptiUtil_PutPcSampDataParams
| Params for CuptiUtilPutPcSampData. More...
struct | Header
| Header info will be stored in file. More...
struct | PcSamplingStallReasons
| All available stall reasons name and respective indexes will be stored in it. More...
## Enumerations
enum | CUPTI::PcSamplingUtil::CUptiUtilResult { CUPTI::PcSamplingUtil::CUPTI_UTIL_SUCCESS = 0, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_INVALID_PARAMETER = 1, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_UNABLE_TO_CREATE_FILE = 2, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_UNABLE_TO_OPEN_FILE = 3, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED = 4, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_FILE_HANDLE_CORRUPTED = 5, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_SEEK_OPERATION_FAILED = 6, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_OUT_OF_MEMORY = 7, CUPTI::PcSamplingUtil::CUPTI_UTIL_ERROR_UNKNOWN = 999 }
| CUPTI PC sampling utility API result codes. More...
enum | CUPTI::PcSamplingUtil::PcSamplingBufferType { CUPTI::PcSamplingUtil::PC_SAMPLING_BUFFER_INVALID = 0, CUPTI::PcSamplingUtil::PC_SAMPLING_BUFFER_PC_TO_COUNTER_DATA = 1 }
## Functions
CUptiUtilResult CUPTIUTILAPI | CUPTI::PcSamplingUtil::CuptiUtilGetBufferInfo (CUptiUtil_GetBufferInfoParams *pParams)
| Get buffer info data of file.
CUptiUtilResult CUPTIUTILAPI | CUPTI::PcSamplingUtil::CuptiUtilGetHeaderData (CUptiUtil_GetHeaderDataParams *pParams)
| Get header data of file.
CUptiUtilResult CUPTIUTILAPI | CUPTI::PcSamplingUtil::CuptiUtilGetPcSampData (CUptiUtil_GetPcSampDataParams *pParams)
| Retrieve PC sampling data from file into allocated buffer.
CUptiUtilResult CUPTIUTILAPI | CUPTI::PcSamplingUtil::CuptiUtilMergePcSampData (CUptiUtil_MergePcSampDataParams *pParams)
| Merge PC sampling data range id wise.
CUptiUtilResult CUPTIUTILAPI | CUPTI::PcSamplingUtil::CuptiUtilPutPcSampData (CUptiUtil_PutPcSampDataParams *pParams)
| Dump PC sampling data into the file.

## Detailed Description

Functions, types, and enums that implement the CUPTI PC Sampling Utility API.

## Enumeration Type Documentation

enum CUPTI::PcSamplingUtil::CUptiUtilResult

Error and result codes returned by CUPTI PC sampling utility API.

Enumerator:

  CUPTI_UTIL_SUCCESS | No error
  CUPTI_UTIL_ERROR_INVALID_PARAMETER | One or more of the parameters are invalid.
  CUPTI_UTIL_ERROR_UNABLE_TO_CREATE_FILE | Unable to create a new file
  CUPTI_UTIL_ERROR_UNABLE_TO_OPEN_FILE | Unable to open a file
  CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED | Read or write operation failed
  CUPTI_UTIL_ERROR_FILE_HANDLE_CORRUPTED | Provided file handle is corrupted.
  CUPTI_UTIL_ERROR_SEEK_OPERATION_FAILED | seek operation failed.
  CUPTI_UTIL_ERROR_OUT_OF_MEMORY | Unable to allocate enough memory to perform the requested operation.
  CUPTI_UTIL_ERROR_UNKNOWN | An unknown internal error has occurred.

enum CUPTI::PcSamplingUtil::PcSamplingBufferType

Enumerator:

  PC_SAMPLING_BUFFER_INVALID | Invalid buffer type.
  PC_SAMPLING_BUFFER_PC_TO_COUNTER_DATA | Refers to CUpti_PCSamplingData buffer.

## Function Documentation

CUptiUtilResult CUPTIUTILAPI CUPTI::PcSamplingUtil::CuptiUtilGetBufferInfo | ( | CUptiUtil_GetBufferInfoParams * | pParams | ) |

This API must be called every time before calling CuptiUtilGetPcSampData API. BufferInfo structure, it gives info about recordCount and stallReasonCount of every record in the buffer. This will help to allocate exact buffer to retrieve data into it.

Return values:

  | CUPTI_UTIL_SUCCESS |
  | CUPTI_UTIL_ERROR_INVALID_PARAMETER | error out if either of pParam or fileHandle is NULL or param struct size is incorrect.
  | CUPTI_UTIL_ERROR_FILE_HANDLE_CORRUPTED | file handle is not in good state to read data from file.
  | CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED | failed to read data from file.

CUptiUtilResult CUPTIUTILAPI CUPTI::PcSamplingUtil::CuptiUtilGetHeaderData | ( | CUptiUtil_GetHeaderDataParams * | pParams | ) |

This API must be called once initially while retrieving data from file. Header structure, it gives info about total number of buffers present in the file.

Return values:

  | CUPTI_UTIL_SUCCESS |
  | CUPTI_UTIL_ERROR_INVALID_PARAMETER | error out if either of pParam or fileHandle is NULL or param struct size is incorrect.
  | CUPTI_UTIL_ERROR_FILE_HANDLE_CORRUPTED | file handle is not in good state to read data from file
  | CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED | failed to read data from file.

CUptiUtilResult CUPTIUTILAPI CUPTI::PcSamplingUtil::CuptiUtilGetPcSampData | ( | CUptiUtil_GetPcSampDataParams * | pParams | ) |

This API must be called after CuptiUtilGetBufferInfo API. It will retrieve data from file into allocated buffer.

Return values:

  | CUPTI_UTIL_SUCCESS |
  | CUPTI_UTIL_ERROR_INVALID_PARAMETER | error out if buffer type is invalid or if either of pSampData, pParams is NULL. If pPcSamplingStallReasons is not NULL then error out if either of stallReasonIndex, stallReasons or stallReasons array element pointer is NULL. or filename is empty.
  | CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED |
  | CUPTI_UTIL_ERROR_FILE_HANDLE_CORRUPTED | file handle is not in good state to read data from file.

CUptiUtilResult CUPTIUTILAPI CUPTI::PcSamplingUtil::CuptiUtilMergePcSampData | ( | CUptiUtil_MergePcSampDataParams * | pParams | ) |

This API merge PC sampling data range id wise. It allocates memory for merged data and fill data in it and provide buffer pointer in MergedPcSampDataBuffers field. It is expected from user to free merge data buffers after use.

Return values:

  | CUPTI_UTIL_SUCCESS |
  | CUPTI_UTIL_ERROR_INVALID_PARAMETER | error out if param struct size is invalid or count of buffers to merge is invalid i.e less than 1 or either of PcSampDataBuffer, MergedPcSampDataBuffers, numMergedBuffer is NULL
  | CUPTI_UTIL_ERROR_OUT_OF_MEMORY | Unable to allocate memory for merged buffer.

CUptiUtilResult CUPTIUTILAPI CUPTI::PcSamplingUtil::CuptiUtilPutPcSampData | ( | CUptiUtil_PutPcSampDataParams * | pParams | ) |

This API can be called multiple times. It will append buffer in the file. For every buffer it will store BufferInfo so that before retrieving data it will help to allocate buffer to store retrieved data. This API creates file if file does not present. If stallReasonIndex or stallReasons pointer of CUptiUtil_PutPcSampDataParams is NULL then stall reasons data will not be stored in file. It is expected to store all available stall reason data at least once to refer it during offline correlation.

Return values:

  | CUPTI_UTIL_SUCCESS |
  | CUPTI_UTIL_ERROR_INVALID_PARAMETER | error out if buffer type is invalid or if either of pSamplingData, pParams pointer is NULL or stall reason configuration details not provided or filename is empty.
  | CUPTI_UTIL_ERROR_UNABLE_TO_CREATE_FILE |
  | CUPTI_UTIL_ERROR_UNABLE_TO_OPEN_FILE |
  | CUPTI_UTIL_ERROR_READ_WRITE_OPERATION_FAILED |