Skip to content

Commit

Permalink
repair rate computation across resets.
Browse files Browse the repository at this point in the history
This repair is mathematically correct so the user can now
check the sign bit to detect counter resets. The loss
of information during the interval of a counter reset
is the user's problem to bound.
  • Loading branch information
baallan committed Jul 12, 2018
1 parent e74f77b commit 1a2f105
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ldms/src/sampler/sysclassib.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static int create_metric_set(const char *instance_name, char *schema_name)
port->ca,
port->portno);
port->rate[i] = ldms_schema_metric_add(schema, metric_name,
LDMS_V_F32);
LDMS_V_D64);
}
}
}
Expand Down Expand Up @@ -641,21 +641,21 @@ static ldms_set_t get_set(struct ldmsd_sampler *self)
*/
static
inline void update_metric(struct scib_port *port, int idx, uint64_t new_v,
float dt)
double dt)
{
uint64_t old_v = ldms_metric_get_u64(set, port->handle[idx]);
if (!port->ext)
new_v += old_v;
ldms_metric_set_u64(set, port->handle[idx], new_v);
if (sysclassib_metrics_type == SYSCLASSIB_METRICS_BOTH) {
ldms_metric_set_float(set, port->rate[idx], (new_v - old_v) / dt);
ldms_metric_set_double(set, port->rate[idx], ((double)new_v - (double)old_v) / dt);
}
}

/**
* Port query (utility function).
*/
int query_port(struct scib_port *port, float dt)
int query_port(struct scib_port *port, double dt)
{
void *p;
int rc;
Expand Down Expand Up @@ -733,7 +733,7 @@ static int sample(struct ldmsd_sampler *self)
{
struct timeval *tmp;
struct timeval tv_diff;
float dt;
double dt;
struct scib_port *port;

if (!set) {
Expand All @@ -743,7 +743,7 @@ static int sample(struct ldmsd_sampler *self)

gettimeofday(tv_now, 0);
timersub(tv_now, tv_prev, &tv_diff);
dt = tv_diff.tv_sec + tv_diff.tv_usec / 1e06f;
dt = (double)tv_diff.tv_sec + tv_diff.tv_usec / 1.0e06;

ldms_transaction_begin(set);
LJI_SAMPLE(set,1);
Expand Down

0 comments on commit 1a2f105

Please sign in to comment.