Exemple #1
0
void vt_metric_read(struct vt_metv* metv, uint64_t offsets[],
                    uint64_t values[])
{
  int i;

  if ( metv == NULL )
    return;

  /* read counter values of set */
  if ( cpc_set_sample(cpc, metv->set, metv->buffer) == -1 )
    vt_error_msg("cpc_set_sample: %s", strerror(errno));

  for ( i = 0; i < nmetrics; i++ )
  {
    /* get 64-bit counter values from CPC buffer */
    if ( cpc_buf_get(cpc, metv->buffer, metv->indices[i], &(values[i])) == -1 )
      break;
  }
  if ( i != nmetrics )
    vt_error_msg("cpc_buf_get: %s", strerror(errno));

  /* add offsets to values, if necessary */
  if ( offsets != NULL )
  {
    for ( i = 0; i < nmetrics; i++ )
      values[i] += offsets[i];
  }
}
Exemple #2
0
static void
print_total(int ncpus, cpc_buf_t *buf, int nreq, const char *setname)
{
	int		i;
	uint64_t	val;

	(void) printf("%7.3f %3d %5s ", mstimestamp(cpc_buf_hrtime(cpc, buf)),
	    ncpus, "total");
	if (opts->dotick)
		(void) printf("%9" PRId64 " ", cpc_buf_tick(cpc, buf));
	for (i = 0; i < nreq; i++) {
		(void) cpc_buf_get(cpc, buf, i, &val);
		(void) printf("%9" PRId64 " ", val);
	}
	if (opts->nsets > 1)
		(void) printf(" # %s", setname);
	(void) fputc('\n', stdout);
}
Exemple #3
0
static void
print_sample(processorid_t cpuid, cpc_buf_t *buf, int nreq, const char *setname,
    int sibling)
{
	char		line[1024];
	int		ccnt;
	int		i;
	uint64_t	val;
	uint64_t	tick;
	hrtime_t	hrtime;

	hrtime = cpc_buf_hrtime(cpc, buf);
	tick = cpc_buf_tick(cpc, buf);

	ccnt = snprintf(line, sizeof (line), "%7.3f %3d %5s ",
	    mstimestamp(hrtime), (int)cpuid, "tick");
	if (opts->dotick)
		ccnt += snprintf(line + ccnt, sizeof (line) - ccnt,
		    "%9" PRId64 " ", tick);
	for (i = 0; i < nreq; i++) {
		(void) cpc_buf_get(cpc, buf, i, &val);
		ccnt += snprintf(line + ccnt, sizeof (line) - ccnt,
		    "%9" PRId64 " ", val);
	}
	if (opts->nsets > 1)
		ccnt += snprintf(line + ccnt, sizeof (line) - ccnt,
		    " # %s\n", setname);
	else
		ccnt += snprintf(line + ccnt, sizeof (line) - ccnt, "\n");

	if (sibling) {
		/*
		 * This sample is being printed for a "sibling" CPU -- that is,
		 * a CPU which does not have its own CPC set bound. It is being
		 * measured via a set bound to another CPU sharing its physical
		 * processor.
		 */
		int designee = chip_designees[gstate[cpuid].chip_id];
		char *p;

		if ((p = strrchr(line, '#')) == NULL)
			p = strrchr(line, '\n');

		if (p != NULL) {
			*p = '\0';
			ccnt = strlen(line);
			ccnt += snprintf(line + ccnt, sizeof (line) - ccnt,
			    "# counter shared with CPU %d\n", designee);
		}
	}

	if (timestamp_fmt != NODATE)
		print_timestamp(timestamp_fmt);
	if (ccnt > sizeof (line))
		ccnt = sizeof (line);
	if (ccnt > 0)
		(void) write(1, line, ccnt);

	/*
	 * If this CPU is the chip designee for any other CPUs, print a line for
	 * them here.
	 */
	if (smt && (sibling == 0)) {
		for (i = 0; i < ncpus; i++) {
			if ((i != cpuid) && (gstate[i].cpuid != -1) &&
			    (chip_designees[gstate[i].chip_id] == cpuid))
				print_sample(i, buf, nreq, setname, 1);
		}
	}
}