Esempio n. 1
0
/** Handler for SIGILL (illegal instruction). */
void ill_handler(int sig, siginfo_t* info, void*) {
#ifdef CVC4_DEBUG
  safe_print(STDERR_FILENO,
             "CVC4 executed an illegal instruction in DEBUG mode.\n");
  if(!segvSpin) {
    print_statistics();
    abort();
  } else {
    safe_print(STDERR_FILENO,
               "Spinning so that a debugger can be connected.\n");
    safe_print(STDERR_FILENO, "Try:  gdb ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, " ");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, "\n");
    safe_print(STDERR_FILENO, " or:  gdb --pid=");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, " ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, "\n");
    for(;;) {
      sleep(60);
    }
  }
#else /* CVC4_DEBUG */
  safe_print(STDERR_FILENO, "CVC4 executed an illegal instruction.\n");
  print_statistics();
  abort();
#endif /* CVC4_DEBUG */
}
Esempio n. 2
0
File: main.c Progetto: tkadom/TWBLE
int main(void)
{

    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    nrf_gpio_cfg_output(WAVE_ON_PIN_NUMBER); // on this pin 2Hz wave will be generated

#ifdef BSP_BUTTON_0
    // configure pull-up on first button
    nrf_gpio_cfg_input(BSP_BUTTON_0, NRF_GPIO_PIN_PULLUP);
#endif

    APP_GPIOTE_INIT(1);

    uart_config();

    lpcomp_init();

    printf("\n\rLPCOMP driver usage example\r\n");

    while (true)
    {
        print_statistics();
        LEDS_ON(BSP_LED_1_MASK);
        NRF_GPIO->OUTCLR = (1 << WAVE_ON_PIN_NUMBER);
        nrf_delay_ms(100); // generate 100 ms pulse on selected pin
        print_statistics();
        LEDS_OFF(BSP_LED_1_MASK);
        NRF_GPIO->OUTSET = (1 << WAVE_ON_PIN_NUMBER);
        nrf_delay_ms(400);
    }
}
Esempio n. 3
0
/* The main function */
int 
main(int argc, char **argv)
{	
	/* Generate the grids and populate them with the same set of random values. */
	GRID_STRUCT *grid_1 = (GRID_STRUCT *)malloc(sizeof(GRID_STRUCT)); 
	GRID_STRUCT *grid_2 = (GRID_STRUCT *)malloc(sizeof(GRID_STRUCT)); 
	GRID_STRUCT *grid_3 = (GRID_STRUCT *)malloc(sizeof(GRID_STRUCT)); 

	grid_1->dimension = GRID_DIMENSION;
	grid_1->num_elements = grid_1->dimension * grid_1->dimension;
	grid_2->dimension = GRID_DIMENSION;
	grid_2->num_elements = grid_2->dimension * grid_2->dimension;
	grid_3->dimension = GRID_DIMENSION;
	grid_3->num_elements = grid_3->dimension * grid_3->dimension;

 	create_grids(grid_1, grid_2, grid_3);

	
	/* Compute the reference solution using the single-threaded version. */
	printf("Using the single threaded version to solve the grid. \n");
	int num_iter = compute_gold(grid_1);
	printf("Convergence achieved after %d iterations. \n", num_iter);

	/* Use pthreads to solve the equation uisng the red-black parallelization technique. */
	printf("Using pthreads to solve the grid using the red-black parallelization method. \n");
	num_iter = compute_using_pthreads_red_black(grid_2);
	printf("Convergence achieved after %d iterations. \n", num_iter);

	
	/* Use pthreads to solve the equation using the jacobi method in parallel. */
	printf("Using pthreads to solve the grid using the jacobi method. \n");
	num_iter = compute_using_pthreads_jacobi(grid_3);
	printf("Convergence achieved after %d iterations. \n", num_iter);

	/* Print key statistics for the converged values. */
	printf("\n");
	printf("Reference: \n");
	print_statistics(grid_1);

	printf("Red-black: \n");
	print_statistics(grid_2);
		
	printf("Jacobi: \n");
	print_statistics(grid_3);

    /* Compute grid differences. */
    compute_grid_differences(grid_1, grid_2, grid_3);

	/* Free up the grid data structures. */
	free((void *)grid_1->element);	
	free((void *)grid_1); 
	
	free((void *)grid_2->element);	
	free((void *)grid_2);

	free((void *)grid_3->element);	
	free((void *)grid_3);

	return 0;
}
Esempio n. 4
0
static void print_detailed(const matstat_state_t *states, size_t nelem, unsigned int test_min, const stat_limits_t *limits)
{
    if (LOG2_STATS) {
        print_str("   interval     count       sum       sum_sq    min   max  mean  variance\n");
        for (unsigned int k = 0; k < nelem; ++k) {
            char buf[20];
            unsigned int num = (1 << k);
            if (num >= TEST_NUM) {
                break;
            }
            unsigned int start = num + test_min;
            if (num == 1) {
                /* special case, bitarithm_msb will return 0 for both 0 and 1 */
                start = test_min;
            }
            print(buf, fmt_lpad(buf, fmt_u32_dec(buf, start), 4, ' '));
            print_str(" - ");
            print(buf, fmt_lpad(buf, fmt_u32_dec(buf, test_min + (num * 2) - 1), 4, ' '));
            print_str(": ");
            print_statistics(&states[k], limits);
        }
        print_str("      TOTAL  ");
    }
    else {
        print_str("interval    count       sum       sum_sq    min   max  mean  variance\n");
        for (unsigned int k = 0; k < nelem; ++k) {
            char buf[10];
            print(buf, fmt_lpad(buf, fmt_u32_dec(buf, k + test_min), 7, ' '));
            print_str(": ");
            print_statistics(&states[k], limits);
        }
        print_str("  TOTAL: ");
    }
    print_totals(states, nelem, limits);
}
Esempio n. 5
0
/** Handler for SIGSEGV (segfault). */
void segv_handler(int sig, siginfo_t* info, void* c) {
  uintptr_t extent = reinterpret_cast<uintptr_t>(cvc4StackBase) - cvc4StackSize;
  uintptr_t addr = reinterpret_cast<uintptr_t>(info->si_addr);
#ifdef CVC4_DEBUG
  safe_print(STDERR_FILENO, "CVC4 suffered a segfault in DEBUG mode.\n");
  safe_print(STDERR_FILENO, "Offending address is ");
  safe_print(STDERR_FILENO, info->si_addr);
  safe_print(STDERR_FILENO, "\n");
  //cerr << "base is " << (void*)cvc4StackBase << endl;
  //cerr << "size is " << cvc4StackSize << endl;
  //cerr << "extent is " << (void*)extent << endl;
  if(addr >= extent && addr <= extent + 10*1024) {
    safe_print(STDERR_FILENO,
               "Looks like this is likely due to stack overflow.\n");
    safe_print(STDERR_FILENO,
               "You might consider increasing the limit with `ulimit -s' or "
               "equivalent.\n");
  } else if(addr < 10*1024) {
    safe_print(STDERR_FILENO, "Looks like a NULL pointer was dereferenced.\n");
  }

  if(!segvSpin) {
    print_statistics();
    abort();
  } else {
    safe_print(STDERR_FILENO,
               "Spinning so that a debugger can be connected.\n");
    safe_print(STDERR_FILENO, "Try:  gdb ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, " ");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, "\n");
    safe_print(STDERR_FILENO, " or:  gdb --pid=");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, " ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, "\n");
    for(;;) {
      sleep(60);
    }
  }
#else /* CVC4_DEBUG */
  safe_print(STDERR_FILENO, "CVC4 suffered a segfault.\n");
  safe_print(STDERR_FILENO, "Offending address is ");
  safe_print(STDERR_FILENO, info->si_addr);
  safe_print(STDERR_FILENO, "\n");
  if(addr >= extent && addr <= extent + 10*1024) {
    safe_print(STDERR_FILENO,
               "Looks like this is likely due to stack overflow.\n");
    safe_print(STDERR_FILENO,
               "You might consider increasing the limit with `ulimit -s' or "
               "equivalent.\n");
  } else if(addr < 10*1024) {
    safe_print(STDERR_FILENO, "Looks like a NULL pointer was dereferenced.\n");
  }
  print_statistics();
  abort();
#endif /* CVC4_DEBUG */
}
Esempio n. 6
0
int lazy_supervised_classification() {
	__START_TIMER__
	CACHE.locked=0;
	evaluation_t evaluator;
	prediction_t prediction;
	initialize_evaluation(&evaluator);
	int n_tests=1;
	list_t* test=TEST;
	while(test) {
		struct timeval s; gettimeofday(&s, NULL);
		prediction=get_THE_prediction(test->instance, test->size, test->label);
		struct timeval e; gettimeofday(&e, NULL);
		long long tt=(e.tv_sec-s.tv_sec)*1000000+e.tv_usec-s.tv_usec;
		printf("time: %d %lf\n", n_tests, tt/(double)1000000);
		update_evaluation(&evaluator, prediction.label, test->label);
		print_statistics(n_tests, test->label, test->id, prediction, evaluator);
		n_tests++;
		list_t* x=test->next;
		free(test->instance);
		free(test);
		test=x;
	}
	printf("\n");
	for(int i=0;i<MAX_CLASSES;i++) printf("CLASS(%d)= %d Prec= %f Rec= %f F1= %f   ", i, evaluator.true_labels[i], evaluator.precision[i], evaluator.recall[i], evaluator.f1[i]);
	printf("Acc= %f  MF1= %f   *    hits= %ld misses= %ld\n", evaluator.acc, evaluator.mf1, CACHE.hits, CACHE.misses);
	//finalize_evaluation(&evaluator);
	__FINISH_TIMER__
	return(0);
}
Esempio n. 7
0
/*
 * Print statistics in global pane.
 */
static void
print_sysglobal(void)
{
	void *list;
	char header[256];

	if (!display_initialized) {
		return;
	}

	(void) werase(sysglobal_window);

	(void) wattron(sysglobal_window, A_REVERSE);
	(void) snprintf(header, sizeof (header),
	    "%s", "System wide latencies");
	fill_space_right(header, screen_width, sizeof (header));
	(void) mvwprintw(sysglobal_window, 0, 0, "%s", header);
	(void) wattroff(sysglobal_window, A_REVERSE);

	list = lt_stat_list_create(current_list_type,
	    LT_LEVEL_GLOBAL, 0, 0, 10, sort_type);
	print_statistics(sysglobal_window, 1, 10, list);
	lt_stat_list_free(list);

	(void) wrefresh(sysglobal_window);
}
Esempio n. 8
0
cl_int clReleaseCommandQueue (cl_command_queue command_queue) {

#if ENABLE_KERNEL_PROFILING == 1
  print_statistics(0);
#endif
#if ENABLE_LEAK_DETECTION == 1
  if (IS_MPI_MASTER()) {
    int i;
    struct ld_program_s *ldprogram;
    struct ld_kernel_s *ldkernel;
    struct ld_mem_s *ldmem;
    //struct ld_mem_offset_s *ldmem_offset;
    
#define CHECK_ALL_RELEASED(_NAME)                               \
    FOR_ALL_MAP_ELTS(i, ld##_NAME, _NAME) {                     \
      if (!ld##_NAME->released) {                               \
        warning("Memory leak: " # _NAME                         \
                " %p not released. (#%d) %d\n",                 \
                ld##_NAME->handle, ld##_NAME->uid, ld##_NAME->released);     \
      }                                                         \
    }                                                           \
    
    CHECK_ALL_RELEASED(program);
    CHECK_ALL_RELEASED(kernel);
    CHECK_ALL_RELEASED(mem);
    //CHECK_ALL_RELEASED(mem_offset);
  }
#endif
  return real_clReleaseCommandQueue (command_queue);
}
Esempio n. 9
0
int lazy_semisupervised_classification() {
	__START_TIMER__
	CACHE.locked=1;
	evaluation_t evaluator;
	prediction_t prediction;
	initialize_evaluation(&evaluator);
	int abstain=0, n_points=1, remaining_points=N_POINTS;
	float min_level=MIN_LEVEL;
	list_t* unlabeled=UNLABELED;
	while(unlabeled) {
		reset_rules();
		prediction=get_THE_prediction(unlabeled->instance, unlabeled->size, unlabeled->label);
		if(prediction.score.points[prediction.score.ordered_labels[0]]>min_level || prediction.score.points[prediction.score.ordered_labels[0]]/(float)prediction.score.points[prediction.score.ordered_labels[1]]>=FACTOR) {
			update_evaluation(&evaluator, prediction.label, unlabeled->label);
			print_statistics(n_points, unlabeled->label, unlabeled->id, prediction, evaluator);
			N_TRANSACTIONS++;
			COUNT_TARGET[prediction.label]++;
			ITEMSETS[TARGET_ID[prediction.label]].list[ITEMSETS[TARGET_ID[prediction.label]].count]=N_TRANSACTIONS;
			ITEMSETS[TARGET_ID[prediction.label]].count++;
			for(int j=0;j<unlabeled->size;j++) {
				ITEMSETS[unlabeled->instance[j]].list[ITEMSETS[unlabeled->instance[j]].count]=N_TRANSACTIONS;
				ITEMSETS[unlabeled->instance[j]].count++;
			}

			n_points++;
			remaining_points--;
			abstain=0;
			list_t* x=unlabeled->next;
			free(unlabeled->instance);
			free(unlabeled);
			unlabeled=x;
			UNLABELED=unlabeled;
		}
		else if(abstain<remaining_points) {
printf("abstaining %d %d %f %f %f\n", abstain, remaining_points, min_level, prediction.score.points[prediction.score.ordered_labels[0]]/(float)prediction.score.points[prediction.score.ordered_labels[1]], avg_size);
			abstain++;
        		list_t* q=UNLABELED;
			while(q->next!=NULL) q=q->next;
			list_t* t=(list_t*)malloc(sizeof(list_t));
			t->instance=(int*)malloc(sizeof(int)*unlabeled->size);
			t->size=0;
			for(int i=0;i<unlabeled->size;i++) t->instance[t->size++]=unlabeled->instance[i];
			t->label=unlabeled->label;
			t->next=NULL;
			q->next=t;
			list_t* x=unlabeled->next;
			free(unlabeled->instance);
			free(unlabeled);
			unlabeled=x;
			UNLABELED=unlabeled;
		}
		else break;
	}
	printf("\n");
	for(int i=0;i<MAX_CLASSES;i++) printf("CLASS(%d)= %d Prec= %f Rec= %f F1= %f   ", i, evaluator.true_labels[i], evaluator.precision[i], evaluator.recall[i], evaluator.f1[i]);
	printf("Acc= %f  MF1= %f   *    hits= %ld misses= %ld\n", evaluator.acc, evaluator.mf1, CACHE.hits, CACHE.misses);
	//finalize_evaluation(&evaluator);
	__FINISH_TIMER__
	return(0);
}
Esempio n. 10
0
/*
 * Print per-thread statistics in process pane.
 * This is called when mode of operation is thread.
 */
static void
print_thread(pid_t pid, id_t tid)
{
	void *list;
	char header[256];
	char tmp[30];

	if (!display_initialized) {
		return;
	}

	list = lt_stat_list_create(current_list_type, LT_LEVEL_THREAD,
	    pid, tid, 8, sort_type);

	(void) werase(process_window);
	(void) wattron(process_window, A_REVERSE);
	(void) snprintf(header, sizeof (header),
	    "Process %s (%i), LWP %d",
	    lt_stat_proc_get_name(pid), pid, tid);
	fill_space_right(header, screen_width, sizeof (header));
	(void) mvwprintw(process_window, 0, 0, "%s", header);

	if (current_list_type != LT_LIST_SPECIALS) {
		(void) mvwprintw(process_window, 0, 48, "Total: %s",
		    get_time_string(
		    (double)lt_stat_list_get_gtotal(list),
		    tmp, sizeof (tmp), 12));
	}

	print_current_mode();
	(void) wattroff(process_window, A_REVERSE);
	print_statistics(process_window, 1, 8, list);
	lt_stat_list_free(list);
	(void) wrefresh(process_window);
}
Esempio n. 11
0
/**
 * Ask for 20 numbers in a loop. When 20 valid numbers are entered, calculate
 * the average and report out the largest, smallest and average numbers.
 *
 * Control the loop by controlling the counter alone, letting the loop worry
 * about itself.
 */
int main()
{
  int i = 1, quantity = 20;
  double number = 0, running_sum = 0, largest_number = 0, smallest_number = 0;

  print_greeting(quantity);

  for (i = 1; i <= quantity; i += 1)
  {
    printf("Enter number %d: ", i);

    if (scanf("%lf", &number))
    {
      running_sum += number;
      smallest_number = compute_smallest_number(number, smallest_number, i);
      largest_number = compute_largest_number(number, largest_number);
    }
    else
    {
      printf("Please only enter numbers! Let's try again...\n");
      i -= 1;
      number = 0.00;
    }

    clear_buffer();
  }

  print_statistics(running_sum, quantity, smallest_number, largest_number);

  return 0;
}
Esempio n. 12
0
void ping(int signal)
{
    int             ret;
    struct in_addr  from;
    float           rtt;


    cmd.args.ping.ip_addr = addr.s_addr;
    sent++;

    ret = ioctl(f, IOC_RT_PING, &cmd);
    if (ret < 0) {
        if (errno == ETIME)
            goto done;
        perror("ioctl");
        exit(1);
    }

    received++;
    from.s_addr = cmd.args.ping.ip_addr;
    rtt = (float)cmd.args.ping.rtt / (float)1000;
    if (rtt > wc_rtt)
        wc_rtt = rtt;
    printf("%d bytes from %s: icmp_seq=%d time=%.1f us\n",
           ret, inet_ntoa(from), cmd.args.ping.sequence, rtt);

  done:
    if (cmd.args.ping.sequence++ == count)
        print_statistics();
}
Esempio n. 13
0
    virtual void execute(cmd_context& ctx) {
        if (m_target == 0) {
            throw cmd_exception("invalid query command, argument expected");
        }
        datalog::context& dlctx = m_dl_ctx->get_dl_context();
        set_background(ctx);        
        dlctx.updt_params(m_params);
        unsigned timeout   = m_params.get_uint(":timeout", UINT_MAX);
        cancel_eh<datalog::context> eh(dlctx);
        lbool status = l_undef;
        {
            scoped_ctrl_c ctrlc(eh);
            scoped_timer timer(timeout, &eh);
            cmd_context::scoped_watch sw(ctx);
            try {
                status = dlctx.query(m_target);
            }
            catch (z3_error & ex) {
                throw ex;
            }
            catch (z3_exception& ex) {
                ctx.regular_stream() << "(error \"query failed: " << ex.msg() << "\")" << std::endl;
            }
            dlctx.cleanup();
        }
        switch (status) {
        case l_false:
            ctx.regular_stream() << "unsat\n";
            print_certificate(ctx);
            break;
        case l_true: 
            ctx.regular_stream() << "sat\n";
            print_answer(ctx);
            print_certificate(ctx);
            break;
        case l_undef: 
            ctx.regular_stream() << "unknown\n";
            switch(dlctx.get_status()) {
            case datalog::INPUT_ERROR:
                break;
                
            case datalog::MEMOUT:
                ctx.regular_stream() << "memory bounds exceeded\n";
                break;

            case datalog::TIMEOUT:
                ctx.regular_stream() << "timeout\n";
                break;
                
            case datalog::OK: 
                break;
            default:
                UNREACHABLE();
            }
            break;
        }
        print_statistics(ctx);
        m_target = 0;
    }
Esempio n. 14
0
void statistics_connected_layer(layer l)
{
    if(l.batch_normalize){
        printf("Scales ");
        print_statistics(l.scales, l.outputs);
        /*
        printf("Rolling Mean ");
        print_statistics(l.rolling_mean, l.outputs);
        printf("Rolling Variance ");
        print_statistics(l.rolling_variance, l.outputs);
        */
    }
    printf("Biases ");
    print_statistics(l.biases, l.outputs);
    printf("Weights ");
    print_statistics(l.weights, l.outputs);
}
Esempio n. 15
0
 void print_statistics( const std::string& filename, const circuit& circ, double runtime, const print_statistics_settings& settings )
 {
   std::filebuf fb;
   fb.open( filename.c_str(), std::ios::out );
   std::ostream os( &fb );
   print_statistics( os, circ, runtime, settings );
   fb.close();
 }
Esempio n. 16
0
void interactive(){
   while (TRUE){
    char *command;
    int i;
    char *parameters[32];
    struct timeval initial_clock;
    struct timeval final_clock;    
    int num_params;

    do{
      type_prompt();// displays prompt
      num_params = read_command(command, parameters);//get input from user and parse it into command and parameters
      if(num_params > 32){
	printf("\nOnly 32 arguments allowed.\n");
      }
    } while(num_params > 32 || num_params == -2);
    char **params = malloc((num_params + 1) * sizeof(char *));
    for(i = 0; i < num_params; i++)
      params[i] = parameters[i];
    params[i] = NULL;
    command = params[0];
    if(strcmp("exit", command) == 0) exit(4);
    if(strcmp("cd", command) == 0){
      chdir(params[1]);
      continue;
    }
    if(gettimeofday(&initial_clock, NULL) == -1) printf("\nCould not get time.\n");
    pid_t pId = fork();
    if(pId == -1){ //fork failed
      printf("Fork failed. Please try running again. %s\n", strerror(errno));
    }
    if(pId != 0){ //parent process
      int status;
      if(waitpid(pId,&status, 0) != pId) printf("waitpid failed\n");
      
      // once child process is done, print usage statistics
      if(gettimeofday(&final_clock, NULL) == -1) printf("\nCould not get time.\n");
      long seconds_elapsed = final_clock.tv_sec - initial_clock.tv_sec;
      long microseconds_elapsed = final_clock.tv_usec - initial_clock.tv_usec;
      long milliseconds_elapsed = seconds_elapsed*1000 + microseconds_elapsed*0.001;
      printf("\nWall clock time for the command to execute:\n%ld milliseconds\n", milliseconds_elapsed);
      print_statistics();
    }
    else{ //child process
      int returnnum;
      returnnum = execvp(command, params);
      if(returnnum == -1){ //error occurred during execvp
	printf("Your command didn't work: %s\n", strerror(errno));
	prev_usr_milliseconds = 0;
	prev_sys_milliseconds = 0;
	prev_stats.ru_nivcsw = 0;
	prev_stats.ru_nvcsw = 0;
	prev_stats.ru_majflt = 0;
	prev_stats.ru_minflt = 0;
      }
    }
  }
}
Esempio n. 17
0
void cvc4unexpected() {
#if defined(CVC4_DEBUG) && !defined(__WIN32__)
  safe_print(STDERR_FILENO,
             "\n"
             "CVC4 threw an \"unexpected\" exception (one that wasn't properly "
             "specified\nin the throws() specifier for the throwing function)."
             "\n\n");

  const char* lastContents = LastExceptionBuffer::currentContents();

  if(lastContents == NULL) {
    safe_print(
        STDERR_FILENO,
        "The exception is unknown (maybe it's not a CVC4::Exception).\n\n");
  } else {
    safe_print(STDERR_FILENO, "The exception is:\n");
    safe_print(STDERR_FILENO, lastContents);
    safe_print(STDERR_FILENO, "\n\n");
  }
  if(!segvSpin) {
    print_statistics();
    set_terminate(default_terminator);
  } else {
    safe_print(STDERR_FILENO,
               "Spinning so that a debugger can be connected.\n");
    safe_print(STDERR_FILENO, "Try:  gdb ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, " ");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, "\n");
    safe_print(STDERR_FILENO, " or:  gdb --pid=");
    safe_print<int64_t>(STDERR_FILENO, getpid());
    safe_print(STDERR_FILENO, " ");
    safe_print(STDERR_FILENO, *progName);
    safe_print(STDERR_FILENO, "\n");
    for(;;) {
      sleep(60);
    }
  }
#else /* CVC4_DEBUG */
  safe_print(STDERR_FILENO, "CVC4 threw an \"unexpected\" exception.\n");
  print_statistics();
  set_terminate(default_terminator);
#endif /* CVC4_DEBUG */
}
Esempio n. 18
0
void UNUSED sig_handler(int signum) {
  switch(signum) {
#if ENABLE_KERNEL_PROFILING == 1
  case SIGUSR1:
    print_statistics(1);
    break;
#endif
  }
}
Esempio n. 19
0
static void print_totals(const matstat_state_t *states, size_t nelem, const stat_limits_t *limits)
{
    matstat_state_t totals;
    matstat_clear(&totals);
    for (size_t k = 0; k < nelem; ++k) {
        matstat_merge(&totals, &states[k]);
    }
    print_statistics(&totals, limits);
}
Esempio n. 20
0
//! Global Analyze of Quality
void MESHQARoot::analyze()
{
    // Nothing to Analyze
    if (!state) return;
    
    print_statistics();

    for (int i = 0; i < nbases; i++)
        bases[i].analyze();
}
Esempio n. 21
0
void utility_tools(long val)
#endif
{
    FILE *fd ;
#if defined(SGI_GL) && defined(GL_NASA)
    long val = g_get_choice_val( ap, &choices[3] ) ;
#endif

    switch( val )
        {
        case CHOICE_UTIL_PS:
            /* Open PS file */
            ps_open( "radiosity.ps" ) ;

            /* Change the view */
            ps_setup_view( DFLT_VIEW_ROT_X, (float)disp_crnt_view_y,
                          DFLT_VIEW_DIST, DFLT_VIEW_ZOOM) ;

            /* And redraw */
            ps_display_scene( disp_fill_mode, disp_patch_switch,
                             disp_mesh_switch, disp_interaction_switch, 0 ) ;

            /* Close */
            ps_close() ;
            break ;
        case CHOICE_UTIL_STAT_CRT:
            print_statistics( stdout, 0 ) ;
            break ;
        case CHOICE_UTIL_STAT_FILE:
            if( (fd = fopen( "radiosity_stat", "w" )) == 0 )
                {
                    perror( "radiosity_stat" ) ;
                    break ;
                }
            print_statistics( fd, 0 ) ;
            fclose( fd ) ;
            break ;
        case CHOICE_UTIL_CLEAR_RAD:
            clear_radiosity(0) ;
        }
}
Esempio n. 22
0
void NonDLHSSampling::print_results(std::ostream& s)
{
  if (!numResponseFunctions) // DACE mode w/ opt or NLS
    Analyzer::print_results(s);

  if (varBasedDecompFlag)
    print_sobol_indices(s);
  else if (statsFlag) {
    s << "\nStatistics based on " << numSamples << " samples:\n";
    print_statistics(s);
  }
}
Esempio n. 23
0
static void
on_update (GdkFrameClock *frame_clock,
           gpointer       data)
{
  GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (frame_clock);
  gint64 frame_time = gdk_frame_timings_get_frame_time (timings);
  gint64 predicted_presentation_time = gdk_frame_timings_get_predicted_presentation_time (timings);
  gint64 refresh_interval;
  FrameData *pending_frame;

  if (clock_time_base == 0)
    clock_time_base = frame_time + PRE_BUFFER_TIME;

  gdk_frame_clock_get_refresh_info (frame_clock, frame_time,
                                    &refresh_interval, NULL);

  pending_frame = peek_pending_frame ();
  if (stream_time_to_clock_time (pending_frame->stream_time)
      < predicted_presentation_time + refresh_interval / 2)
    {
      while (TRUE)
        {
          FrameData *next_frame = peek_next_frame ();
          if (next_frame &&
              stream_time_to_clock_time (next_frame->stream_time)
              < predicted_presentation_time + refresh_interval / 2)
            {
              g_slice_free (FrameData, unqueue_frame ());
              n_frames++;
              dropped_frames++;
              pending_frame = next_frame;
            }
          else
            break;
        }

      if (displayed_frame)
        past_frames = g_list_prepend (past_frames, displayed_frame);

      n_frames++;
      displayed_frame = unqueue_frame ();
      displayed_frame->clock_time = stream_time_to_clock_time (displayed_frame->stream_time);

      displayed_frame->frame_counter = gdk_frame_timings_get_frame_counter (timings);
      variable_add (&time_factor_stats, time_factor);

      collect_old_frames ();
      print_statistics ();

      gtk_widget_queue_draw (window);
    }
}
Esempio n. 24
0
/** Command arguments are as follows
 *  - argv[1]: The corpus file
 *  - argv[2]: The search file
 *  - argv[3]: The number of significant terms to display
 */
int main(int argc, char * argv[]){
  // Create an index from the corpus
  create_corpus_index(argv[1]);

  // Create an index from the search file
  create_search_index(argv[2]);

  // Print statistics
  print_statistics(argv[2], (atoi(argv[3])));

  // No errors encountered
  return 0;
}
Esempio n. 25
0
void cvc4terminate() {
  set_terminate(default_terminator);
#ifdef CVC4_DEBUG
  LastExceptionBuffer* current = LastExceptionBuffer::getCurrent();
  LastExceptionBuffer::setCurrent(NULL);
  delete current;

  safe_print(STDERR_FILENO,
             "\n"
             "CVC4 was terminated by the C++ runtime.\n"
             "Perhaps an exception was thrown during stack unwinding.  "
             "(Don't do that.)\n");
  print_statistics();
  default_terminator();
#else /* CVC4_DEBUG */
  safe_print(STDERR_FILENO,
             "CVC4 was terminated by the C++ runtime.\n"
             "Perhaps an exception was thrown during stack unwinding.\n");
  print_statistics();
  default_terminator();
#endif /* CVC4_DEBUG */
}
Esempio n. 26
0
void main (int argc, uchar **argv) {
    int i, j, c;
    struct stat f_stat;

    printf("compdic: Utility for compilation of word dictionaries\n");
    if (argc!=4) error("Usage:\ncompdic <alphabet> <text_dic> <comp_dic>");

    if ((fi=fopen(argv[1],"rb"))==NULL) error("Error opening alphabet file");
    memset(codes, 0, 256);
    for (letter_count=1; (c=getc(fi))>=' '; codes[c] = letter_count++) ;
    fclose(fi);

    stat(argv[2],&f_stat);
    init_mem(letter_count, f_stat.st_size + 50000);

    if ((fi=fopen(argv[2],"rb"))==NULL) error("Error opening input file");

    clear_state(0);
    owf[0]=0;

    wf1[0]=0;
    get_word_info(wf); // init of get_word_inf()

    while (get_word_info(wf)) {

        for (i=0; wf[i]==owf[i]; i++) ;		// find difference location

        for (j=strlen(owf)-1; j>=i; j--) state(j, codes[owf[j]]) = save_state(j+1);

        for (j=i+1; j<=strlen(wf); j++) clear_state(j);

        state(--j,0) = 1;

        strcpy(owf, wf);
    }
    fclose(fi);

    for (j=strlen(owf)-1; j>=0; j--) state(j, codes[owf[j]]) = save_state(j+1);

    save_cell(0, 'S', save_state(0));
    save_cell(1, 'T', last_full_cell+1);

    fo = fopen(argv[3], "wb");
    fwrite (cells, sizeof(tcell), last_full_cell+1, fo);
    fwrite (strings, 1, last_string, fo);
    fclose(fo);

    print_statistics();
}
Esempio n. 27
0
int main(const int argc, const char** argv) {
	double tstart1, tstop1, tstart2, tstop2, tstartall, tstopall;
	
	// start clocking
	tstartall = (double)clock()/(double)CLOCKS_PER_SEC;
	
	// mi will be the cards of the support sets and m is the total card
  std::vector<int> mi;
 	int m;
 	
 	// construct an empty pointset and an index
 	std::vector<std::vector<Field> > pointset;
 	map<std::vector<Field>,int> points_index;
 	
 	//read input (points, mi, m), apply cayley trick 
 	// (now you have the pointset), make the index
 	cayley_trick(pointset, points_index, mi, m);
	
	// compute the big matrix
	// BUT first homogenize the pointset, dirty way..
	vector<vector<Field> > homo_pointset;
	homogenize(pointset,homo_pointset);
	std::cout << homo_pointset << std::endl;
  HD dets(homo_pointset.begin(),homo_pointset.end());
	
	//define the projection
	vector<int> proj = proj_first_coord(PD,m,mi);
	
	// the data structure to hold the res polytope
	int numof_triangs=0, numof_init_Res_vertices;
	Convex_hull_d CH(PD);
	
	//compute the res polytope
	compute_res(pointset,points_index,m,mi,proj,dets,numof_triangs, numof_init_Res_vertices,CH);
	//compute_res_fast(pointset,points_index,m,mi,proj,dets,numof_triangs, numof_init_Res_vertices,CH);
	
	// stop clocking
	tstopall = (double)clock()/(double)CLOCKS_PER_SEC;
	
	// print the vertices of the res polytope
	for (Vertex_iterator_d vit = CH.vertices_begin(); vit != CH.vertices_end(); vit++)
		std::cout << vit->point() << " ";
	std::cout << std::endl;
	
	// print some statistics
	print_statistics(numof_triangs, numof_init_Res_vertices, CH.number_of_vertices(), tstopall-tstartall);
	
	return 0;
}
Esempio n. 28
0
static void reiserfs_put_super (struct super_block * s)
{
  int i;
  struct reiserfs_transaction_handle th ;
  
  /* change file system state to current state if it was mounted with read-write permissions */
  if (!(s->s_flags & MS_RDONLY)) {
    journal_begin(&th, s, 10) ;
    reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
    set_sb_state( SB_DISK_SUPER_BLOCK(s), s->u.reiserfs_sb.s_mount_state );
    journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
  }

  /* note, journal_release checks for readonly mount, and can decide not
  ** to do a journal_end
  */
  journal_release(&th, s) ;

  for (i = 0; i < SB_BMAP_NR (s); i ++)
    brelse (SB_AP_BITMAP (s)[i].bh);

  vfree (SB_AP_BITMAP (s));

  brelse (SB_BUFFER_WITH_SB (s));

  print_statistics (s);

  if (s->u.reiserfs_sb.s_kmallocs != 0) {
    reiserfs_warning ("vs-2004: reiserfs_put_super: allocated memory left %d\n",
		      s->u.reiserfs_sb.s_kmallocs);
  }

  if (s->u.reiserfs_sb.reserved_blocks != 0) {
    reiserfs_warning ("green-2005: reiserfs_put_super: reserved blocks left %d\n",
		      s->u.reiserfs_sb.reserved_blocks);
  }

  reiserfs_proc_unregister( s, "journal" );
  reiserfs_proc_unregister( s, "oidmap" );
  reiserfs_proc_unregister( s, "on-disk-super" );
  reiserfs_proc_unregister( s, "bitmap" );
  reiserfs_proc_unregister( s, "per-level" );
  reiserfs_proc_unregister( s, "super" );
  reiserfs_proc_unregister( s, "version" );
  reiserfs_proc_info_done( s );
  return;
}
Esempio n. 29
0
void read_udp(int fd) {

	int nbytes;
	//char buf[MAXDATA];
	int io = 0, total_bytes = 0;
	char *buf;

	buf = (char*) malloc(sizeof(char) * buflen);
	if(buf == NULL) {
		fprintf(stderr, "Not enough memory\n");
		exit(0);
	}

	struct timeval  my_time, start_time, end_time;

	struct s_adhdr ah;
	ah.mysize = 2 * sizeof(int) + sizeof(struct timeval);

	while(1) {
		//nbytes = read(fd, buf, sizeof(buf));
		nbytes = read(fd, buf, buflen);
		gettimeofday(&my_time, NULL);
		check("recvfrom", nbytes);
		buf[nbytes] = '\0';
		memcpy(&ah, buf, ah.mysize);

		if(ah.seq == 1) { printf("Finished.\n"); break; }

		if(ah.seq == 0) {
			fprintf(stdout, "Got Connection.\nStarting measurement...");
			fflush(stdout);
			gettimeofday(&start_time, NULL);
			continue;
		}
		insert_time_record(my_time, ah.tv, ah.seq);

		io++;
		total_bytes += nbytes;
        }

	gettimeofday(&end_time, NULL);
        printf("Connection closed by foreign host.\n");

	free(buf);
	print_statistics(SOCK_DGRAM, start_time, end_time, total_bytes, io);
}
Esempio n. 30
0
/**
  Works like the main function of the program, it calls almost all other functions
*/
void run()
{
    char **files = get_files_list();

    read_matrix_from_file(files[1], 1);
    if (error_flag == 1)
        return;

    read_matrix_from_file(files[2], 2);
    if (error_flag == 1)
        return;

    post_read();
    if (error_flag == 1)
        return;

    calculate_without_threads();
    calculate_element_by_element();
    calculate_row_by_row();
    write_matrix_to_file(files[3]);
    print_statistics();
}