Esempio n. 1
0
int
main(int ac, char **av)
{
	long long count = 0;
	long long max;
	char c;
	int j;

	printf("timing standard getuid() syscall, single thread\n");
	printf("if using powerd, run several times\n");

	start_timing();
	while (stop_timing(0, NULL) == 0) {
		for (j = 0; j < 100; ++j)
			getuid();
		count += 100;
	}
	max = count;
	start_timing();
	for (count = 0; count < max; count += 100) {
		for (j = 0; j < 100; ++j)
			getuid();
	}
	stop_timing(count, "getuid()");
	return(0);
}
Esempio n. 2
0
int
main(int ac, char **av)
{
    long long count = 0;
    long long max;
    struct timespec ts;
    int j;

    printf("timing standard clock_gettime() syscall\n");

    start_timing();
    while (stop_timing(0, NULL) == 0) {
	for (j = 0; j < 100; ++j)
	    clock_gettime(CLOCK_REALTIME_FAST, &ts);
	count += 100;
    }
    max = count;
    start_timing();
    for (count = 0; count < max; count += 100) {
	for (j = 0; j < 100; ++j)
	    clock_gettime(CLOCK_REALTIME_FAST, &ts);
    }
    stop_timing(count, "getuid()");
    return(0);
}
Esempio n. 3
0
int
main(int ac, char **av)
{
    long long count = 0;
    long long max;
    int j;
    struct timeval tv;

    printf("timing standard gettimeofday() syscall\n");

    start_timing();
    while (stop_timing(0, NULL) == 0) {
	for (j = 0; j < 100; ++j)
	    gettimeofday(&tv, NULL);
	count += 100;
    }
    max = count;
    start_timing();
    for (count = 0; count < max; count += 100) {
	for (j = 0; j < 100; ++j)
	    gettimeofday(&tv, NULL);
    }
    stop_timing(count, "gettimeofday()");
    return(0);
}
Esempio n. 4
0
File: time.c Progetto: goovdl/akaros
/* Determines the overhead of tsc timing.  Note the start/stop calls are
 * inlined, so we're trying to determine the lowest amount of overhead
 * attainable by using the TSC (or whatever timing source).
 *
 * For more detailed TSC measurements, use test_rdtsc() in k/a/i/rdtsc_test.c */
void train_timing() 
{
	uint64_t min_overhead = UINT64_MAX;
	uint64_t max_overhead = 0;
	uint64_t time, diff;
	int8_t irq_state = 0;

	/* Reset this, in case we run it again.  The use of start/stop to determine
	 * the overhead relies on timing_overhead being 0. */
	system_timing.timing_overhead = 0;
	/* timing might use cpuid, in which case we warm it up to avoid some extra
	 * variance */
	time = start_timing();
 	diff = stop_timing(time);
	time = start_timing();
 	diff = stop_timing(time);
	time = start_timing();
 	diff = stop_timing(time);
	disable_irqsave(&irq_state);
	for (int i = 0; i < 10000; i++) {
		time = start_timing();
 		diff = stop_timing(time);
		min_overhead = MIN(min_overhead, diff);
		max_overhead = MAX(max_overhead, diff);
	}
	enable_irqsave(&irq_state);
	system_timing.timing_overhead = min_overhead;
	printk("TSC overhead (Min: %llu, Max: %llu)\n", min_overhead, max_overhead);
}
Esempio n. 5
0
void
test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes))
{
    int i;
    int loops;
    long long us;

    start_timing();
    for (i = 0; (i & 31) || stop_timing(0, NULL) == 0; ++i) {
	copyf(buf, buf + bytes, bytes);
    }

    loops = i * 2;
    start_timing();
    for (i = loops - 1; i >= 0; --i) {
	copyf(buf, buf + bytes, bytes);
    }
#if 0
    fpcleanup();
#endif
    stop_timing(loops, ctl);
    us = get_timing();
    printf("%s %d %5.2f MBytes/sec\n", ctl, bytes, 
	(double)loops * (double)bytes / (double)us);
}
Esempio n. 6
0
int
main(int ac, char **av)
{
    long long count = 0;
    long long max;
    int j;
    int *counter;
    pid_t pid;

    printf("Test simple locked bus cycle mutex latency\n");
    printf("auto-forks two processes for the test with shared memory\n");
    printf("This test is only useful on a SMP box\n");

    start_timing();
    mtx = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
    counter = mtx + 64;
    while (stop_timing(0, NULL) == 0) {
	for (j = 0; j < 100; ++j) {
	    get_mtx(1);
	    rel_mtx();
	}
	count += 100;
    }
    max = count;
    *mtx = 0;

    start_timing();
    for (count = 0; count < max; count += 100) {
	for (j = 0; j < 100; ++j) {
	    get_mtx(1);
	    rel_mtx();	/* release */
	    ++counter[64];
	}
    }
    stop_timing(count, "complex_mtx(uncontested/1cpu)");

    if ((pid = fork()) == 0) {
	for (;;) {
	    for (j = 0; j < 100; ++j) {
		get_mtx(2);
		rel_mtx();	/* release */
		++counter[128];
	    }
	}
    } else {
	start_timing();
	for (count = 0; count < max; count += 100) {
	    for (j = 0; j < 100; ++j) {
		get_mtx(1);
		rel_mtx();	/* release */
		++counter[64];
	    }
	}
	stop_timing(count, "complex_mtx");
	printf("proc1=%d proc2=%d\n", counter[64], counter[128]);
	kill(pid, 9);
    }
    return(0);
}
Esempio n. 7
0
int
main(int ac, char **av)
{
    long long count = 0;
    long long max;
    char c[1];
    int j;
    int loops;
    int fds[2];

    printf("tests full duplex pipe 1write,2read,2write,1read loop\n");
    if (pipe(fds)) {
	perror("pipe");
	exit(1);
    }
    if (fork() == 0) {
	/*
	 * child process
	 */
	close(fds[0]);
	while (read(fds[1], c, sizeof(c)) == sizeof(c)) {
	    write(fds[1], c, sizeof(c));
	}
	_exit(0);
    } else {
	/* 
	 * parent process.
	 */
	close(fds[1]);
	write(fds[0], c, sizeof(c));	/* prime the caches */
	read(fds[0], c, sizeof(c));

	start_timing();
	for (j = 0; ; ++j) {
	    write(fds[0], c, sizeof(c));
	    if (read(fds[0], c, sizeof(c)) != sizeof(c)) {
		fprintf(stderr, "broken pipe during test\n");
		exit(1);
	    }
	   if ((j & 31) == 0 && stop_timing(0, NULL))
		break;
	}
	loops = j;

	start_timing();
	for (j = 0; j < loops; ++j) {
	    write(fds[0], c, sizeof(c));
	    if (read(fds[0], c, sizeof(c)) != sizeof(c)) {
		fprintf(stderr, "broken pipe during test\n");
		exit(1);
	    }
	}
	stop_timing(j, "full duplex pipe / 1char:");
	close(fds[0]);
	while(wait(NULL) >= 0);
    }
    return(0);
}
Esempio n. 8
0
int
main(int ac, char **av)
{
	long long count = 0;
	long long max;
	char c;
	int n;
	int i;
	int j;
	int fd;
	int status;
	char *path;
	char buf[256];
	struct stat st;

	printf("timing standard fstat() syscall\n");

	fd = open("/tmp/lockmgr3.test", O_RDWR|O_CREAT, 0666);
	assert(fd >= 0);
	start_timing();
	while (stop_timing(0, NULL) == 0) {
		fstat(fd, &st);
		fstat(fd, &st);
		fstat(fd, &st);
		fstat(fd, &st);
		++count;
	}
	max = count * 4;
	close(fd);

	if (ac > 1)
		n = strtol(av[1], NULL, 0);
	else
		n = 1;

	start_timing();
	for (i = 0; i < n; ++i) {
		if (fork() == 0) {
			asprintf(&path, "/tmp/lockmgr.test");
			fd = open(path, O_RDWR|O_CREAT, 0666);
			assert(fd >= 0);
			for (count = 0; count < max; ++count) {
				fstat(fd, &st);
				fstat(fd, &st);
				fstat(fd, &st);
				fstat(fd, &st);
			}
			_exit(0);
		}
	}
	while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
		;
	stop_timing(max * n * 4, "lockmgr3");

	return(0);
}
Esempio n. 9
0
int main(int argc, char *argv[])
{
	struct timespec timing;
	int i, round;
	void *m[ALLOCS];
	/* a random set of allocations we test */
	int sizes[16] = { 1, 13, 100, 1000, 16, 10000, 50, 17,
					  123, 32, 8, 64, 8096, 1024, 123, 9 };

	library_init(NULL, "malloc_speed");
	atexit(library_deinit);

	print_mallinfo();

	start_timing(&timing);

	for (round = 0; round < ROUNDS; round++)
	{
		for (i = 0; i < ALLOCS; i++)
		{
			m[i] = malloc(sizes[(round + i) % countof(sizes)]);
		}
		for (i = 0; i < ALLOCS; i++)
		{
			free(m[i]);
		}
	}
	printf("time for %d malloc/frees, repeating %d rounds: %.4fs\n",
		   ALLOCS, ROUNDS, end_timing(&timing));

	print_mallinfo();

	return 0;
}
Esempio n. 10
0
//
// wait_till_completed(interval_ms = 0)
//
// params:
//   interval_ms - the polling interval in milliseconds. If zero, 1000 ms is used
//
static VALUE wait_till_completed(int argc, VALUE * argv, VALUE self) {
  struct timeval tm;
  start_timing(&tm);

  if ( rb_iv_get(self, "@done") == Qtrue ) return Qtrue;

  VALUE interval_ms;

  rb_scan_args(argc, argv, "01", &interval_ms);

  if ( NIL_P(interval_ms) ) interval_ms = rb_zero;

  as_error err;
  aerospike * as   = get_client_struct(rb_iv_get(self, "@client"));

  as_query * query;
  Data_Get_Struct(rb_iv_get(self, "@query"), as_query, query);

  uint64_t query_id = NUM2ULONG( rb_iv_get(self, "@query_id") );

  if ( aerospike_query_wait(as, &err, NULL, query, query_id, FIX2LONG(interval_ms)) != AEROSPIKE_OK ) {
    raise_as_error(err);
  }

  rb_iv_set(self, "@done", Qtrue);

  rb_aero_logger(AS_LOG_LEVEL_DEBUG, &tm, 1, rb_str_new2("[QueryTask][wait_till_completed] success"));

  return rb_iv_get(self, "@done");
}
Esempio n. 11
0
int main(int argc, char** argv) {

	double* S = malloc_aligned<double>(LENGTH, 5);
	double* X = malloc_aligned<double>(LENGTH, 5);
	double* T = malloc_aligned<double>(LENGTH, 5);
	double* r = malloc_aligned<double>(LENGTH, 5);
	double* v = malloc_aligned<double>(LENGTH, 5);
	
	for(int i = 0; i < LENGTH; i++) {
		S[i] = 100;
		X[i] = 98;
		T[i] = 2;
		r[i] = 0.02;
		v[i] = 5;
	}

	start_timing();
	double sum = 0;
	for(int i = 0; i < ROUNDS; i++) {
		sum += run(S, X, T, r, v);
	}
	printf("%f \t(%f)\n", end_timing(), sum / (LENGTH * ROUNDS));

	return 0;
}
Esempio n. 12
0
void rgb_timing(Test **test, Rgb_Timing *timing)
{

 double total_time,avg_time;
 int i,j;
 unsigned int *rand_uint;

 MYDEBUG(D_RGB_TIMING){
   printf("# Entering rgb_timing(): ps = %u  ts = %u\n",test[0]->psamples,test[0]->tsamples);
 }

 seed = random_seed();
 gsl_rng_set(rng,seed);

 rand_uint = (uint *)malloc((size_t)test[0]->tsamples*sizeof(uint));

 total_time = 0.0;
 for(i=0;i<test[0]->psamples;i++){
   start_timing();
   for(j=0;j<test[0]->tsamples;j++){
     rand_uint[j] = gsl_rng_get(rng);
   }
   stop_timing();
   total_time += delta_timing();
 }
 avg_time = total_time/(test[0]->psamples*test[0]->tsamples);

 timing->avg_time_nsec = avg_time*1.0e+9;
 timing->rands_per_sec = 1.0/avg_time;

 free(rand_uint);
 
}
Esempio n. 13
0
static void remap_data(int index, ft_data *ftd){
  msg_tag *mtag;
  char *temp;
  int i;
  double dtime = start_timing();

  temp = (char *)malloc(sites_on_node*ftd->size);
  if(temp==NULL){
    printf("remap_data: No room\n");
    terminate(1);
  }

  mtag = start_gather_field(ftd->data, ftd->size, index, EVENANDODD,
			    gen_pt[0]);
  wait_gather(mtag);

  /* First copy gathered data to temporary */
  for(i = 0; i < sites_on_node; i++)
    memcpy(temp + ftd->size*i, gen_pt[0][i], ftd->size);

  cleanup_gather(mtag);

  /* Then copy temp back to field */
  memcpy((char *)ftd->data, temp, sites_on_node*ftd->size);

  free(temp);

  print_timing(dtime, "REMAP FFTW remap");
}
Esempio n. 14
0
ft_data *create_ft_data(complex *src, int size){
  char myname[] = "create_ft_data";
  ft_data *ftd;
  int ncmp;
  double dtime = start_timing();

  ftd = (ft_data *)malloc(sizeof(ft_data));
  if(ftd == NULL){
    printf("%s: No room\n", myname);
    terminate(1);
  }

  ncmp = size/sizeof(complex);
  ftd->size = ncmp*sizeof(fftw_complex);
  ftd->dir = MILC_DIR;
  ftd->data 
    = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*sites_on_node*ncmp);
  ftd->tmp 
    = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*sites_on_node*ncmp);

  if(ftd->data == NULL || ftd->tmp == NULL){
    printf("%s: no room\n",myname);
    terminate(1);
  }
  /* Copy data in */
  ft_copy_from_milc(ftd->data, src, size);

  print_timing(dtime, "REMAP FFTW copy MILC");
  return ftd;
}
Esempio n. 15
0
static void run_test(diffie_hellman_group_t group, int rounds)
{
	diffie_hellman_t *l[rounds], *r;
	chunk_t chunk;
	struct timespec timing;
	int round;

	r = lib->crypto->create_dh(lib->crypto, group);
	if (!r)
	{
		printf("skipping %N, not supported\n",
				diffie_hellman_group_names, group);
		return;
	}

	printf("%N:\t",
			diffie_hellman_group_names, group);

	start_timing(&timing);
	for (round = 0; round < rounds; round++)
	{
		l[round] = lib->crypto->create_dh(lib->crypto, group);
	}
	printf("A = g^a/s: %8.1f", rounds / end_timing(&timing));

	for (round = 0; round < rounds; round++)
	{
		l[round]->get_my_public_value(l[round], &chunk);
		r->set_other_public_value(r, chunk);
		chunk_free(&chunk);
	}

	r->get_my_public_value(r, &chunk);
	start_timing(&timing);
	for (round = 0; round < rounds; round++)
	{
		l[round]->set_other_public_value(l[round], chunk);
	}
	printf(" | S = B^a/s: %8.1f\n", rounds / end_timing(&timing));
	chunk_free(&chunk);

	for (round = 0; round < rounds; round++)
	{
		l[round]->destroy(l[round]);
	}
	r->destroy(r);
}
Esempio n. 16
0
opt_oct_t* opt_oct_assign_linexpr(ap_manager_t* man,
			  bool destructive, opt_oct_t* o,
			  ap_dim_t d, ap_linexpr0_t* lexpr,
			  opt_oct_t* dest)
{
  opt_oct_internal_t* pr =
    opt_oct_init_from_manager(man,AP_FUNID_ASSIGN_LINEXPR_ARRAY,2*(o->dim+1+5));
  opt_uexpr u = opt_oct_uexpr_of_linexpr(pr,pr->tmp,lexpr,o->intdim,o->dim);
  opt_oct_mat_t* src;
  bool respect_closure;
  if(d>=o->dim){
	return NULL;
  }

  if (dest && !dest->closed && !dest->m)
    /* definitively empty due to dest*/
    return opt_oct_set_mat(pr,o,NULL,NULL,destructive);

  if (u.type==OPT_EMPTY)
    /* definitively empty due to empty expression */
    return opt_oct_set_mat(pr,o,NULL,NULL,destructive);

  /* useful to close only for non-invertible assignments */
  if ((u.type!=OPT_UNARY || u.i!=d) && pr->funopt->algorithm>=0)
    opt_oct_cache_closure(pr,o);
  src = o->closed ? o->closed : o->m;
  if (!src) return opt_oct_set_mat(pr,o,NULL,NULL,destructive); /* empty */

  /* can / should we try to respect the closure */
  respect_closure = (src==o->closed) && (pr->funopt->algorithm>=0) && (!dest);

  if (!destructive) src = opt_hmat_copy(src,o->dim);

  /* go */
  #if defined(TIMING)
  	start_timing();
  #endif

  opt_hmat_assign(pr,u,src,o->dim,d,&respect_closure);
  
  #if defined(TIMING)
  	record_timing(assign_linexpr_time);
  #endif

  /* exact on Q if zeroary or unary, closed arg and no conv error */
  if (u.type==OPT_BINARY || u.type==OPT_OTHER) flag_incomplete;
  else if (num_incomplete || o->intdim) flag_incomplete;
  else if (!o->closed) flag_algo;
  else if (pr->conv) flag_conv;

  /* intersect with dest */
  if (dest) {
    opt_oct_mat_t* src2 = dest->closed ? dest->closed : dest->m;
    meet_half(src,src,src2,o->dim,true);
  }
  
  if (respect_closure) return opt_oct_set_mat(pr,o,NULL,src,destructive);
  else return opt_oct_set_mat(pr,o,src,NULL,destructive);
}
Esempio n. 17
0
void fourier_ftdata( ft_data *ftd, int isign ){

  double dtime = start_timing();

  if(isign == 1)
    fftw_execute(fwd_plan[ftd->dir]);
  else
    fftw_execute(bck_plan[ftd->dir]);

  print_timing(dtime, "FFTW transform");
  dtime = start_timing();

  /* Copy the result from "tmp" back to "data" */

  memcpy((char *)ftd->data, (char *)ftd->tmp, ftd->size*sites_on_node);
  print_timing(dtime, "REMAP FFTW copy back");
}
void dijkstra_pq_threaded(CSRGraph *g, int numThreads)
{
    int *dist = new int[g->size];
    std::mutex *dist_locks = new std::mutex[g->size];
    int i;

    for(i=0;i<g->size;i++)
    {
        dist[i] = MAX_INT;
    }

    int source = 0;
    dist[source] = 0;

    std::priority_queue<Priority_struct, std::vector<Priority_struct>, Compare_priority> pq;
    Priority_struct temp;
    temp.node_name=source;
    temp.node_weight=0;
    pq.push(temp);

    printf("Pushed Initial\n");
    for(int i=0; i< pq.size();i++){
	printf(" %d", pq[i]);
    }
    printf("\n");

    flush_cache();
    start_timing();

    // make threads
    std::vector<std::thread> threads;
    for(i = 0; i < numThreads; ++i){
        threads.push_back(std::thread(dijkstra_pq_thread, g, dist, std::ref(pq), i, dist_locks));
    }

    for (auto it = threads.begin(); it != threads.end(); ++it) {
        std::thread &t = *it;
        t.join();
    }

    stop_timing();

#ifdef PRINT_DISTANCES
    i=0;
    while(i < g->size && i < 10)
    {
        printf("%d ", dist[i]);
        i++;
    }
    printf("\n");
#endif

    delete(dist);
    delete(dist_locks);
    dist = NULL;

}
Esempio n. 19
0
Time::Time ()
{	
	if ( !m_Started ) {
		m_Started = true;			
		SetSystemTime ();				// Get base time from wall clock
		start_timing ( m_CurrTime );	// Start timing from base time
	}
	m_CurrTime = 0;
}
Esempio n. 20
0
int
main(int ac, char **av)
{
	long long count = 0;
	long long max;
	char c;
	int n;
	int i;
	int j;
	int status;

	printf("timing standard getuid() syscall, single thread\n");
	printf("if using powerd, run several times\n");

	start_timing();
	while (stop_timing(0, NULL) == 0) {
		for (j = 0; j < 100; ++j)
			getuid();
		count += 100;
	}
	max = count;

	if (ac > 1)
		n = strtol(av[1], NULL, 0);
	else
		n = 1;

	start_timing();
	for (i = 0; i < n; ++i) {
		if (fork() == 0) {
			for (count = 0; count < max; count += 100) {
				for (j = 0; j < 100; ++j)
					getuid();
			}
			_exit(0);
		}
	}
	while (wait3(&status, 0, NULL) >= 0 || errno == EINTR)
		;
	stop_timing(count * n, "getuid()");

	return(0);
}
void dijkstra_LIFO_threaded(CSRGraph *g, int numThreads)
{
    int *dist = new int[g->size];
    std::mutex *dist_locks = new std::mutex[g->size];
    int *onstack = new int[g->size];
    int i;

    for(i=0;i<g->size;i++)
    {
        dist[i] = MAX_INT;
        onstack[i]=0;
    }

    int source = 0;
    dist[source] = 0;

    std::deque<int> deq;
    deq.push_back(source);
    onstack[source]=1;

    printf("Pushed initial\n");
    for(int i=0; i< deq.size();i++){
	printf(" %d", deq[i]);
    }
    printf("\n");

    flush_cache();
    start_timing();

    // make threads
    std::vector<std::thread> threads;
    for(i = 0; i < numThreads; ++i){
        threads.push_back(std::thread(dijkstra_LIFO_thread, g, dist, std::ref(deq), i, onstack, dist_locks));
    }

    for (auto it = threads.begin(); it != threads.end(); ++it) {
        std::thread &t = *it;
        t.join();
    }

    stop_timing();

#ifdef PRINT_DISTANCES
    i=0;
    while(i < g->size && i < 10)
    {
        printf("%d ", dist[i]);
        i++;
    }
    printf("\n");
#endif
    delete(onstack);
    delete(dist);
    delete(dist_locks);
}
Esempio n. 22
0
static void do_send_fragment(struct ipw_hardware *hw, unsigned char *data,
			    unsigned length)
{
	unsigned i;
	unsigned long flags;

	start_timing();
	BUG_ON(length > hw->ll_mtu);

	if (ipwireless_debug)
		dump_data_bytes("send", data, length);

	spin_lock_irqsave(&hw->lock, flags);

	hw->tx_ready = 0;
	swap_packet_bitfield_to_le(data);

	if (hw->hw_version == HW_VERSION_1) {
		outw((unsigned short) length, hw->base_port + IODWR);

		for (i = 0; i < length; i += 2) {
			unsigned short d = data[i];
			__le16 raw_data;

			if (i + 1 < length)
				d |= data[i + 1] << 8;
			raw_data = cpu_to_le16(d);
			outw(raw_data, hw->base_port + IODWR);
		}

		outw(DCR_TXDONE, hw->base_port + IODCR);
	} else if (hw->hw_version == HW_VERSION_2) {
		outw((unsigned short) length, hw->base_port);

		for (i = 0; i < length; i += 2) {
			unsigned short d = data[i];
			__le16 raw_data;

			if (i + 1 < length)
				d |= data[i + 1] << 8;
			raw_data = cpu_to_le16(d);
			outw(raw_data, hw->base_port);
		}
		while ((i & 3) != 2) {
			outw((unsigned short) 0xDEAD, hw->base_port);
			i += 2;
		}
		writew(MEMRX_RX, &hw->memory_info_regs->memreg_rx);
	}

	spin_unlock_irqrestore(&hw->lock, flags);

	end_write_timing(length);
}
Esempio n. 23
0
void external_dataset_sort(external_dataset_t* data)
{
    struct runtime rt;
    void* results = NULL;
    size_t i;
    
    stream_t* tmp;
    stream_t* stream = data->stream;
    stream_seek(stream, 0);
    tmp = stream_create(stream->config, "tmp.stream");
    stream_open(tmp, O_CREAT | O_TRUNC | O_RDWR | O_SYNC);
    /* sort each individual chunk of memory size */
    for(i = 0; i < data->n_records / MEMORY_RECORDS(stream); i++)
    {
        memory_read(stream, RECORDS(data->mem), MEMORY_RECORDS(stream));
        N_RECORDS(data->mem) = MEMORY_RECORDS(stream);
        results = NULL;
        start_timing(&rt);
        fp_im_sort(data->context, RECORDS(data->mem), N_RECORDS(data->mem), &results);
        stop_timing(&rt);
        printf("Sort time: %f\n", get_runtime(rt));
        memory_write(tmp, RECORDS(data->mem), N_RECORDS(data->mem));
        dataset_print(data->mem, TRUE);

    }
    if(data->n_records % MEMORY_RECORDS(stream))
    {
        memory_read(stream, RECORDS(data->mem), data->n_records % MEMORY_RECORDS(stream));
        N_RECORDS(data->mem) = data->n_records % MEMORY_RECORDS(stream);
        start_timing(&rt);
        results = NULL;
        fp_im_sort(data->context, RECORDS(data->mem), N_RECORDS(data->mem), &results);
        stop_timing(&rt);
        memory_write(tmp, RECORDS(data->mem), N_RECORDS(data->mem));
        dataset_print(data->mem, TRUE);
    }
    /* merge memory chunks block by block */
}
Esempio n. 24
0
static void* check_updates_worker(void* arg){
    timing_info timing;
    reset_timing(&timing);

    while(!stop){
        start_timing(&timing);

        if(!updated && push_commit){
            if(push_commit){
                pthread_mutex_lock(&commit_mutex);

                if(push_result_shell(push_commit, NULL)){
                    puts("Failed to push coin, reseting.");

                    pthread_mutex_lock(&update_mutex);

                    fetch_updates();
                    updated = 1;

                    pthread_mutex_unlock(&update_mutex);
                } else {
                    puts("Earned it!");
                }
                push_commit = NULL;

                pthread_mutex_unlock(&commit_mutex);
            } else {
                if(check_updates()){
                    pthread_mutex_lock(&update_mutex);
                    updated = 1;
                    pthread_mutex_unlock(&update_mutex);
                }
            }
            time_point(&timing);
            print_timing(&timing);
        } else {
            skip_point(&timing);
            usleep(10);
        }
    }

    puts("Update thread ending");

    pthread_exit(NULL);
}
Esempio n. 25
0
static void ft_make_maps(ft_layout *ftl[], int key[], int ndim){

  int dir, dirold;
  double dtime = start_timing();

  dirold = MILC_DIR;  /* Start from MILC layout */
  for(dir = 0; dir < ndim; dir++){
    if(key[dir] != 0){
      ft_make_map(dirold, dir);
      dirold = dir;
    }
  }
  /* End with the MILC layout */
  dir = MILC_DIR;
  ft_make_map(dirold, dir);

  print_timing(dtime, "make FFTW gathers");
}
Esempio n. 26
0
opt_oct_t* opt_oct_meet_lincons_array(ap_manager_t* man,
			      bool destructive, opt_oct_t* o,
			      ap_lincons0_array_t* array)
{
  opt_oct_internal_t* pr =
    opt_oct_init_from_manager(man,AP_FUNID_MEET_LINCONS_ARRAY,2*(o->dim+8));
  if (!o->closed && !o->m)
    /* definitively empty */
    return opt_oct_set_mat(pr,o,NULL,NULL,destructive);
  else {
    bool exact, respect_closure;
    int i;
    opt_oct_mat_t * oo = o->closed ? o->closed : o->m;
    /* can / should we try to respect closure */
    respect_closure = (oo==o->closed) && (pr->funopt->algorithm>=0);
    int size = 2*(o->dim)*(o->dim + 1);
    if (!destructive) oo = opt_hmat_copy(oo,o->dim);

    /* go */
   
    #if defined(TIMING)
  	start_timing();
    #endif
    bool res = opt_hmat_add_lincons(pr,oo,o->intdim,o->dim,array,&exact,&respect_closure);
    #if defined(TIMING)
	record_timing(meet_lincons_time);
    #endif
    if (res) {
      /* empty */
      if (!destructive) {
	opt_hmat_free(oo);
	oo = NULL;
      }
      return opt_oct_set_mat(pr,o,NULL,NULL,destructive);
    }
    else {
      /* exact if octagonal constraints & no conversion error */
      if (num_incomplete || !exact) flag_incomplete;
      else if (pr->conv) flag_conv;
      if (respect_closure) return opt_oct_set_mat(pr,o,NULL,oo,destructive);
      else return opt_oct_set_mat(pr,o,oo,NULL,destructive);
    }
  }
}
Esempio n. 27
0
void make_fftw_plans(int size, ft_data *ftd){
  int ncmp;
  int rank, howmany, istride, idist, ostride, odist;
  int n[1], inembed[1], onembed[1];
  int nxfm;
  unsigned flags;
  int dir;
  double dtime = start_timing();

  flags = FFTW_ESTIMATE;  /* Could try FFTW_MEASURE */
  rank = 1;
  /* Number of complex values in a 4D site datum */
  ncmp = size/sizeof(complex);
  idist = odist = 1;

  for(dir = 0; dir < NDIM; dir++)
    if(layout[dir] != NULL){
      
      nxfm = layout[dir]->nxfm;
      
      /* The FT dimension */
      n[0] = inembed[0] = onembed[0] = nxfm;
      
      /* Number of contiguous complex values per 1D coordinate being
	 transformed */
      howmany = (sites_on_node*ncmp)/nxfm;
      ostride = istride = howmany;
      
      fwd_plan[dir] = 
	fftw_plan_many_dft(rank, n, howmany, 
			   ftd->data, inembed, istride, idist, 
			   ftd->tmp, onembed, ostride, odist, 
			   FFTW_FORWARD, flags);
      bck_plan[dir] = 
	fftw_plan_many_dft(rank, n, howmany, 
			   ftd->data, inembed, istride, idist, 
			   ftd->tmp, onembed, ostride, odist, 
			   FFTW_BACKWARD, flags);
    }

  print_timing(dtime, "make FFTW plans");
}
Esempio n. 28
0
void display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
 	start_timing();

	SetLighting();

	CALL_MEMBER_FN(bunny, bunny.render)();

	float timeElapsed = stop_timing();
  	gTotalFrames++;
  	gTotalTimeElapsed += timeElapsed;
  	float fps = gTotalFrames / gTotalTimeElapsed;
  	char string[1024] = {0};
  	sprintf(string, "OpenGL Bunny: %0.2f FPS", fps);
  	glutSetWindowTitle(string);

	glutPostRedisplay();
  	glutSwapBuffers();
}
Esempio n. 29
0
/**
 * @brief Performs a volume analysis.
 * @return Zero for success, negative value otherwise.
 */
int analyze(udefrag_job_parameters *jp)
{
    ULONGLONG time;
    int result;
    
    time = start_timing("analysis",jp);
    jp->pi.current_operation = VOLUME_ANALYSIS;
    
    /* update volume information */
    result = get_volume_information(jp);
    if(result < 0)
        return result;
    
    /* scan volume for free space areas */
    if(get_free_space_layout(jp) < 0)
        return (-1);
    
    /* redraw mft zone in light magenta */
    get_mft_zones_layout(jp);
    
    /* search for files */
    if(find_files(jp) < 0)
        return (-1);
    
    /* redraw well known locked files in green */
    redraw_well_known_locked_files(jp);

    /* produce list of fragmented files */
    produce_list_of_fragmented_files(jp);
    (void)check_fragmentation_level(jp); /* for debugging */

    result = check_requested_action(jp);
    if(result < 0)
        return result;
    
    jp->p_counters.analysis_time = winx_xtime() - time;
    stop_timing("analysis",time,jp);
    return 0;
}
Esempio n. 30
0
void ft_create_layouts(ft_layout *ftl[], ft_layout **ft_milc, 
		       int ndim, int dims[], int key[]){
  int dir;
  int dtime = start_timing();

  /* Set up the FT layout structure for each dir needed */
  /* We don't remake the FT layout if it already exists, i.e.  the
     pointer is nonnull.  This provision allows a user to call
     setup_restrict_fourier multiple times without risking a memory
     leak */
  for(dir = 0; dir < ndim; dir++)
    if(ftl[dir] == NULL && key[dir] != 0){
      ftl[dir] = ft_create_ft_layout(ndim);
      ft_setup_layout(ftl[dir]->nsquares, ftl[dir]->squaresize,
		      ftl[dir]->dirp, ndim, dims, dir);
      ftl[dir]->node_number = ft_node_number;
      ftl[dir]->node_index = ft_node_index;
      ftl[dir]->get_coords = ft_get_coords;
      ftl[dir]->nxfm = dims[dir];
    }

  /* Set up the MILC layout structure */
  if(*ft_milc == NULL){
    *ft_milc = ft_create_ft_layout(ndim);
    /* Copy in the current MILC hypercubic layout dimensions and
       function pointers */
    ft_fill_milc_layout((*ft_milc)->nsquares, (*ft_milc)->squaresize, 
			(*ft_milc)->dirp, ndim, dims);
    (*ft_milc)->node_number = milc_node_number;
    (*ft_milc)->node_index = milc_node_index;
    (*ft_milc)->get_coords = milc_get_coords;
    (*ft_milc)->nxfm = 0;  /* We don't run transforms with the MILC layout */
  }

  print_timing(dtime, "create FFT layouts");
}