Example #1
0
static orcm_value_t* compute_min(opal_list_t* compute,
                                 orcm_analytics_aggregate* aggregate,
                                 int workflow_id)
{
    orcm_value_t *current_value = NULL;
    orcm_value_t *temp = NULL;
    orcm_value_t *min_value = NULL;
    char *data_key = NULL;
    double val;
    if(NULL == compute || NULL == aggregate) {
        return NULL;
    }
    temp = (orcm_value_t*)opal_list_get_first(compute);
    if(NULL != temp) {
        if (NULL == (data_key = generate_data_key("MIN", workflow_id))) {
            return NULL;
        }
        min_value = orcm_util_load_orcm_value(data_key, &temp->value.data,OPAL_DOUBLE,temp->units);
    }
    if(NULL == min_value){
        SAFEFREE(data_key);
        return NULL;
    }
    min_value->value.data.dval = aggregate->min;
    OPAL_LIST_FOREACH(current_value, compute, orcm_value_t) {
        val = orcm_util_get_number_orcm_value(current_value);
        if(val < aggregate->min) {
            aggregate->min = val;
            min_value->value.data.dval = aggregate->min;
        }
    }
static void compute_average(orcm_value_t* agg_value, orcm_analytics_aggregate* aggregate, opal_list_t* compute)
{
    double sum = 0.0;
    orcm_value_t *list_item = NULL;
    size_t size = opal_list_get_size(compute);

    OPAL_LIST_FOREACH(list_item, compute, orcm_value_t) {
        sum += orcm_util_get_number_orcm_value(list_item);
    }
Example #3
0
static orcm_value_t *compute_average(opal_list_t *compute_data,
                                     orcm_analytics_aggregate* aggregate,
                                     int workflow_id)
{
    double sum = 0.0;
    orcm_value_t *temp = NULL;
    orcm_value_t *aggregate_value = NULL;
    orcm_value_t *list_item = NULL;
    char *data_key = NULL;
    if (NULL == compute_data || NULL == aggregate) {
            return NULL;
    }
    size_t size = opal_list_get_size(compute_data);
    temp = (orcm_value_t*)opal_list_get_first(compute_data);
    if(NULL != temp) {
        if (NULL == (data_key = generate_data_key("average", workflow_id))) {
            return NULL;
        }
        aggregate_value = orcm_util_load_orcm_value(data_key, &temp->value.data,OPAL_DOUBLE,temp->units);
    }
    if(NULL == aggregate_value) {
        SAFEFREE(data_key);
        return NULL;
    }
    OPAL_LIST_FOREACH(list_item, compute_data, orcm_value_t) {
        if (NULL == list_item) {
            SAFEFREE(data_key);
            return NULL;
        }
        sum += orcm_util_get_number_orcm_value(list_item);
    }
    aggregate_value->value.data.dval = (aggregate->average * aggregate->num_sample + sum) /
                                     (aggregate->num_sample + size);
    aggregate->average = aggregate_value->value.data.dval;
    aggregate->num_sample += size;

    OPAL_OUTPUT_VERBOSE((5, orcm_analytics_base_framework.framework_output,
                         "%s analytics:aggregate:AVERAGE is: %f, and the number of sample is:%u",
                         ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), aggregate->average,aggregate->num_sample));
    SAFEFREE(data_key);
    return aggregate_value;
}