Virtual Function Management Extension

Virtual Function Management Extension#

API#

Virtual Function Management#

This feature adds the ability to retrieve telemetry from PF domain for monitoring per VF memory and engine utilization. This telemetry is used to determine if a VM has oversubscribed GPU memory or observe engine business for a targeted workload. If VF has no activity value to report, then implementation shall reflect that appropriately in zes_vf_util_engine_exp_t struct so that percentage calculation results in value of 0.

The following pseudo-code demonstrates a sequence for obtaining the engine activity for all Virtual Functions from Physical Function environment:

// Gather count of VF handles
uint32_t numVf = 0;
zes_vf_exp_capabilities_t vfProps {};
zesDeviceEnumEnabledVFExp(hDevice, &numVf, nullptr);

// Allocate memory for vf handles and call back in to gather handles
std::vector<zes_vf_handle_t> vfs(numVf, nullptr);
zesDeviceEnumEnabledVFExp(hDevice, &numVf, vfs.data());

// Gather VF properties
std::vector <zes_vf_exp_capabilities_t> vfProps(numVf);
for (uint32_t i = 0; i < numVf; i++) {
    zesVFManagementGetVFCapabilitiesExp(vfs[i], &vfProps[i]);
}

// Detect the info types a particular VF supports

// Using VF# 0 to demonstrate how to detect engine info type and query engine util info
zes_vf_handle_t activeVf = vfs[0];
uint32_t engineStatCount = 0;

zesVFManagementGetVFEngineUtilizationExp(activeVf, &engineStatCount, nullptr);
// Allocate memory for vf engine stats
zes_vf_util_engine_exp_t* engineStats0 = (zes_vf_util_engine_exp_t*) allocate(engineStatCount * sizeof(zes_vf_util_engine_exp_t));
zesVFManagementGetVFEngineUtilizationExp(activeVf, &engineStatCount, engineStats0);
sleep(1)
zes_vf_util_engine_exp_t* engineStats1 = (zes_vf_util_engine_exp_t*) allocate(engineStatCount * sizeof(zes_vf_util_engine_exp_t));
zesVFManagementGetVFEngineUtilizationExp(activeVf, &engineStatCount, &engineStats1);