Src/GPUPerfAPIHSA/GPUPerfAPIHSA.cpp
/// Pre-dispatch callback function
/// \param pRTParam the pre-dispatch callback params
/// \param pUserArgs the user arguments
Pre-dispatch callback function
\param pRTParam the pre-dispatch callback params
\param pUserArgs the user arguments
Pre - dispatch callback function \ param pRTParam the pre - dispatch callback params \ param pUserArgs the user arguments
void HSA_PreDispatchCallback(const hsa_dispatch_callback_t* pRTParam, void* pUserArgs)
{
    UNREFERENCED_PARAMETER(pUserArgs);
    assert(nullptr != pRTParam && true == pRTParam->pre_dispatch);
    HSAToolsRTModule* pHsaToolsRTModule = HSAToolsRTModuleLoader::Instance()->GetAPIRTModule();
    if (nullptr == pHsaToolsRTModule || !pHsaToolsRTModule->IsModuleLoaded())
    {
        GPA_LogError("Unable to load HSA tools runtime module.");
    }
    else
    {
        GPA_ContextStateHSA* pContextState = getCurrentContext();
        if (nullptr != pContextState)
        {
            pContextState->m_pAqlTranslationHandle = pRTParam->aql_translation_handle;
            if (pContextState->m_currentPass > 0)
            {
                GPA_DataRequest* pRequest = pContextState->GetDataRequest(g_pCurrentContext->m_currentPass - 1);
                if (nullptr != pRequest)
                {
                    pRequest->SetSampleID(HSAGlobalFlags::Instance()->m_sampleID);
                    bool requestOk = pRequest->Begin(pContextState, pContextState->m_selectionID, pContextState->m_pCounterScheduler->GetCountersForPass(pContextState->m_currentPass - 1));
                    if (!requestOk)
                    {
                        GPA_LogError("Failed to begin request.");
                        return;
                    }
                    g_pCurrentContext->m_pCurrentSessionRequests->Begin(pContextState->m_currentPass - 1, HSAGlobalFlags::Instance()->m_sampleID, pRequest);
                }
                else
                {
                    GPA_LogError("Failed to get data request.");
                }
            }
        }
    }
}
void HSA_PreDispatchCallback ( const hsa_dispatch_callback_t * pRTParam , void * pUserArgs ) { UNREFERENCED_PARAMETER ( pUserArgs ) ; assert ( nullptr != pRTParam && true == pRTParam -> pre_dispatch ) ; HSAToolsRTModule * pHsaToolsRTModule = HSAToolsRTModuleLoader :: Instance ( ) -> GetAPIRTModule ( ) ; if ( nullptr == pHsaToolsRTModule || ! pHsaToolsRTModule -> IsModuleLoaded ( ) ) { GPA_LogError ( " " ) ; } else { GPA_ContextStateHSA * pContextState = getCurrentContext ( ) ; if ( nullptr != pContextState ) { pContextState -> m_pAqlTranslationHandle = pRTParam -> aql_translation_handle ; if ( pContextState -> m_currentPass > 0 ) { GPA_DataRequest * pRequest = pContextState -> GetDataRequest ( g_pCurrentContext -> m_currentPass - 1 ) ; if ( nullptr != pRequest ) { pRequest -> SetSampleID ( HSAGlobalFlags :: Instance ( ) -> m_sampleID ) ; bool requestOk = pRequest -> Begin ( pContextState , pContextState -> m_selectionID , pContextState -> m_pCounterScheduler -> GetCountersForPass ( pContextState -> m_currentPass - 1 ) ) ; if ( ! requestOk ) { GPA_LogError ( " " ) ; return ; } g_pCurrentContext -> m_pCurrentSessionRequests -> Begin ( pContextState -> m_currentPass - 1 , HSAGlobalFlags :: Instance ( ) -> m_sampleID , pRequest ) ; } else { GPA_LogError ( " " ) ; } } } } }
Pre-dispatch callback function
\param pRTParam the pre-dispatch callback params
\param pUserArgs the user arguments
Pre - dispatch callback function \ param pRTParam the pre - dispatch callback params \ param pUserArgs the user arguments
// issue request for counter data // add new request to current session requests list