Src/GPUPerfAPI-Common/GPUPerfAPI.cpp
//-----------------------------------------------------------------------------
/// Local function which first tries to acquire device information
/// from the supplied hwInfo, which uses ADL to get the data.
/// If this method fails for any reason, this function will fall back
/// to having the API-specific implementation query the hw info.
/// If either of these methods succeeds, the API-specific implementation
/// is asked to verify support of the hardware, if not, then an error
/// code is returned.
/// \param pApiContext the context pointer supplied by the API
/// \param pHwInfo a pointer to the hwInfo structure that must be
/// filled in.
/// \return GPA_STATUS_OK if hardware is supported, an error status otherwise.
Local function which first tries to acquire device information
from the supplied hwInfo, which uses ADL to get the data.
If this method fails for any reason, this function will fall back
to having the API-specific implementation query the hw info.
If either of these methods succeeds, the API-specific implementation
is asked to verify support of the hardware, if not, then an error
code is returned.
\param pApiContext the context pointer supplied by the API
\param pHwInfo a pointer to the hwInfo structure that must be
filled in.
\return GPA_STATUS_OK if hardware is supported, an error status otherwise.
Local function which first tries to acquire device information from the supplied hwInfo which uses ADL to get the data . If this method fails for any reason this function will fall back to having the API - specific implementation query the hw info . If either of these methods succeeds the API - specific implementation is asked to verify support of the hardware if not then an error code is returned . \ param pApiContext the context pointer supplied by the API \ param pHwInfo a pointer to the hwInfo structure that must be filled in . \ return GPA_STATUS_OK if hardware is supported an error status otherwise .
GPA_Status GetHWInfo(void* pApiContext, GPA_HWInfo* pHwInfo)
{
    if (nullptr == pHwInfo)
    {
        GPA_LogDebugError("Parameter 'pHwInfo' is NULL.");
        return GPA_STATUS_ERROR_NULL_POINTER;
    }
    bool foundMatchingHWInfo = false;
    AsicInfoList asicInfoList;
    GPA_IMP_GetHWInfo(pApiContext, pHwInfo);
    if (pHwInfo->IsAMD())
    {
        AMDTADLUtils::Instance()->GetAsicInfoList(asicInfoList);
        if (0 == asicInfoList.size())
        {
            GPA_LogMessage("Cannot get asicInfoList from ADL.");
        }
        for (auto asicInfo : asicInfoList)
        {
            pHwInfo->SetVendorID(asicInfo.vendorID);
            pHwInfo->SetDeviceName(asicInfo.adapterName.c_str());
            pHwInfo->SetDeviceID(asicInfo.deviceID);
            pHwInfo->SetRevisionID(asicInfo.revID);
            pHwInfo->SetGpuIndex(asicInfo.gpuIndex);
            pHwInfo->UpdateDeviceInfoBasedOnDeviceID();
            if (GPA_IMP_CompareHWInfo(pApiContext, pHwInfo) == GPA_STATUS_OK)
            {
                foundMatchingHWInfo = true;
                break;
            }
        }
    }
#if defined(WIN32)
    if (false == foundMatchingHWInfo) 
    {
        Adapter adapter;
        asicInfoList.clear();
        if (adapter.getAsicInfoList(asicInfoList))
        {
            for (auto asicInfo : asicInfoList)
            {
                if (NVIDIA_VENDOR_ID == asicInfo.vendorID || INTEL_VENDOR_ID == asicInfo.vendorID) 
                {
                    pHwInfo->SetVendorID(asicInfo.vendorID);
                    pHwInfo->SetDeviceName(asicInfo.adapterName.c_str());
                    pHwInfo->SetDeviceID(asicInfo.deviceID);
                    pHwInfo->SetRevisionID(asicInfo.revID);
                    if (NVIDIA_VENDOR_ID == asicInfo.vendorID)
                    {
                        pHwInfo->SetHWGeneration(GDT_HW_GENERATION_NVIDIA);
                    }
                    else if (INTEL_VENDOR_ID == asicInfo.vendorID)
                    {
                        pHwInfo->SetHWGeneration(GDT_HW_GENERATION_INTEL);
                    }
                    if (GPA_STATUS_OK == GPA_IMP_CompareHWInfo(pApiContext, pHwInfo))
                    {
                        foundMatchingHWInfo = true;
                        break;
                    }
                }
            }
        }
        else
        {
            GPA_LogMessage("QueryAdapterInfo() failed.");
        }
    }
#endif 
    if (foundMatchingHWInfo == false)
    {
        GPA_Status status = GPA_IMP_GetHWInfo(pApiContext, pHwInfo);
        if (status != GPA_STATUS_OK)
        {
            GPA_LogError("Cannot identify graphics hardware.");
            return status;
        }
        bool deviceInfoOk = pHwInfo->UpdateDeviceInfoBasedOnDeviceID();
        if (deviceInfoOk == false)
        {
            GPA_LogError("Cannot update device information.");
            return GPA_STATUS_ERROR_HARDWARE_NOT_SUPPORTED;
        }
    }
    GPA_Status status = GPA_IMP_VerifyHWSupport(pApiContext, pHwInfo);
    return status;
}
GPA_Status GetHWInfo ( void * pApiContext , GPA_HWInfo * pHwInfo ) { if ( nullptr == pHwInfo ) { GPA_LogDebugError ( " " ) ; return GPA_STATUS_ERROR_NULL_POINTER ; } bool foundMatchingHWInfo = false ; AsicInfoList asicInfoList ; GPA_IMP_GetHWInfo ( pApiContext , pHwInfo ) ; if ( pHwInfo -> IsAMD ( ) ) { AMDTADLUtils :: Instance ( ) -> GetAsicInfoList ( asicInfoList ) ; if ( 0 == asicInfoList . size ( ) ) { GPA_LogMessage ( " " ) ; } for ( auto asicInfo : asicInfoList ) { pHwInfo -> SetVendorID ( asicInfo . vendorID ) ; pHwInfo -> SetDeviceName ( asicInfo . adapterName . c_str ( ) ) ; pHwInfo -> SetDeviceID ( asicInfo . deviceID ) ; pHwInfo -> SetRevisionID ( asicInfo . revID ) ; pHwInfo -> SetGpuIndex ( asicInfo . gpuIndex ) ; pHwInfo -> UpdateDeviceInfoBasedOnDeviceID ( ) ; if ( GPA_IMP_CompareHWInfo ( pApiContext , pHwInfo ) == GPA_STATUS_OK ) { foundMatchingHWInfo = true ; break ; } } } #if defined ( WIN32 ) if ( false == foundMatchingHWInfo ) { Adapter adapter ; asicInfoList . clear ( ) ; if ( adapter . getAsicInfoList ( asicInfoList ) ) { for ( auto asicInfo : asicInfoList ) { if ( NVIDIA_VENDOR_ID == asicInfo . vendorID || INTEL_VENDOR_ID == asicInfo . vendorID ) { pHwInfo -> SetVendorID ( asicInfo . vendorID ) ; pHwInfo -> SetDeviceName ( asicInfo . adapterName . c_str ( ) ) ; pHwInfo -> SetDeviceID ( asicInfo . deviceID ) ; pHwInfo -> SetRevisionID ( asicInfo . revID ) ; if ( NVIDIA_VENDOR_ID == asicInfo . vendorID ) { pHwInfo -> SetHWGeneration ( GDT_HW_GENERATION_NVIDIA ) ; } else if ( INTEL_VENDOR_ID == asicInfo . vendorID ) { pHwInfo -> SetHWGeneration ( GDT_HW_GENERATION_INTEL ) ; } if ( GPA_STATUS_OK == GPA_IMP_CompareHWInfo ( pApiContext , pHwInfo ) ) { foundMatchingHWInfo = true ; break ; } } } } else { GPA_LogMessage ( " " ) ; } } #endif if ( foundMatchingHWInfo == false ) { GPA_Status status = GPA_IMP_GetHWInfo ( pApiContext , pHwInfo ) ; if ( status != GPA_STATUS_OK ) { GPA_LogError ( " " ) ; return status ; } bool deviceInfoOk = pHwInfo -> UpdateDeviceInfoBasedOnDeviceID ( ) ; if ( deviceInfoOk == false ) { GPA_LogError ( " " ) ; return GPA_STATUS_ERROR_HARDWARE_NOT_SUPPORTED ; } } GPA_Status status = GPA_IMP_VerifyHWSupport ( pApiContext , pHwInfo ) ; return status ; }
Local function which first tries to acquire device information
from the supplied hwInfo, which uses ADL to get the data.
Local function which first tries to acquire device information from the supplied hwInfo which uses ADL to get the data .
// make sure there are available asics for AMD card. // In case there is no AMD driver, we output a message. // this device matches what the application is running on, so break from the loop. //NO ADL exist for clean system that has never had the AMD driver installed // support non-AMD use case (DX and GL only) // this device matches what the application is running on, so break from the loop. // WIN32 // NOTE: we don't expect to have to take this code path, it is a fall back, as we expect ADL to be available on machines. // Hopefully in the future we can remove this path. One potential issue is that we need to make sure we expose the counters // for the device being used. // if this is not GPA_STATUS_OK, then the API-specific implementation could not get the hardware information, // so there is no way to know if GPA should support this device. // GPA_IMP_GetHWInfo mostly gets basic information (namely just needs to get VendorID and DeviceID), so we need to update // the device info with additional information that we store per-deviceID. // If this fails, then the hardware must not be supported because we don't know enough about it // Give the API-specific implementation a chance to verify that the hardware is supported.