예제 #1
0
int main(int argc, char *argv[]) {
  int nmeas = 100;
  if (argc > 1)
    nmeas = atoi(argv[1]);
  int i;
  double max_mhz = 0.0;
  for (i = 0; i < nmeas; i++) {
    double mhz = get_mhz();
    if (mhz > max_mhz)
      max_mhz = mhz;
    printf("%d\t%.2f\t%.2f\n", i, mhz, max_mhz);
    burn_cpu();
  }
  return 0;
}
예제 #2
0
파일: iospeed-mpi.c 프로젝트: snsl/osc-osd
static uint64_t obj_create_any(int fd, uint64_t pid)
{
	struct osd_command command;
	struct attribute_list attr = {
		.type = ATTR_GET,
		.page = CUR_CMD_ATTR_PG,
		.number = CCAP_OID,
		.len = 8,
	};
	int ret;
	uint64_t oid;

	osd_command_set_create(&command, pid, 0, 0);
	osd_command_attr_build(&command, &attr, 1);
	ret = osd_submit_and_wait(fd, &command);
	if (ret) {
		osd_error_xerrno(ret, "%s: submit_and_wait failed", __func__);
		exit(1);
	}
	ret = osd_command_attr_resolve(&command);
	if (ret) {
		osd_error_xerrno(ret, "%s: attr_resolve failed", __func__);
		exit(1);
	}
	oid = get_ntohll(command.attr[0].val);
	osd_command_attr_free(&command);
	return oid;
}

static void obj_remove(int fd, uint64_t pid, uint64_t oid)
{
	struct osd_command command;
	int ret;

	osd_command_set_remove(&command, pid, oid);
	ret = osd_submit_and_wait(fd, &command);
	if (ret) {
		osd_error_xerrno(ret, "%s: submit_and_wait failed", __func__);
		exit(1);
	}
}

static void read_bw(int fd, uint64_t pid, uint64_t oid,
		    size_t sz, int iters, int dosync)
{
	int i = 0;
	int ret = 0;
	uint64_t start, end, delta, total_start, total_stop;
	double mhz = get_mhz();
	double time = 0.0;
	double max_time = 0.0;
	double min_time = 0.0;
	double *b = NULL;
	void *buf = NULL;
	size_t total_size;

	buf = malloc(sz);
	b = malloc(iters * sizeof(*b));

	if (!buf || !b)
		osd_error_fatal("out of memory");

	/* warm up */
	if (iters > 5)
		for (i=0; i<5; i++) {
			ret = read_osd(fd, pid, oid, buf, sz, 0);
			assert(ret == 0);
		}

	memset(buf, '\0', sz);

	MPI_Barrier(MPI_COMM_WORLD);
	rdtsc(total_start);
	for (i=0; i< iters; i++) {
		if (dosync) {
			rdtsc(start);
			ret = read_osd(fd, pid, oid, buf, sz, 0);
			rdtsc(end);
			assert(ret == 0);
			delta = end - start;

			rdtsc(start);
			ret = flush_object(fd, pid, oid, 2);
			rdtsc(end);
			assert(ret == 0);
			delta += (end - start);
		} else {
			rdtsc(start);
			ret = read_osd(fd, pid, oid, buf, sz, 0);
			rdtsc(end);
			assert(ret == 0);
			delta = end - start;
		}

		time = ((double)delta)/mhz; /* time in usec */
		b[i] = sz/time; /* BW in MegaBytes/sec */
	}

	MPI_Barrier(MPI_COMM_WORLD); /*everyone is done reading*/
	rdtsc(total_stop);

	unsigned int j;
	for (j=0; j<sz; j++) {
		char *c = (char *)buf + j;
		if (*c != 'D') {
			printf("[%d] ERROR READING BUFF (%c)\n", rank, *c);
		}
	}

#if 1
	delta = total_stop - total_start;
	time = ((double)delta)/mhz; /*time in usec*/

	ret = MPI_Reduce(&time, &max_time, 1, MPI_DOUBLE, MPI_MAX,
			0, MPI_COMM_WORLD);
	if (ret != MPI_SUCCESS) {
		printf("MPI ERROR\n");
	}

	ret = MPI_Reduce(&time, &min_time, 1, MPI_DOUBLE, MPI_MIN,
			0, MPI_COMM_WORLD);
	if (ret != MPI_SUCCESS) {
		printf("MPI ERROR\n");
	}
	if (rank == 0) {
		total_size = sz * iters * numproc; /*total bytes moved*/
		printf("read  %3d %3lu %7.3lf --- Discrep %.0f is %.1f%%\n",
			numproc, sz>>10, total_size/max_time,
			max_time - min_time, 100. * (max_time - min_time) / max_time);
	}
예제 #3
0
파일: spy.c 프로젝트: metacore/spin
/* Convert clock cycle count into microsecs. 
   The CPU clock rate is assumed to be MHZ. */
double
cycle_to_usec (unsigned long cycles) 
{
    return (double)cycles / get_mhz();
}