コード例 #1
0
ファイル: 8254ctr.cpp プロジェクト: jmcarter9t/PCI-tests
void syncronize(unsigned BaseAddress)
{
   unsigned secondcount = 0;
   unsigned previouscount = 0;
   unsigned timeout = 500;

   secondcount = total_count(BaseAddress);
   do
   {
      previouscount = secondcount;
      DELAY(1);
      secondcount = total_count(BaseAddress);
   }
   while ((secondcount != previouscount) && timeout--);
}
コード例 #2
0
int main()
{
	int choice,n;
	printf("\n1. Push\n2. Pop\n3. Display\n4.Count\n5.Exit");
	while (1)
    {
	printf("\nEnter your choice ");
	scanf("%d",&choice);
	switch(choice)
	{
		case 1: printf("Enter data : ");
        		scanf("%d", &n);
            	push(n);
				break;
		case 2: pop();
				break;
		case 3: disp();
				break;
		case 4: total_count();
				break;
		case 5: exit(1);
		default : printf("Wrong entry please enter correct choice !!! ");
				break;
		}
	}
}
コード例 #3
0
void BytecodePairHistogram::print(float cutoff) {
  ResourceMark rm;
  GrowableArray<HistoEntry*>* profile = sorted_array(_counters, number_of_pairs);
  // print profile
  int tot     = total_count(profile);
  int abs_sum = 0;
  tty->cr();   //0123456789012345678901234567890123456789012345678901234567890123456789
  tty->print_cr("Histogram of %d executed bytecode pairs:", tot);
  tty->cr();
  tty->print_cr("  absolute  relative    codes    1st bytecode        2nd bytecode");
  tty->print_cr("----------------------------------------------------------------------");
  int i = profile->length();
  while (i-- > 0) {
    HistoEntry* e = profile->at(i);
    int       abs = e->count();
    float     rel = abs * 100.0F / tot;
    if (cutoff <= rel) {
      int   c1 = e->index() % number_of_codes;
      int   c2 = e->index() / number_of_codes;
      tty->print_cr("%10d   %6.3f%%    %02x %02x    %-19s %s", abs, rel, c1, c2, name_for(c1), name_for(c2));
      abs_sum += abs;
    }
  }
  tty->print_cr("----------------------------------------------------------------------");
  float rel_sum = abs_sum * 100.0F / tot;
  tty->print_cr("%10d   %6.3f%%    (cutoff = %.3f%%)", abs_sum, rel_sum, cutoff);
  tty->cr();
}
コード例 #4
0
void BytecodeHistogram::print(float cutoff) {
  ResourceMark rm;
  GrowableArray<HistoEntry*>* profile = sorted_array(_counters, Bytecodes::number_of_codes);
  // print profile
  int tot     = total_count(profile);
  int abs_sum = 0;
  tty->cr();   //0123456789012345678901234567890123456789012345678901234567890123456789
  tty->print_cr("Histogram of %d executed bytecodes:", tot);
  tty->cr();
  tty->print_cr("  absolute  relative  code    name");
  tty->print_cr("----------------------------------------------------------------------");
  int i = profile->length();
  while (i-- > 0) {
    HistoEntry* e = profile->at(i);
    int       abs = e->count();
    float     rel = abs * 100.0F / tot;
    if (cutoff <= rel) {
      tty->print_cr("%10d  %7.2f%%    %02x    %s", abs, rel, e->index(), name_for(e->index()));
      abs_sum += abs;
    }
  }
  tty->print_cr("----------------------------------------------------------------------");
  float rel_sum = abs_sum * 100.0F / tot;
  tty->print_cr("%10d  %7.2f%%    (cutoff = %.2f%%)", abs_sum, rel_sum, cutoff);
  tty->cr();
}
コード例 #5
0
ファイル: nl_base.cpp プロジェクト: bmunger/mame
void netlist_t::print_stats() const
{
	if (nperftime_t::enabled)
	{
		std::vector<size_t> index;
		for (size_t i=0; i<m_devices.size(); i++)
			index.push_back(i);

		std::sort(index.begin(), index.end(),
				[&](size_t i1, size_t i2) { return m_devices[i1]->m_stat_total_time.total() < m_devices[i2]->m_stat_total_time.total(); });

		nperftime_t::type total_time(0);
		uint_least64_t total_count(0);

		for (auto & j : index)
		{
			auto entry = m_devices[j].get();
			log().verbose("Device {1:20} : {2:12} {3:12} {4:15} {5:12}", entry->name(),
					entry->m_stat_call_count(), entry->m_stat_total_time.count(),
					entry->m_stat_total_time.total(), entry->m_stat_inc_active());
			total_time += entry->m_stat_total_time.total();
			total_count += entry->m_stat_total_time.count();
		}

		nperftime_t overhead;
		nperftime_t test;
		overhead.start();
		for (int j=0; j<100000;j++)
		{
			test.start();
			test.stop();
		}
		overhead.stop();

		nperftime_t::type total_overhead = overhead()
				* static_cast<nperftime_t::type>(total_count)
				/ static_cast<nperftime_t::type>(200000);

		log().verbose("Queue Pushes   {1:15}", queue().m_prof_call());
		log().verbose("Queue Moves    {1:15}", queue().m_prof_sortmove());

		log().verbose("Total loop     {1:15}", m_stat_mainloop());
		/* Only one serialization should be counted in total time */
		/* But two are contained in m_stat_mainloop */
		log().verbose("Total devices  {1:15}", total_time);
		log().verbose("");
		log().verbose("Take the next lines with a grain of salt. They depend on the measurement implementation.");
		log().verbose("Total overhead {1:15}", total_overhead);
		nperftime_t::type overhead_per_pop = (m_stat_mainloop()-2*total_overhead - (total_time - total_overhead))
				/ static_cast<nperftime_t::type>(queue().m_prof_call());
		log().verbose("Overhead per pop  {1:11}", overhead_per_pop );
		log().verbose("");
		for (auto &entry : m_devices)
		{
			if (entry->m_stat_inc_active() > 3 * entry->m_stat_total_time.count())
				log().verbose("HINT({}, NO_DEACTIVATE)", entry->name());
		}
	}
}
コード例 #6
0
void BytecodeHistogram::print(float cutoff) {
  jlong total        = total_count();
  jlong absolute_sum = 0;

  SortedHistogramEntry* sorted_histogram = 
    NEW_GLOBAL_HEAP_ARRAY(SortedHistogramEntry, Bytecodes::number_of_java_codes, "BytecodeHistogram");
  for (int i = 0; i < Bytecodes::number_of_java_codes; i++) {
    sorted_histogram[i].count = counter_at(i);
    sorted_histogram[i].code = (Bytecodes::Code) i;
  }
  jvm_qsort(sorted_histogram, Bytecodes::number_of_java_codes, sizeof(SortedHistogramEntry), compare_entries);

  tty->cr();
  tty->print_cr("Histogram of executed bytecodes:");
  tty->cr();
  tty->print_cr("      absolute  relative    code    name");
  tty->print_cr("----------------------------------------------------------------------");
  if (total > 0) {
    for (int i = 0; i < Bytecodes::number_of_java_codes; i++) {
      Bytecodes::Code code = sorted_histogram[i].code;
      jlong count          = sorted_histogram[i].count;
      if (Bytecodes::is_defined(code)) {
        jlong absolute = count;
        float relative = jvm_fdiv(jvm_fmul(jvm_l2f(absolute), 100.0F),
                                  jvm_l2f(total));
        if (!jvm_fcmpg(cutoff, relative)) {
          tty->print_cr(FLL "  %7.2f%%    0x%02x    %s", 
                        absolute, 
                        jvm_f2d(relative), 
                        code, 
                        Bytecodes::name(Bytecodes::cast(code)));
          absolute_sum += absolute;
        }
      }
    }
  }
  tty->print_cr("----------------------------------------------------------------------");
  if (total > 0) {  
    float relative_sum = jvm_fdiv(jvm_fmul(jvm_l2f(absolute_sum), 100.0F),
                                  jvm_l2f(total));
    tty->print_cr(FLL " %7.2f%%    cutoff = %.2f%%", 
                  absolute_sum, 
                  jvm_f2d(relative_sum), 
                  jvm_f2d(cutoff));
    tty->print_cr(FLL " %7.2f%%    total", total, 100.0, 0.0);
  }
  tty->cr();

  FREE_GLOBAL_HEAP_ARRAY(sorted_histogram, "BytecodeHistogram");
}
コード例 #7
0
void gooda::convert_to_afdo(const gooda::gooda_report& report, gooda::afdo_data& data, boost::program_options::variables_map& vm){
    bool lbr;
    if(vm.count("auto")){
        auto total_count_lbr = total_count(report, BB_EXEC);
        lbr = total_count_lbr > 0;
    } else {
        lbr = vm.count("lbr");
    }

    //Choose the correct counter
    std::string counter_name = lbr ? BB_EXEC : UNHALTED_CORE_CYCLES;

    //Verify that the file has the correct column
    if(!vm.count("auto") && total_count(report, counter_name) == 0){
        throw gooda::gooda_exception("The file is not valid for the current mode");
    }

    //Empty each cache
    inlining_cache.clear();
    discriminator_cache.clear();

    auto filter = get_process_filter(report, vm, counter_name);
    log::emit<log::Debug>() << "Filter by \"" << filter << "\"" << log::endl;

    for(std::size_t i = 0; i < report.functions(); ++i){
        auto& line = report.hotspot_function(i);

        //Only if the function passes the filters
        if(filter.empty() || line.get_string(report.get_hotspot_file().column(PROCESS)) == filter){
            auto string_cycles = line.get_string(report.get_hotspot_file().column(counter_name));

            //Some functions are filled empty by Gooda for some reason
            //In some case, it means 0, in that case, it is not a problem to ignore it either, cause not really hotspot
            if(string_cycles.empty()){
                continue;
            }

            gooda::afdo_function function;
            function.i = i;
            function.executable_file = get_application_file(report, i);
            function.name = line.get_string(report.get_hotspot_file().column(FUNCTION_NAME));

            if(lbr){
                function.total_count = line.get_counter(report.get_hotspot_file().column(SW_INST_RETIRED));
            } else {
                auto count =
                        report.get_hotspot_file().multiplex_line().get_double(report.get_hotspot_file().column(UNHALTED_CORE_CYCLES))
                      * line.get_counter(report.get_hotspot_file().column(UNHALTED_CORE_CYCLES));

                function.total_count = static_cast<gcov_type>(count);
            }

            //We need the asm file to continue

            if(!report.has_asm_file(function.i)){
                continue;
            }

            //Check that the function file is correctly set

            auto& file = report.asm_file(function.i);

            bool invalid = false;

            for(std::size_t j = 0; j < file.lines(); ++j){
                auto& line = file.line(j);

                //Basic Block have no file
                if(boost::starts_with(line.get_string(file.column(DISASSEMBLY)), "Basic Block")){
                    continue;
                }

                //Line without addresses have special meaning
                if(line.get_string(file.column(ADDRESS)).empty()){
                    continue;
                }

                //Gooda does not always found the source file of a function
                //In that case, declare the function as invalid and return quickly
                auto princ_file = line.get_string(file.column(PRINC_FILE));
                if(princ_file == "null"){
                    log::emit<log::Warning>() << function.name << " is invalid (null file)" << log::endl;

                    invalid = true;
                    break;
                }

                if(princ_file.empty()){
                    log::emit<log::Warning>() << function.name << " is invalid (empty file)" << log::endl;

                    invalid = true;
                    break;
                }
            }

            if(invalid){
                continue;
            }

            //Add the function

            data.functions.push_back(std::move(function));
        }
    }

    //Update function names (replace unmangled with mangled names)
    update_function_names(report, data, vm);

    //Fill the inlining cache (gets inlined function names)
    fill_inlining_cache(report, data, vm);

    //Fill the discriminator cache (gets the discriminators of each lines)
    fill_discriminator_cache(report, data, vm);

    //Generate the inline stacks

    for(auto& function : data.functions){
        //Collect function.file and function.entry_count
        auto bbs = collect_basic_blocks(report, function, lbr);

        if(lbr){
            lbr_annotate(report, function, bbs);
        } else {
            ca_annotate(report, function, bbs);
        }
    }

    //Prune uncounted functions
    prune_uncounted_functions(data);

    //Strip current directory from paths
    strip_paths(data);

    //Fill the file name table with the strings from the AFDO profile
    fill_file_name_table(data);

    //Compute the working set
    compute_working_set(report, data, vm, lbr);

    //Set the sizes of the different sections
    compute_lengths(data);

    //Note: No need to fill the modules because it is not used by GCC
    //It will be automatically written empty by the AFDO generator
}
コード例 #8
0
ファイル: 8254ctr.cpp プロジェクト: jmcarter9t/PCI-tests
double pulse_measure(unsigned BaseAddress)
{
   #define TIMEOUTVAL  150000
   unsigned firstcount = 0;
   unsigned secondcount = 0;
   unsigned previouscount = 0;
   unsigned time = 0;
   unsigned long timeout;

   unsigned one, two;

   OUTPORTB(BaseAddress + 3, 0xB4);           // 1011 0100 ctr2 mode2
   OUTPORTB(BaseAddress + 2, 0xFF);           // write 65535 to counters
   OUTPORTB(BaseAddress + 2, 0xFF);

   OUTPORTB(BaseAddress + 3, 0x72);           // 0111 0010 ctr1 mode2
   DELAY(1);
   OUTPORTB(BaseAddress + 3, 0x70);           // 0111 0000 ctr1 mode2
   DELAY(1);
   OUTPORTB(BaseAddress + 3, 0x74);           // 0111 0100 ctr1 mode2
   OUTPORTB(BaseAddress + 1, 0xFF);           // write 65535 to counters
   OUTPORTB(BaseAddress + 1, 0xFF);

   firstcount = total_count(BaseAddress); // read the counter
   timeout = 0;
   do
   {
      previouscount = firstcount;
      firstcount = total_count(BaseAddress);
      timeout++;
   }
   while ((firstcount != previouscount) && (timeout < TIMEOUTVAL));
					  // check to see if the counts are changing
   one = count2(BaseAddress);
   if (timeout < TIMEOUTVAL)
      timeout = 0;
   do
   {
      secondcount = total_count(BaseAddress);
      timeout++;
   }
   while ((firstcount == secondcount) && (timeout < TIMEOUTVAL));
					  // check to see if counts are stable
   if (timeout < TIMEOUTVAL)
      timeout = 0;
   do
   {
      previouscount = secondcount;
      DELAY(1);
      secondcount = total_count(BaseAddress);
      timeout++;
   }
   while ((secondcount != previouscount) && (timeout < TIMEOUTVAL));
					  // check to see if counts are changing
   two = count2(BaseAddress);
   if (timeout < TIMEOUTVAL)
   {
      time = firstcount - secondcount;
      return(time);                       // return the counts for the pulse
   }
   else
      return 0;
}
コード例 #9
0
ファイル: nl_base.cpp プロジェクト: rfka01/mame
void netlist_t::print_stats() const
{
	if (nperftime_t<NL_KEEP_STATISTICS>::enabled)
	{
		std::vector<size_t> index;
		for (size_t i=0; i < m_state->m_devices.size(); i++)
			index.push_back(i);

		std::sort(index.begin(), index.end(),
				[&](size_t i1, size_t i2) { return m_state->m_devices[i1].second->m_stat_total_time.total() < m_state->m_devices[i2].second->m_stat_total_time.total(); });

		nperftime_t<NL_KEEP_STATISTICS>::type total_time(0);
		nperftime_t<NL_KEEP_STATISTICS>::ctype total_count(0);

		for (auto & j : index)
		{
			auto entry = m_state->m_devices[j].second.get();
			log().verbose("Device {1:20} : {2:12} {3:12} {4:15} {5:12}", entry->name(),
					entry->m_stat_call_count(), entry->m_stat_total_time.count(),
					entry->m_stat_total_time.total(), entry->m_stat_inc_active());
			total_time += entry->m_stat_total_time.total();
			total_count += entry->m_stat_total_time.count();
		}

		log().verbose("Total calls : {1:12} {2:12} {3:12}", total_count,
			total_time, total_time / static_cast<decltype(total_time)>(total_count));

		nperftime_t<NL_KEEP_STATISTICS> overhead;
		nperftime_t<NL_KEEP_STATISTICS> test;
		{
			auto overhead_guard(overhead.guard());
			for (int j=0; j<100000;j++)
			{
				auto test_guard(test.guard());
			}
		}

		nperftime_t<NL_KEEP_STATISTICS>::type total_overhead = overhead()
				* static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(total_count)
				/ static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(200000);

		log().verbose("Queue Pushes   {1:15}", m_queue.m_prof_call());
		log().verbose("Queue Moves    {1:15}", m_queue.m_prof_sortmove());
		log().verbose("Queue Removes  {1:15}", m_queue.m_prof_remove());
		log().verbose("Queue Retimes  {1:15}", m_queue.m_prof_retime());

		log().verbose("Total loop     {1:15}", m_stat_mainloop());
		/* Only one serialization should be counted in total time */
		/* But two are contained in m_stat_mainloop */
		log().verbose("Total devices  {1:15}", total_time);
		log().verbose("");
		log().verbose("Take the next lines with a grain of salt. They depend on the measurement implementation.");
		log().verbose("Total overhead {1:15}", total_overhead);
		nperftime_t<NL_KEEP_STATISTICS>::type overhead_per_pop = (m_stat_mainloop()-2*total_overhead - (total_time - total_overhead))
				/ static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(m_queue.m_prof_call());
		log().verbose("Overhead per pop  {1:11}", overhead_per_pop );
		log().verbose("");

		auto trigger = total_count * 200 / 1000000; // 200 ppm
		for (auto &entry : m_state->m_devices)
		{
			auto ep = entry.second.get();
			// Factor of 3 offers best performace increase
			if (ep->m_stat_inc_active() > 3 * ep->m_stat_total_time.count()
				&& ep->m_stat_inc_active() > trigger)
				log().verbose("HINT({}, NO_DEACTIVATE) // {} {} {}", ep->name(),
					static_cast<double>(ep->m_stat_inc_active()) / static_cast<double>(ep->m_stat_total_time.count()),
					ep->m_stat_inc_active(), ep->m_stat_total_time.count());
		}
	}
}