예제 #1
0
파일: test6.c 프로젝트: bgarate/tso-alloc
void run_benchmark(struct parameters p) {
	

	init_benchmark(p);

	benchmark.mapping_size = getpagesize() * MAPPING_SIZE;
	benchmark.free_space = benchmark.mapping_size;
	benchmark.max_deallocs = p.max_allocs;

	benchmark.allocs_size = 0;

	benchmark.allocs_number = 0;
	benchmark.deallocs_number = 0;
	benchmark.runs = 0;

	benchmark.alloc_time = 0;

	int previous_allocs = 0;
	int previous_deallocs = 0;

	bool alloc_result;

	while(true) {
		benchmark.runs++;

		clock_t start_time = clock();

		alloc_result = run_allocations(p);

		clock_t end_time = clock();
		benchmark.alloc_time += end_time - start_time;

		if(!alloc_result && (benchmark.max_deallocs == 0 || !p.deallocate_after_fail))
			break;
		int old_max_deallocs = benchmark.max_deallocs;
		run_deallocations(p);
		if(DO_PRINT)
      printf("Allocs: %d | Deallocs: %d | ",
		benchmark.allocs_number - previous_allocs,
		benchmark.deallocs_number - previous_deallocs);
		if(DO_PRINT)
      printf("Running diference: %d | Max deallocs: %d\n",
		benchmark.allocs_number - benchmark.deallocs_number, old_max_deallocs);
		previous_allocs = benchmark.allocs_number;
		previous_deallocs = benchmark.deallocs_number;
	}

	save_result(p);

	if(DO_PRINT) {
    printf("TEST STOPPED\n");
  	printf("FULL DEALLOCATION\n");
  }
	run_full_deallocation();

}
예제 #2
0
    void run_benchmark_1op(F f, OS& out, std::size_t size, std::size_t iter, init_method init = init_method::classic)
    {
        bench_vector<float> f_lhs, f_rhs, f_res;
        bench_vector<double> d_lhs, d_rhs, d_res;

        switch (init)
        {
        case init_method::classic:
            init_benchmark(f_lhs, f_rhs, f_res, size);
            init_benchmark(d_lhs, d_rhs, d_res, size);
            break;
        case init_method::arctrigo:
            init_benchmark_arctrigo(f_lhs, f_rhs, f_res, size);
            init_benchmark_arctrigo(d_lhs, d_rhs, d_res, size);
            break;
        default:
            init_benchmark(f_lhs, f_rhs, f_res, size);
            init_benchmark(d_lhs, d_rhs, d_res, size);
            break;
        }

        duration_type t_float_scalar = benchmark_scalar(f, f_lhs, f_res, iter);
        duration_type t_double_scalar = benchmark_scalar(f, d_lhs, d_res, iter);

#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        duration_type t_float_sse = benchmark_simd<batch<float, 4>>(f, f_lhs, f_res, iter);
        duration_type t_float_sse_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_lhs, f_res, iter);
        duration_type t_double_sse = benchmark_simd<batch<double, 2>>(f, d_lhs, d_res, iter);
        duration_type t_double_sse_u = benchmark_simd_unrolled<batch<double, 2>>(f, d_lhs, d_res, iter);
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        duration_type t_float_avx = benchmark_simd<batch<float, 8>>(f, f_lhs, f_res, iter);
        duration_type t_float_avx_u = benchmark_simd_unrolled<batch<float, 8>>(f, f_lhs, f_res, iter);
        duration_type t_double_avx = benchmark_simd<batch<double, 4>>(f, d_lhs, d_res, iter);
        duration_type t_double_avx_u = benchmark_simd_unrolled<batch<double, 4>>(f, d_lhs, d_res, iter);
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        duration_type t_float_neon = benchmark_simd<batch<float, 4>>(f, f_lhs, f_res, iter);
        duration_type t_float_neon_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_lhs, f_res, iter);
        duration_type t_double_neon = benchmark_simd<batch<double, 2>>(f, d_lhs, d_res, iter);
        duration_type t_double_neon_u = benchmark_simd_unrolled<batch<double, 2>>(f, d_lhs, d_res, iter);
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        duration_type t_float_fallback = benchmark_simd<batch<float, 7>>(f, f_lhs, f_res, iter);
        duration_type t_float_fallback_u = benchmark_simd_unrolled<batch<float, 7>>(f, f_lhs, f_res, iter);
        duration_type t_double_fallback = benchmark_simd<batch<double, 3>>(f, d_lhs, d_res, iter);
        duration_type t_double_fallback_u = benchmark_simd_unrolled<batch<double, 3>>(f, d_lhs, d_res, iter);
#endif

        out << "============================" << std::endl;
        out << f.name() << std::endl;
        out << "scalar float   : " << t_float_scalar.count() << "ms" << std::endl;
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        out << "sse float      : " << t_float_sse.count() << "ms" << std::endl;
        out << "sse float unr  : " << t_float_sse_u.count() << "ms" << std::endl;
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        out << "avx float      : " << t_float_avx.count() << "ms" << std::endl;
        out << "avx float unr  : " << t_float_avx_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        out << "neon float     : " << t_float_neon.count() << "ms" << std::endl;
        out << "neon float unr : " << t_float_neon_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        out << "flbk float     : " << t_float_fallback.count() << "ms" << std::endl;
        out << "flbk float unr : " << t_float_fallback_u.count() << "ms" << std::endl;
#endif
        out << "scalar double  : " << t_double_scalar.count() << "ms" << std::endl;
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        out << "sse double     : " << t_double_sse.count() << "ms" << std::endl;
        out << "sse double unr : " << t_double_sse_u.count() << "ms" << std::endl;
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        out << "avx double     : " << t_double_avx.count() << "ms" << std::endl;
        out << "avx double unr : " << t_double_avx_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        out << "neon double    : " << t_double_neon.count() << "ms" << std::endl;
        out << "neon double unr: " << t_double_neon_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        out << "flbk double    : " << t_double_fallback.count() << "ms" << std::endl;
        out << "flbk double unr: " << t_double_fallback_u.count() << "ms" << std::endl;
#endif
        out << "============================" << std::endl;
    }
예제 #3
0
    void run_benchmark_3op(F f, OS& out, std::size_t size, std::size_t iter)
    {
        bench_vector<float> f_op0, f_op1, f_op2, f_res;
        bench_vector<double> d_op0, d_op1, d_op2, d_res;

        init_benchmark(f_op0, f_op1, f_op2, f_res, size);
        init_benchmark(d_op0, d_op1, d_op2, d_res, size);

        duration_type t_float_scalar = benchmark_scalar(f, f_op0, f_op1, f_op2, f_res, iter);
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        duration_type t_float_sse = benchmark_simd<batch<float, 4>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_float_sse_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_op0, f_op1, f_op2, f_res, iter);
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        duration_type t_float_avx = benchmark_simd<batch<float, 8>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_float_avx_u = benchmark_simd_unrolled<batch<float, 8>>(f, f_op0, f_op1, f_op2, f_res, iter);
#endif
        duration_type t_double_scalar = benchmark_scalar(f, d_op0, d_op1, d_op2, d_res, iter);
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        duration_type t_double_sse = benchmark_simd<batch<double, 2>>(f, d_op0, d_op1, d_op2, d_res, iter);
        duration_type t_double_sse_u = benchmark_simd_unrolled<batch<double, 2>>(f, d_op0, d_op1, d_op2, d_res, iter);
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        duration_type t_double_avx = benchmark_simd<batch<double, 4>>(f, d_op0, d_op1, d_op2, d_res, iter);
        duration_type t_double_avx_u = benchmark_simd_unrolled<batch<double, 4>>(f, d_op0, d_op1, d_op2, d_res, iter);
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        duration_type t_float_neon = benchmark_simd<batch<float, 4>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_float_neon_u = benchmark_simd_unrolled<batch<float, 4>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_double_neon = benchmark_simd<batch<double, 2>>(f, d_op0, d_op1, d_op2, d_res, iter);
        duration_type t_double_neon_u = benchmark_simd_unrolled<batch<double, 2>>(f, d_op0, d_op1, d_op2, d_res, iter);
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        duration_type t_float_fallback = benchmark_simd<batch<float, 7>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_float_fallback_u = benchmark_simd_unrolled<batch<float, 7>>(f, f_op0, f_op1, f_op2, f_res, iter);
        duration_type t_double_fallback = benchmark_simd<batch<double, 3>>(f, d_op0, d_op1, d_op2, d_res, iter);
        duration_type t_double_fallback_u = benchmark_simd_unrolled<batch<double, 3>>(f, d_op0, d_op1, d_op2, d_res, iter);
#endif

        out << "============================" << std::endl;
        out << f.name() << std::endl;
        out << "scalar float   : " << t_float_scalar.count() << "ms" << std::endl;
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        out << "sse float      : " << t_float_sse.count() << "ms" << std::endl;
        out << "sse float unr  : " << t_float_sse_u.count() << "ms" << std::endl;
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        out << "avx float      : " << t_float_avx.count() << "ms" << std::endl;
        out << "avx float unr  : " << t_float_avx_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        out << "neon float     : " << t_float_neon.count() << "ms" << std::endl;
        out << "neon float unr : " << t_float_neon_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        out << "flbk float     : " << t_float_fallback.count() << "ms" << std::endl;
        out << "flbk float unr : " << t_float_fallback_u.count() << "ms" << std::endl;
#endif
        out << "scalar double  : " << t_double_scalar.count() << "ms" << std::endl;
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
        out << "sse double     : " << t_double_sse.count() << "ms" << std::endl;
        out << "sse double unr : " << t_double_sse_u.count() << "ms" << std::endl;
#endif
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
        out << "avx double     : " << t_double_avx.count() << "ms" << std::endl;
        out << "avx double unr : " << t_double_avx_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ARM_INSTR_SET)
        out << "neon double    : " << t_double_neon.count() << "ms" << std::endl;
        out << "neon double unr: " << t_double_neon_u.count() << "ms" << std::endl;
#endif
#if defined(XSIMD_ENABLE_FALLBACK)
        out << "flbk double    : " << t_double_fallback.count() << "ms" << std::endl;
        out << "flbk double unr: " << t_double_fallback_u.count() << "ms" << std::endl;
#endif
        out << "============================" << std::endl;
    }
예제 #4
0
int main(int argc, char *argv[]) {
  char *filename;
  int32_t code;
  FILE *dump;
  double time, mem_used;

  if (argc > 2) {
    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
    exit(YICES_EXIT_USAGE);
  }

  if (argc == 2) {
    // read from file
    filename = argv[1];
    if (init_smt_file_lexer(&lexer, filename) < 0) {
      perror(filename);
      exit(YICES_EXIT_FILE_NOT_FOUND);
    }
  } else {
    // read from stdin
    init_smt_stdin_lexer(&lexer);
  }

  yices_init();

  init_smt_tstack(&stack);

  init_parser(&parser, &lexer, &stack);
  init_benchmark(&bench);
  code = parse_smt_benchmark(&parser, &bench);
  if (code == 0) {
    printf("No syntax error found\n");
  }

  if (benchmark_reduced_to_false(&bench)) {
    printf("Reduced to false\n\nunsat\n");
    fflush(stdout);
  }
  printf("\n");

  time = get_cpu_time();
  mem_used = mem_size() / (1024 * 1024);
  printf("Construction time: %.4f s\n", time);
  printf("Memory used: %.2f MB\n\n", mem_used);
  fflush(stdout);

  dump = fopen("yices2new.dmp", "w");
  if (dump == NULL) {
    perror("yices2new.dmp");
  } else {
    dump_benchmark(dump, &bench);
    fclose(dump);
  }

  delete_benchmark(&bench);
  delete_parser(&parser);
  close_lexer(&lexer);
  delete_tstack(&stack);
  yices_exit();

  return YICES_EXIT_SUCCESS;
}