当前位置: 首页>>代码示例>>C++>>正文


C++ Cpu类代码示例

本文整理汇总了C++中Cpu的典型用法代码示例。如果您正苦于以下问题:C++ Cpu类的具体用法?C++ Cpu怎么用?C++ Cpu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cpu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    QApplication a(argc, argv);

    qDebug() << "Hello, world";

    MainWindow window;
    window.show();

    Cpu cpu;
    CpuRam cpuRam;

    CpuBus cpuBus(&cpuRam);
    cpu.setMediator(&cpuBus);

    CartridgeMapper* cartridge = loadCartridgeMapperFromFile("testRoms/instr_misc/rom_singles/03-dummy_reads.nes");
    cpuBus.setCartridge(cartridge);

    while (true) {
        cpu.tick();
    }

    std::cout << "Done!" << std::endl;

    return a.exec();
}
开发者ID:Levoila,项目名称:CrNES,代码行数:26,代码来源:main.cpp

示例2: while

void *RunThread(void *cpu_arg)
{
    Cpu *cpu = (Cpu *)cpu_arg;
    while(!cpu->GetStatus())
    {
        cpu->Exec(1000000);
    }
    return NULL;
}
开发者ID:ecular,项目名称:scratchemulator,代码行数:9,代码来源:main.cpp

示例3: TEST

TEST(Cpu, SBC_NoUnderflow) {
    Cpu cpu;
    ASSERT_EQ(0, cpu.P.read());
    cpu.i_sec();  // set carry instruction
    cpu.A.write(0x01);
    cpu.i_sbc(0x01);
    ASSERT_EQ(0, cpu.A.read());
    ASSERT_TRUE(cpu.P.has_carry());
    ASSERT_TRUE(cpu.P.has_zero());
    ASSERT_FALSE(cpu.P.has_negative());
    ASSERT_FALSE(cpu.P.has_overflow());
}
开发者ID:pglass,项目名称:mos6502,代码行数:12,代码来源:test_cpu.cpp

示例4: main

int main(int argc, char** argv){
    if(argc < 2){
        cerr << "Usage: " << argv[0] << " CpuId" << endl;
    }

    unsigned int cpuId = atoi(argv[1]);

    Mammut mammut;

    /*******************************************/
    /*       Idle states power consumption     */
    /*******************************************/
    VirtualCore* vc = mammut.getInstanceTopology()->getCpus().at(cpuId)->getVirtualCore();
    Cpu* cpu = mammut.getInstanceTopology()->getCpu(vc->getCpuId());
    vector<VirtualCoreIdleLevel*> idleLevels = vc->getIdleLevels();
    Domain* fDomain = mammut.getInstanceCpuFreq()->getDomain(vc);
    if(idleLevels.size() == 0){
        cout << "No idle levels supported by CPU " << cpu->getCpuId() << "." << endl;
    }else{
        for(int32_t i = idleLevels.size() - 1; i >= 0 ; i--){
            int fd = open("/dev/cpu_dma_latency", O_RDWR);
            int32_t lat = idleLevels.at(i)->getExitLatency();
            write(fd, &lat, sizeof(lat));

            /** We compute the base power consumption at each frequency step. **/
            vector<Frequency> frequencies;
            frequencies = fDomain->getAvailableFrequencies();

            for(size_t j = 0; j < frequencies.size(); j++){
                fDomain->setGovernor(GOVERNOR_USERSPACE);
                fDomain->setFrequencyUserspace(frequencies.at(j));
                CounterCpus* counter = dynamic_cast<CounterCpus*>(mammut.getInstanceEnergy()->getCounter(COUNTER_CPUS));
                counter->reset();
                sleep(levelTime);

                mammut::topology::CpuId cpuId = cpu->getCpuId();
                cout << idleLevels.at(i)->getName() << " ";
                cout << frequencies.at(j) << " ";
                cout << counter->getJoulesCpu(cpuId)/levelTime << " ";
                cout << counter->getJoulesCores(cpuId)/levelTime << " ";
                cout << counter->getJoulesDram(cpuId)/levelTime << " ";
                cout << counter->getJoulesGraphic(cpuId)/levelTime << " ";
                cout << fDomain->getCurrentVoltage() << " ";
                cout << endl;
            }

            close(fd);
        }
    }
}
开发者ID:DanieleDeSensi,项目名称:mammut,代码行数:50,代码来源:idleLevelsPower.cpp

示例5: DistributeError

void PanicModule::DistributeError() {
  if (!IsInitialized()) return;
  Lapic & lapic = LapicModule::GetGlobal().GetLapic();
  Cpu * current = &Cpu::GetCurrent();
  DomainList & domains = DomainList::GetGlobal();
  for (int i = 0; i < domains.GetCount(); i++) {
    Domain & domain = domains[i];
    for (int j = 0; j < domain.GetThreadCount(); j++) {
      Cpu * cpu = &domain.GetCpu(j);
      if (cpu == current) continue;
      lapic.SendIpi(cpu->GetApicId(), IntVectors::Panic);
    }
  }
}
开发者ID:unixpickle,项目名称:anarch,代码行数:14,代码来源:panic.cpp

示例6: xbt_assert

double VMHL13Model::next_occuring_event(double now)
{
  /* TODO: update action's cost with the total cost of processes on the VM. */

  /* 1. Now we know how many resource should be assigned to each virtual
   * machine. We update constraints of the virtual machine layer.
   *
   * If we have two virtual machine (VM1 and VM2) on a physical machine (PM1).
   *     X1 + X2 = C       (Equation 1)
   * where
   *    the resource share of VM1: X1
   *    the resource share of VM2: X2
   *    the capacity of PM1: C
   *
   * Then, if we have two process (P1 and P2) on VM1.
   *     X1_1 + X1_2 = X1  (Equation 2)
   * where
   *    the resource share of P1: X1_1
   *    the resource share of P2: X1_2
   *    the capacity of VM1: X1
   *
   * Equation 1 was solved in the physical machine layer.
   * Equation 2 is solved in the virtual machine layer (here).
   * X1 must be passed to the virtual machine laye as a constraint value.
   **/

  /* iterate for all virtual machines */
  for (VMModel::vm_list_t::iterator iter = VMModel::ws_vms.begin(); iter !=  VMModel::ws_vms.end(); ++iter) {
    VirtualMachine *ws_vm = &*iter;
    Cpu *cpu = ws_vm->p_cpu;
    xbt_assert(cpu, "cpu-less host");

    double solved_value = ws_vm->action_->getVariable()->value;
    XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->getName(), ws_vm->getPm()->name().c_str());

    // TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
    // cpu_cas01->constraint->bound = solved_value;
    xbt_assert(cpu->getModel() == surf_cpu_model_vm);
    lmm_system_t vcpu_system = cpu->getModel()->getMaxminSystem();
    lmm_update_constraint_bound(vcpu_system, cpu->getConstraint(), virt_overhead * solved_value);
  }

  /* 2. Calculate resource share at the virtual machine layer. */
  adjustWeightOfDummyCpuActions();

  /* 3. Ready. Get the next occuring event */
  return surf_cpu_model_vm->next_occuring_event(now);
}
开发者ID:R7R8,项目名称:simgrid,代码行数:48,代码来源:vm_hl13.cpp

示例7: while

/*********
 * Model *
 *********/
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
  CpuAction *action;
  while ((xbt_heap_size(getActionHeap()) > 0)
         && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
    action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
    XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
    if (TRACE_is_enabled()) {
      Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
      TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      action->getLastUpdate(),
                                      now - action->getLastUpdate());
    }

    action->finish();
    XBT_CDEBUG(surf_kernel, "Action %p finished", action);

    /* set the remains to 0 due to precision problems when updating the remaining amount */
    action->setRemains(0);
    action->setState(SURF_ACTION_DONE);
    action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
  }
  if (TRACE_is_enabled()) {
    //defining the last timestamp that we can safely dump to trace file
    //without losing the event ascending order (considering all CPU's)
    double smaller = -1;
    ActionList *actionSet = getRunningActionSet();
    for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
       ; it != itend ; ++it) {
      action = static_cast<CpuAction*>(&*it);
        if (smaller < 0) {
          smaller = action->getLastUpdate();
          continue;
        }
        if (action->getLastUpdate() < smaller) {
          smaller = action->getLastUpdate();
        }
    }
    if (smaller > 0) {
      TRACE_last_timestamp_to_dump = smaller;
    }
  }
  return;
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:48,代码来源:cpu_interface.cpp

示例8: putCPUinfo

void putCPUinfo()
{
	using namespace Xbyak::util;
	Cpu cpu;
	printf("vendor %s\n", cpu.has(Cpu::tINTEL) ? "intel" : "amd");
	static const struct {
		Cpu::Type type;
		const char *str;
	} tbl[] = {
		{ Cpu::tMMX, "mmx" },
		{ Cpu::tMMX2, "mmx2" },
		{ Cpu::tCMOV, "cmov" },
		{ Cpu::tSSE, "sse" },
		{ Cpu::tSSE2, "sse2" },
		{ Cpu::tSSE3, "sse3" },
		{ Cpu::tSSSE3, "ssse3" },
		{ Cpu::tSSE41, "sse41" },
		{ Cpu::tSSE42, "sse42" },
		{ Cpu::tPOPCNT, "popcnt" },
		{ Cpu::t3DN, "3dn" },
		{ Cpu::tE3DN, "e3dn" },
		{ Cpu::tSSE4a, "sse4a" },
		{ Cpu::tSSE5, "sse5" },
		{ Cpu::tAESNI, "aesni" },
		{ Cpu::tRDTSCP, "rdtscp" },
		{ Cpu::tOSXSAVE, "osxsave(xgetvb)" },
		{ Cpu::tPCLMULQDQ, "pclmulqdq" },
		{ Cpu::tAVX, "avx" },
		{ Cpu::tFMA, "fma" },
	};
	for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
		if (cpu.has(tbl[i].type)) printf(" %s", tbl[i].str);
	}
	printf("\n");
	if (cpu.has(Cpu::tPOPCNT)) {
		const int n = 0x12345678; // bitcount = 13
		const int ok = 13;
		int r = ((int (*)())(PopCountTest(n).getCode()))();
		if (r == ok) {
			puts("popcnt ok");
		} else {
			printf("popcnt ng %d %d\n", r, ok);
		}
	}
}
开发者ID:stfn80,项目名称:xbyak,代码行数:45,代码来源:test_util.cpp

示例9: main

int main(int argc, char* argv[])
{
	std::string file = "input.txt";

	//int program[] = {
	//	PSH, 5,
	//	PSH, 6,
	//	ADD,
	//	POP,
	//	SET, A, 2,
	//	HLT
	//};

	//std::vector<int> p;

	Cpu c;
	c.execute(&parse(file)[0]);
}
开发者ID:Jillbore,项目名称:VM_C,代码行数:18,代码来源:main.cpp

示例10: cmd_exe

void cmd_exe(char const line[512], Cpu& cpu){
	uInt count = 1;

	if (sscanf(line, ". %u", &count) == EOF && sscanf(line, ".") == EOF){
		COMMAND_SYNTAX();
		return;
	}

	cpu.execute(count);
};
开发者ID:tlevi,项目名称:mipsim,代码行数:10,代码来源:main.cpp

示例11: api_cpu_handler

void api_cpu_handler(const shared_ptr<restbed::Session> session)
{
  Cpu *cpu;
  JSONObject obj;
  JSONValue *output;
  wstring cpuModel;
  double cpuCount;
  double cpuFrequency;

  cpu = Cpu::getInstance();
  cpuModel = s2ws(cpu->getCpuInfo());
  cpuCount = cpu->getCoresCount();
  cpuFrequency = cpu->getFreq();
  obj[L"model"] = new JSONValue(cpuModel);
  obj[L"count"] = new JSONValue(cpuCount);
  obj[L"frequency"] = new JSONValue(cpuFrequency);
  output = new JSONValue(obj);
  session->close(restbed::OK, ws2s(output->Stringify()), { { "Content-Type", "application/json" } });
}
开发者ID:niou128,项目名称:my_config,代码行数:19,代码来源:main.cpp

示例12: printCpuValues

/*
 * Print out the current CPU settings as configured either from
 * the cpufreq sysfs files or the intel_pstate sysfs files.
 */
void printCpuValues(const Cpu &cpu)
{
	if (Log::isOutputCapable()) {
		printVersion();
		std::ostringstream oss;
		oss << Color::boldWhite()
			<< "    pstate::" << Color::boldGreen()
			<< "CPU_DRIVER     -> "
			<< Color::boldCyan() << cpu.getDriver()
			<< std::endl;
		oss << Color::boldWhite()
			<< "    pstate::" << Color::boldGreen()
			<< "CPU_GOVERNOR   -> "
			<< Color::boldCyan() << cpu.getGovernor()
			<< std::endl;
		const int turbo = cpu.getTurboBoost();
		oss << Color::boldWhite()
			<< "    pstate::" << Color::boldGreen()
			<< (cpu.hasPstate()
				? "NO_TURBO       -> "
				: "TURBO_BOOST    -> ")
			<< Color::boldCyan() << turbo << " : "
			<< (cpu.hasPstate()
				? (turbo == 1
					? "OFF"
					: "ON")
				: (turbo == 1
					? "ON"
					: "OFF"))
			<< std::endl;
		oss << Color::boldWhite()
			<< "    pstate::" << Color::boldGreen()
			<< "CPU_MIN        -> "
			<< Color::boldCyan() << cpu.getMinValue() << "% : "
			<< static_cast<int>(cpu.getScalingMinFrequency())
			<< "KHz" << std::endl;
		oss << Color::boldWhite()
			<< "    pstate::" << Color::boldGreen()
			<< "CPU_MAX        -> "
			<< Color::boldCyan() << cpu.getMaxValue() << "% : "
			<< static_cast<int>(cpu.getScalingMaxFrequency())
			<< "KHz" << std::endl;
		oss << Color::reset();
		std::cout << oss.str();
	}
}
开发者ID:Papapashu,项目名称:pstate-frequency,代码行数:50,代码来源:psfreq_output.cpp

示例13: getRunningActionSet

void CpuModel::updateActionsStateFull(double now, double delta)
{
  CpuAction *action = NULL;
  ActionList *running_actions = getRunningActionSet();

  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
     ; it != itend ; it=itNext) {
	++itNext;
    action = static_cast<CpuAction*>(&*it);
    if (TRACE_is_enabled()) {
      Cpu *x = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) );

      TRACE_surf_host_set_utilization(x->getName(),
                                      action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      now - delta,
                                      delta);
      TRACE_last_timestamp_to_dump = now - delta;
    }

    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);


    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);


    if ((action->getRemainsNoUpdate() <= 0) &&
        (lmm_get_variable_weight(action->getVariable()) > 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
               (action->getMaxDuration() <= 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    }
  }

  return;
}
开发者ID:tempbottle,项目名称:simgrid,代码行数:40,代码来源:cpu_interface.cpp

示例14: run

void run() {
	if (executionCounter > 0) {
		printer.print("            \n");
	}
	savedRam = ram.state;
	cpu.exec();
	// if 'esc' was pressed then it doesn't wait for keypress at the end
	if (executionCanceled) {
		executionCanceled = false;
	} else {
		getc(stdin);
	}
	ram = Ram();
	ram.state = savedRam;
	cpu = Cpu();
	redrawScreen();
	executionCounter++;
}
开发者ID:ketralnis,项目名称:comp-cpp,代码行数:18,代码来源:comp.cpp

示例15: printRealtimeFrequency

/*
 * Grab the current CPU frequencies from /proc/cpuinfo
 * and pretty print them to the stdout
 */
void printRealtimeFrequency(const Cpu &cpu)
{
	if (Log::isOutputCapable()) {
		printVersion();
		const std::vector<std::string> frequencies =
			cpu.getRealtimeFrequencies();
		if (!frequencies.empty()) {
			std::ostringstream oss;
			const unsigned int size = frequencies.size();
			for (unsigned int i = 0; i < size; ++i) {
				std::string freq = frequencies[i];
				oss << Color::boldWhite()
				    << "    pstate::" << Color::boldGreen()
				    << "CPU[" << Color::boldMagenta()
				    << i << Color::boldGreen() << "]  -> "
				    << Color::boldCyan()
				    << freq.substr(0, freq.size() - 1)
				    << "MHz" << Color::reset() << std::endl;
			}
			std::cout << oss.str();
		}
	}
}
开发者ID:Papapashu,项目名称:pstate-frequency,代码行数:27,代码来源:psfreq_output.cpp


注:本文中的Cpu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。