void Compilation::emit_lir() {
  CHECK_BAILOUT();

  LIRGenerator gen(this, method());
  {
    PhaseTraceTime timeit(_t_lirGeneration);
    hir()->iterate_linear_scan_order(&gen);
  }

  CHECK_BAILOUT();

  {
    PhaseTraceTime timeit(_t_linearScan);

    LinearScan* allocator = new LinearScan(hir(), &gen, frame_map());
    set_allocator(allocator);
    // Assign physical registers to LIR operands using a linear scan algorithm.
    allocator->do_linear_scan();
    CHECK_BAILOUT();

    _max_spills = allocator->max_spills();
  }

  if (BailoutAfterLIR) {
    if (PrintLIR && !bailed_out()) {
      print_LIR(hir()->code());
    }
    bailout("Bailing out because of -XX:+BailoutAfterLIR");
  }
}
int Compilation::compile_java_method() {
  assert(!method()->is_native(), "should not reach here");

  if (BailoutOnExceptionHandlers) {
    if (method()->has_exception_handlers()) {
      bailout("linear scan can't handle exception handlers");
    }
  }

  CHECK_BAILOUT_(no_frame_size);

  {
    PhaseTraceTime timeit(_t_buildIR);
  build_hir();
  }
  if (BailoutAfterHIR) {
    BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size);
  }


  {
    PhaseTraceTime timeit(_t_emit_lir);

    _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack()));
    emit_lir();
  }
  CHECK_BAILOUT_(no_frame_size);

  {
    PhaseTraceTime timeit(_t_codeemit);
    return emit_code_body();
  }
}
示例#3
0
int main(int argc, char *argv[])
{
    float start = timeit();

    int ways = 0;
    int idx = 0;

    while (total[idx] <= limit && (idx != CAP)) {

        total[idx] += currency[idx];
        int sum = calculate_total();

        if (sum < limit)
            idx = 0;
        else {
            if (sum == limit)
                ways++;
            total[idx] = 0;
            idx++;
        } 
    }

    float stop = timeit();

    printf("Answer: %d\n", ways);
    printf("Time: %f\n", stop - start);

    return 0;
}
示例#4
0
int main(int argc, char **argv)
{
    float mps;

    mps = timeit(time_greenlet_switch_to) / 1000000.0;
    printf("greenlet_switch_to: %.2f million context switches/sec\n", mps);
    mps = timeit(time_pthread_cond_wait) / 1000000.0;
    printf("pthread_cond_wait: %.2f million context switches/sec\n", mps);

    return 0;
}
/**
 * A main runner function that runner.py uses to execute LCS
 * tests with the Hirshberg algorithm.
 **/
int main( int argc, char** argv ){
    
    int ittr, x, y;

    extern ulong memusage;
    memusage = 0L;

    sscanf( argv[1], "%i", &ittr);
    scanf("%d %d", &x, &y);

    char* a = (char*)malloc( (x+1) * sizeof(char) );
    char* b = (char*)malloc( (y+1) * sizeof(char) );
    char* ansref = (char*)malloc( (x+1) * sizeof(char) );

    scanf( "%s %s", a, b );

    printf("Timing, Quadratic Time and Linear Space Algorithm (Hirshberg's):\n");
    double avg = timeit( Hirshberg, ittr, a, b, x, y, &ansref );

    printf( "Dynamic Memory Allocated: %lu bytes\n", memusage/ittr );
    printf( "Time Const: %e\n", avg / (x+y) );// Quadratic, so sum.

    free( a ); free( b );
    free( ansref );
    return 0;
}
示例#6
0
文件: memsize.c 项目: Maxlufs/CSE221
int
main(int ac, char **av)
{
	char	*where;
	size_t	size = 0;
	size_t	max = 0;
	size_t	delta;

	if (ac == 2) {
		max = size = bytes(av[1]) * 1024 * 1024;
	}
	if (max < 1024 * 1024) {
		max = size = 1024 * 1024 * 1024;
	}
	/*
	 * Binary search down and then binary search up
	 */
	for (where = 0; !test_malloc(size); size >>= 1) {
		max = size;
	}
	/* delta = size / (2 * 1024 * 1024) */
	for (delta = (size >> 21); delta > 0; delta >>= 1) {
		uint64 sz = (uint64)size + (uint64)delta * 1024 * 1024;
		size_t check = sz;
		if (max < sz) continue;
		if (check < sz || !test_malloc(sz)) break;
		size = sz;
	}
	if (where = malloc(size)) {
		timeit(where, size);
		free(where);
	}
	exit (0);
}
Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci)
: _compiler(compiler)
, _env(env)
, _method(method)
, _osr_bci(osr_bci)
, _hir(NULL)
, _max_spills(-1)
, _frame_map(NULL)
, _masm(NULL)
, _has_exception_handlers(false)
, _has_fpu_code(true)   // pessimistic assumption
, _has_unsafe_access(false)
, _bailout_msg(NULL)
, _exception_info_list(NULL)
, _allocator(NULL)
, _code(Runtime1::get_buffer_blob()->instructions_begin(),
        Runtime1::get_buffer_blob()->instructions_size())
, _current_instruction(NULL)
#ifndef PRODUCT
, _last_instruction_printed(NULL)
#endif // PRODUCT
{
  PhaseTraceTime timeit(_t_compile);

  assert(_arena == NULL, "shouldn't only one instance of Compilation in existence at a time");
  _arena = Thread::current()->resource_area();
  _compilation = this;
  _needs_debug_information = _env->jvmti_can_examine_or_deopt_anywhere() ||
                               JavaMonitorsInStackTrace || AlwaysEmitDebugInfo || DeoptimizeALot;
  _exception_info_list = new ExceptionInfoList();
  _implicit_exception_table.set_size(0);
  compile_method();
}
示例#8
0
int main() {
	int i, res;
	ed25519_public_key pk;
	ed25519_signature sig;
	unsigned char forge[1024] = {'x'};
	curved25519_key csk[2] = {{255}};
	uint64_t ticks, pkticks = maxticks, signticks = maxticks, openticks = maxticks, curvedticks = maxticks;

	for (i = 0; i < 1024; i++) {
		ed25519_publickey(dataset[i].sk, pk);
		edassertequal(dataset[i].pk, pk, sizeof(pk), i, "public key didn't match");
		ed25519_sign((unsigned char *)dataset[i].m, i, dataset[i].sk, pk, sig);
		edassertequal(dataset[i].sig, sig, sizeof(sig), i, "signature didn't match");
		edassert(!ed25519_sign_open((unsigned char *)dataset[i].m, i, pk, sig), i, "failed to open message");

		memcpy(forge, dataset[i].m, i);
		if (i)
			forge[i - 1] += 1;

		edassert(ed25519_sign_open(forge, (i) ? i : 1, pk, sig), i, "opened forged message");
	}

	for (i = 0; i < 1024; i++)
		curved25519_scalarmult_basepoint(csk[(i & 1) ^ 1], csk[i & 1]);
	edassertequal(curved25519_expected, csk[0], sizeof(curved25519_key), 0, "curve25519 failed to generate correct value");

	printf("success\n");

	for (i = 0; i < 2048; i++) {
		timeit(ed25519_publickey(dataset[0].sk, pk), pkticks)
		edassertequal(dataset[0].pk, pk, sizeof(pk), i, "public key didn't match");
		timeit(ed25519_sign((unsigned char *)dataset[0].m, 0, dataset[0].sk, pk, sig), signticks)
		edassertequal(dataset[0].sig, sig, sizeof(sig), i, "signature didn't match");
		timeit(res = ed25519_sign_open((unsigned char *)dataset[0].m, 0, pk, sig), openticks)
		edassert(!res, 0, "failed to open message");
		timeit(curved25519_scalarmult_basepoint(csk[1], csk[0]), curvedticks);
	}
	printf("%.0f ticks/public key generation\n", (double)pkticks);
	printf("%.0f ticks/signature\n", (double)signticks);
	printf("%.0f ticks/signature verification\n", (double)openticks);
	printf("%.0f ticks/curve25519 basepoint scalarmult\n", (double)curvedticks);
	return 0;
}
示例#9
0
int main(int argc, char *argv[])
{
    float start = timeit();

    long long high_num = 0;

    for (long long canidate=3, high=0, count=0; canidate < 1000000; canidate += 2, count=0) {
        for (long long collatz=canidate; collatz != 1; count++) 
            collatz = collatz % 2 == 0 ? collatz / 2 : (collatz * 3) + 1; 
        if (count > high) {
            high = count;
            high_num = canidate;
        }
    }

    float stop = timeit();

    printf ("Answer: %lld\n", high_num);
    printf ("Time: %f\n", stop - start);

    return 0;
}
示例#10
0
Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
                         int osr_bci, BufferBlob* buffer_blob)
: _compiler(compiler)
, _env(env)
, _log(env->log())
, _method(method)
, _osr_bci(osr_bci)
, _hir(NULL)
, _max_spills(-1)
, _frame_map(NULL)
, _masm(NULL)
, _has_exception_handlers(false)
, _has_fpu_code(true)   // pessimistic assumption
, _would_profile(false)
, _has_unsafe_access(false)
, _has_method_handle_invokes(false)
, _bailout_msg(NULL)
, _exception_info_list(NULL)
, _allocator(NULL)
, _next_id(0)
, _next_block_id(0)
, _code(buffer_blob)
, _has_access_indexed(false)
, _current_instruction(NULL)
#ifndef PRODUCT
, _last_instruction_printed(NULL)
#endif // PRODUCT
{
  PhaseTraceTime timeit(_t_compile);
  _arena = Thread::current()->resource_area();
  _env->set_compiler_data(this);
  _exception_info_list = new ExceptionInfoList();
  _implicit_exception_table.set_size(0);
  compile_method();
  if (bailed_out()) {
    _env->record_method_not_compilable(bailout_msg(), !TieredCompilation);
    if (is_profiling()) {
      // Compilation failed, create MDO, which would signal the interpreter
      // to start profiling on its own.
      _method->ensure_method_data();
    }
  } else if (is_profiling()) {
    ciMethodData *md = method->method_data_or_null();
    if (md != NULL) {
      md->set_would_profile(_would_profile);
    }
  }
}
示例#11
0
int main(int argc, char const **argv)
{
    init_env(argc, argv);
    omp_set_num_threads(num_thread);
    high_resolution_clock::time_point s;

    Gmm = G * mass * mass;
    for (int i = 0; i < iters; ++i) {
        if (gui) draw_points(0);
        s = high_resolution_clock::now();
        #pragma omp parallel for schedule(dynamic, 50)
        for (int j = 0; j < num_body; ++j) move_nth_body(j);
        Body* t = new_bodies; new_bodies = bodies; bodies = t;
        total_time += timeit(s);
    }
    INFO("Run in " << total_time.count() / 1000 << " us");
    return 0;
}
示例#12
0
void Compilation::compile_method() {
  // setup compilation
  initialize();

  if (!method()->can_be_compiled()) {
    // Prevent race condition 6328518.
    // This can happen if the method is obsolete or breakpointed.
    bailout("Bailing out because method is not compilable");
    return;
  }

  if (_env->jvmti_can_hotswap_or_post_breakpoint()) {
    // We can assert evol_method because method->can_be_compiled is true.
    dependency_recorder()->assert_evol_method(method());
  }

  if (method()->break_at_execute()) {
    BREAKPOINT;
  }

#ifndef PRODUCT
  if (PrintCFGToFile) {
    CFGPrinter::print_compilation(this);
  }
#endif

  // compile method
  int frame_size = compile_java_method();

  // bailout if method couldn't be compiled
  // Note: make sure we mark the method as not compilable!
  CHECK_BAILOUT();

  if (InstallMethods) {
    // install code
    PhaseTraceTime timeit(_t_codeinstall);
    install_code(frame_size);
  }

  if (log() != NULL) // Print code cache state into compiler log
    log()->code_cache_state();

  totalInstructionNodes += Instruction::number_of_instructions();
}
示例#13
0
static void
test_main(void) {
	int i;
	static const curve25519_key max = {
		255,255,255,255,255,255,255,255,
		255,255,255,255,255,255,255,255,
		255,255,255,255,255,255,255,255,
		255,255,255,255,255,255,255,255
	};
	static const curve25519_key mid = {
		127,127,127,127,127,127,127,127,
		127,127,127,127,127,127,127,127,
		127,127,127,127,127,127,127,127,
		127,127,127,127,127,127,127,127
	};
	curve25519_key pk[2];
	curve25519_key shared[2];
	uint64_t ticks, curveticks = maxticks;

	curve25519_donna(pk[0], max, max);
	for (i = 0; i < 1023; i++)
		curve25519_donna(pk[(i & 1) ^ 1], pk[i & 1], max);
	curve25519_donna_basepoint(pk[0], pk[1]);
	curveassert_equal(curve25519_expected, pk[0], sizeof(curve25519_key), "curve25519 sanity test failed to generate correct value");

	curve25519_donna_basepoint(pk[0], max);
	curve25519_donna_basepoint(pk[1], mid);
	curve25519_donna(shared[0], max, pk[1]);
	curve25519_donna(shared[1], mid, pk[0]);
	curveassert_equal(curve25519_shared, shared[0], sizeof(curve25519_key), "curve25519 failed to generate the same shared key (1)");
	curveassert_equal(curve25519_shared, shared[1], sizeof(curve25519_key), "curve25519 failed to generate the same shared key (2)");

	for (i = 0; i < 2048; i++) {
		timeit(curve25519_donna(pk[1], pk[0], max), curveticks);
	}

	printf("%.0f ticks/curve25519 scalarmult\n", (double)curveticks);
}
示例#14
0
int main(int argc, char** args) {
	int threads = 1;
	if(argc == 2) {
		sscanf(args[1], "%i", &threads);
		if(threads < 1) {
			printf("Threads must be greater 1.\n");
			return 1;
		}
	}
	printf("Running profile tests on %i threads\n", threads);
	ERRCHECK(Lav_initialize());
	for(int i = 0; i < to_profile_size; i++) {
		auto &info = to_profile[i];
		printf("Estimate for %s nodes: ", std::get<0>(info).c_str());
		LavHandle s;
		ERRCHECK(Lav_createServer(SR, BLOCK_SIZE, &s));
		ERRCHECK(Lav_serverSetThreads(s, threads));
		int times=std::get<1>(info);
		//If it's not at least threads, make it threads.
		if(times < threads) times = threads;
		auto handles=std::get<2>(info)(s, times);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeConnectServer(h, 0));
		}
		float dur=timeit([&] () {
			ERRCHECK(Lav_serverGetBlock(s, 2, 1, storage));
		}, ITERATIONS);
		dur /= ITERATIONS;
		float estimate = (BLOCK_SIZE/(float)SR)/dur*times;
		printf("%f\n", estimate);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeDisconnect(h, 0, 0, 0));
			ERRCHECK(Lav_handleDecRef(h));
		}
		ERRCHECK(Lav_handleDecRef(s));
	}
}
示例#15
0
void main(int argc, char** args) {
	int threads = 1;
	if(argc == 2) {
		sscanf(args[1], "%i", &threads);
		if(threads < 1) {
			printf("Threads must be greater 1.\n");
			return;
		}
	}
	printf("Running profile tests on %i threads\n", threads);
	ERRCHECK(Lav_initialize());
	for(int i = 0; i < to_profile_size; i++) {
		auto &info = to_profile[i];
		printf("Estimate for %s nodes: ", std::get<0>(info).c_str());
		LavHandle sim;
		ERRCHECK(Lav_createSimulation(SR, BLOCK_SIZE, &sim));
		ERRCHECK(Lav_simulationSetThreads(sim, threads));
		int times=std::get<1>(info);
		//If it's not at least threads, make it threads.
		if(times < threads) times = threads;
		auto handles=std::get<2>(info)(sim, times);
		for(auto h: handles) {
			ERRCHECK(Lav_nodeSetIntProperty(h, Lav_NODE_STATE, Lav_NODESTATE_ALWAYS_PLAYING));
		}
		float dur=timeit([&] () {
			ERRCHECK(Lav_simulationGetBlock(sim, 2, 1, storage));
		}, ITERATIONS);
		dur /= ITERATIONS;
		float estimate = (BLOCK_SIZE/(float)SR)/dur*times;
		printf("%f\n", estimate);
		for(auto h: handles) {
			ERRCHECK(Lav_handleDecRef(h));
		}
		ERRCHECK(Lav_handleDecRef(sim));
	}
}
示例#16
0
void G_COLD
map_test(void)
{
	sha1_t *keys;
	map_t *mh, *mp;
	int i;
	size_t count;
	int tests;
	struct {
		unsigned insertion, contains, removal;
	} faster = { 0, 0, 0};
	bool verbose = common_stats > 1;

	if (common_stats <= 0)
		return;

	XMALLOC_ARRAY(keys, ITEM_COUNT);

	for (i = 0; i < ITEM_COUNT; i++)
		random_bytes(keys[i].data, SHA1_RAW_SIZE);

	mh = map_create_hash(sha1_hash, sha1_eq);
	mp = map_create_patricia(KEYBITS);

	timeit(test_map_insert, mh, keys, ITEM_COUNT,
		LOOPS, "map hash insertion", verbose);

	timeit(test_map_insert, mp, keys, ITEM_COUNT,
		LOOPS, "map PATRICIA insertion", verbose);

	map_destroy(mh);
	map_destroy(mp);

	for (tests = 0, count = ITEM_COUNT; count > 1; count /= 10) {
		double htime;
		double ptime;

		tests++;

		mh = map_create_hash(sha1_hash, sha1_eq);
		mp = map_create_patricia(KEYBITS);

		htime = timeit(test_map_insert, mh, keys, count,
			1, "map hash reloading", verbose);

		ptime = timeit(test_map_insert, mp, keys, count,
			1, "map PATRICIA reloading", verbose);

		if (verbose)
			g_info("PATRICIA insertion %s than hash with %zu items",
				ptime < htime ? "faster" : "slower", count);

		if (ptime < htime)
			faster.insertion++;

		htime = timeit(test_map_contains, mh, keys, count,
			LOOPS, "map hash contains", verbose);

		ptime = timeit(test_map_contains, mp, keys, count,
			LOOPS, "map PATRICIA contains", verbose);

		if (verbose)
			g_info("PATRICIA contains %s than hash with %zu items",
				ptime < htime ? "faster" : "slower", count);

		if (ptime < htime)
			faster.contains++;

		htime = timeit(test_map_remove, mh, keys, count,
			1, "map hash remove", verbose);

		ptime = timeit(test_map_remove, mp, keys, count,
			1, "map PATRICIA remove", verbose);

		if (verbose)
			g_info("PATRICIA remove %s than hash with %zu items",
				ptime < htime ? "faster" : "slower", count);

		if (ptime < htime)
			faster.removal++;

		map_destroy(mh);
		map_destroy(mp);
	}

	if (faster.insertion)
		g_info("PATRICIA insert was faster than hash in %d out of %d tests",
			faster.insertion, tests);
	if (faster.contains)
		g_info(
			"PATRICIA contains was faster than hash in %d out of %d tests",
			faster.contains, tests);
	if (faster.removal)
		g_info("PATRICIA remove was faster than hash in %d out of %d tests",
			faster.removal, tests);

	XFREE_NULL(keys);
}
示例#17
0
//************************************************************************
// compute_energy_and_force() function
//   - Calculates energy and force acting on each atom.
//   - Arguments:
//       - myatoms: struct containing all atomic information.
//       - len_jo: struct containing lennard jones interaction parameters.
//       - m_pars: struct containing misc. parameters.
//************************************************************************
void compute_energy_and_force( Atoms * myatoms, const lj_params * len_jo, 
                               const misc_params * m_pars, int scountsARR[], int displsARR[], int rank, int nprocs )
{

   //#pragma omp parallel
   //{
      
      //int tid = omp_get_thread_num();

      timeit(1,0);
      int atomi, atomj, i;
      #pragma simd
      for (atomi=0; atomi < myatoms->N; atomi++)
      {
         myatoms->fx[atomi] = 0.0;
         myatoms->fy[atomi] = 0.0;
         myatoms->fz[atomi] = 0.0;
      }

      myatoms->pot_energy = 0.0;
      myatoms->virial = 0.0;

      float sum_local_pot[myatoms->N]; //need to initialize all elements to zero
      float sum_local_vir[myatoms->N]; 
      memset(sum_local_pot, 0, myatoms->N * sizeof(sum_local_pot[0]) );
      memset(sum_local_vir, 0, myatoms->N * sizeof(sum_local_vir[0]) );
   
      for (atomi=0; atomi < myatoms->N; atomi++)
      {

         float sum_loco_pot_total = 0;
         float sum_loco_vir_total = 0;

         //old: non-vectorized
         //for (atomj=atomi+1 ; atomj < myatoms->N; atomj++)
         #pragma simd
         for (atomj=0 ; atomj < myatoms->N; atomj++)
         {  
          
            if (atomj != atomi )
            {
               
      
               float xxi = myatoms->xx[atomi] - myatoms->xx[atomj];
               xxi = minimum_image( xxi, m_pars->side, m_pars->sideh );
               float yyi = myatoms->yy[atomi] - myatoms->yy[atomj];
               yyi = minimum_image( yyi, m_pars->side, m_pars->sideh );
               float zzi = myatoms->zz[atomi] - myatoms->zz[atomj];
               zzi = minimum_image( zzi, m_pars->side, m_pars->sideh );

               float dis2 = xxi*xxi + yyi*yyi + zzi*zzi;
               if ( dis2 <= len_jo->rcut2 )
               {
                  float dis2i = 1.0 / dis2;
                  float dis6i = dis2i * dis2i * dis2i;
                  float dis12i = dis6i * dis6i;
                  //old: non-vectorized
                  //myatoms->pot_energy += len_jo->sig12 * dis12i - 
                  //                       len_jo->sig6 * dis6i;
                  //-----------------------------------------------
                  float loco_pot_energy = 0; //local variable 
                  loco_pot_energy = len_jo->sig12 * dis12i - 
                                         len_jo->sig6 * dis6i;
                  sum_local_pot[atomj] += loco_pot_energy;
                  //-----------------------------------------------
                  
                  float fterm = dis2i * ( 2.0 * len_jo->sig12 * dis12i -
                                                len_jo->sig6 * dis6i );
                  
                  //myatoms->virial -= fterm * dis2;
                  float loco_vir_value  = 0;    //local variable 
                  loco_vir_value = fterm * dis2;
                  sum_local_vir[atomj] -= loco_vir_value;
                  /*
                  //old: non-vectorized since atomi is not in inner loop.
                  myatoms->fx[atomi] += fterm * xxi;
                  myatoms->fy[atomi] += fterm * yyi;
                  myatoms->fz[atomi] += fterm * zzi;
                  */
                  myatoms->fx[atomj] -= fterm * xxi;
                  myatoms->fy[atomj] -= fterm * yyi;
                  myatoms->fz[atomj] -= fterm * zzi;
               
               }
            }
         } 
      }


      for (atomi=0; atomi < myatoms->N; atomi++)
      {
         myatoms -> pot_energy += sum_local_pot[atomi];
         myatoms -> virial     += sum_local_vir[atomi];
         myatoms->fx[atomi] *= 24.0 * len_jo->eps;
         myatoms->fy[atomi] *= 24.0 * len_jo->eps;
         myatoms->fz[atomi] *= 24.0 * len_jo->eps;
      }

      myatoms -> pot_energy *= 0.5;
      myatoms -> virial *= 0.5;

      myatoms->pot_energy *= 4.0 * len_jo->eps;
      myatoms->virial *= 24.0 * len_jo->eps;
      timeit(1,1);

   //}

}
示例#18
0
void Compilation::build_hir() {
  CHECK_BAILOUT();

  // setup ir
  CompileLog* log = this->log();
  if (log != NULL) {
    log->begin_head("parse method='%d' ",
                    log->identify(_method));
    log->stamp();
    log->end_head();
  }
  _hir = new IR(this, method(), osr_bci());
  if (log)  log->done("parse");
  if (!_hir->is_valid()) {
    bailout("invalid parsing");
    return;
  }

#ifndef PRODUCT
  if (PrintCFGToFile) {
    CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false);
  }
#endif

#ifndef PRODUCT
  if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); }
  if (PrintIR  || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); }
#endif

  _hir->verify();

  if (UseC1Optimizations) {
    NEEDS_CLEANUP
    // optimization
    PhaseTraceTime timeit(_t_optimize_blocks);

    _hir->optimize_blocks();
  }

  _hir->verify();

  _hir->split_critical_edges();

#ifndef PRODUCT
  if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); }
  if (PrintIR  || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); }
#endif

  _hir->verify();

  // compute block ordering for code generation
  // the control flow must not be changed from here on
  _hir->compute_code();

  if (UseGlobalValueNumbering) {
    // No resource mark here! LoopInvariantCodeMotion can allocate ValueStack objects.
    int instructions = Instruction::number_of_instructions();
    GlobalValueNumbering gvn(_hir);
    assert(instructions == Instruction::number_of_instructions(),
           "shouldn't have created an instructions");
  }

  _hir->verify();

#ifndef PRODUCT
  if (PrintCFGToFile) {
    CFGPrinter::print_cfg(_hir, "Before RangeCheckElimination", true, false);
  }
#endif

  if (RangeCheckElimination) {
    if (_hir->osr_entry() == NULL) {
      PhaseTraceTime timeit(_t_rangeCheckElimination);
      RangeCheckElimination::eliminate(_hir);
    }
  }

#ifndef PRODUCT
  if (PrintCFGToFile) {
    CFGPrinter::print_cfg(_hir, "After RangeCheckElimination", true, false);
  }
#endif

  if (UseC1Optimizations) {
    // loop invariant code motion reorders instructions and range
    // check elimination adds new instructions so do null check
    // elimination after.
    NEEDS_CLEANUP
    // optimization
    PhaseTraceTime timeit(_t_optimize_null_checks);

    _hir->eliminate_null_checks();
  }

  _hir->verify();

  // compute use counts after global value numbering
  _hir->compute_use_counts();

#ifndef PRODUCT
  if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); }
  if (PrintIR  || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); }
#endif

  _hir->verify();
}
void Compilation::build_hir() {
  CHECK_BAILOUT();

  // setup ir
  _hir = new IR(this, method(), osr_bci());
  if (!_hir->is_valid()) {
    bailout("invalid parsing");
    return;
  }

#ifndef PRODUCT
  if (PrintCFGToFile) {
    CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false);
  }
#endif

#ifndef PRODUCT
  if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); }
  if (PrintIR  || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); }
#endif

  _hir->verify();

  if (UseC1Optimizations) {
    NEEDS_CLEANUP
    // optimization
    PhaseTraceTime timeit(_t_optimizeIR);

    _hir->optimize();
  }

  _hir->verify();

  _hir->split_critical_edges();

#ifndef PRODUCT
  if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); }
  if (PrintIR  || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); }
#endif

  _hir->verify();

  // compute block ordering for code generation
  // the control flow must not be changed from here on
  _hir->compute_code();

  if (UseGlobalValueNumbering) {
    ResourceMark rm;
    int instructions = Instruction::number_of_instructions();
    GlobalValueNumbering gvn(_hir);
    assert(instructions == Instruction::number_of_instructions(),
           "shouldn't have created an instructions");
  }

  // compute use counts after global value numbering
  _hir->compute_use_counts();

#ifndef PRODUCT
  if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); }
  if (PrintIR  || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); }
#endif

  _hir->verify();
}
示例#20
0
int 
main(int argc, char *argv[])
{
	char **argp = ++argv;
	char *fname;
	char *op;
	int max_pages;
	int rest_secs;
	int iteration = 0;

#define NARGS 4
	if(argc < NARGS + 1)
	{
		printf("frw <fname> <op=r/w> <max_pages> <rest_secs>\n");
		printf("op = r - read , w - random, s - fsync write\n");
		return -2;
	}  
	fname = *argp++;
	op = *argp++;
	sscanf(*argp++, "%d", &max_pages);
	sscanf(*argp++, "%d", &rest_secs);
	printf("fname = %s op=%s  max_pages = %d rest_secs = %d\n", fname, op, max_pages, rest_secs);
	
	if(op[0] == 'r')
	{
		slam_fd = open(fname, O_RDWR);
	}
	else
	{
		slam_fd = open(fname, O_WRONLY| O_TRUNC);
		if(slam_fd < 0 )
			slam_fd = creat(fname, 0666);
		
	}
	if(slam_fd < 0)
	{
		perror("open:");
		return -2;
	}

	signal(SIGINT, sigterm_hdlr);
	signal(SIGTERM, sigterm_hdlr);

	while(1)
	{
		timeit(NULL);
		if(op[0] == 'r')
		{
			read_fd(slam_fd, max_pages, op[1]=='r');
			timeit("read");
		}
		else
		{
			write_fd(slam_fd, max_pages, op[1]=='r');
			if(op[0] == 's')
			{
				fsync(slam_fd);
				timeit("write fsync");
			}
			else
			{
				timeit("write");
			}
		}
		printf("%d:iter=%d\n", getpid(), iteration++);
		
		sleep(rest_secs);
	}
	
	return 0;
	 
}