Metric Programmable Experimental Extension
Contents
Metric Programmable Experimental Extension¶
API¶
Enumerations
Structures
Functions
Metric Programmable¶
Application can use zetMetricGroupGet to enumerate the list of metric groups and zetMetricGet for the metrics available for collection. However Applications may also want to collect custom metrics which are not listed as part of the enumeration. This is made possible by making a list of programmable metrics available to the application, so that it may choose different parameter values for preparing custom metrics.
Sample Code¶
The following pseudo-code demonstrates how programmable metrics could be enumerated and custom values could be set to the metric parameters.
zet_metric_handle_t * metricHandles = null_ptr; uint32_t metricHandleCount = 0; zet_metric_group_handle_t metricGroup; // Query and Get metric programmable handles uint32_t programmableCount = 0; zetMetricProgrammableGetExp(device, &programmableCount, nullptr); zet_metric_programmable_exp_handle_t * metricProgrammableHandles = allocate(sizeof(zet_metric_programmable_exp_handle_t) * programmableCount); zetMetricProgrammableGetExp(device, &programmableCount, metricProgrammableHandles); // Create metrics from metric programmable handles for(uint32_t i = 0; i < programmableCount; i++){ zet_metric_programmable_exp_handle_t programmableHandle = metricProgrammableHandles[i]; zet_metric_programmable_exp_properties_t programmableProperties{}; zetMetricProgrammableGetPropertiesExp(programmableHandle, &programmableProperties); // Choose programmable handle of interest if(strcmp(programmableProperties.name, "EU_ACTIVE" ) == 0){ // Get Parameter info zet_metric_programmable_param_info_exp_t * paramInfo = allocate (sizeof(zet_metric_programmable_param_info_exp_t) * programmableProperties.parameterCount); zetMetricProgrammableGetParamInfoExp(programmableHandle, programmableProperties.parameterCount, paramInfo); // Get Parameter Value info for the 0th parameter zet_metric_programmable_param_value_info_exp_t * paramValueInfo = allocate(sizeof(zet_metric_programmable_param_value_info_exp_t) * paramInfo[0].valueInfoCount); zetMetricProgrammableGetParamValueInfoExp(programmableHandle, 0, paramInfo[0].valueInfoCount, paramValueInfo); // Setting value for the 0th parameter zet_metric_programmable_param_value_exp_t parameterValue; parameterValue.value = paramValueInfo[0].valueInfo.ui64; // Create Metric char metricName[ZET_MAX_METRIC_NAME] = "eu_active_minimum"; char metricDescription[ZET_MAX_METRIC_DESCRIPTION] = "eu_active_minimum_desc"; zetMetricCreateFromProgrammableExp(programmableHandle, ¶meterValue, 1, metricName, metricDescription, &metricHandleCount, null_ptr); zet_metric_handle_t * metricHandles = allocate(sizeof(zet_metric_handle_t) * metricHandleCount); zetMetricCreateFromProgrammableExp(programmableHandle, ¶meterValue, 1, metricName, metricDescription, &metricHandleCount, metricHandles); } } //Create Metric Group from metrics zet_metric_group_handle_t metricGroupHandle{}; char metricGroupName[ZET_MAX_METRIC_GROUP_NAME] = "eu_active"; char metricGroupDescription[ZET_MAX_METRIC_GROUP_DESCRIPTION] = "eu_active_desc"; zetMetricGroupCreateExp(device, metricGroupName, metricGroupDescription, ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED, &metricGroup); zetMetricGroupAddMetricExp(metricGroup, &metricHandles[0], null_ptr, null_ptr); zetMetricGroupCloseExp(metricGroup); //Activate Metric group //Collect Metric group using available sampling types //Cleanup zetMetricGroupDestroyExp(metricGroup); for(uint32_t j = 0; j < metricHandleCount; j++){ zetMetricDestroyExp(metricHandles[j]); }