cpu

Measure CPU time on Windows using GetProcessTimes

偶尔善良 提交于 2019-12-06 11:45:54
I would like to measure CPU time of some function. I know how to use GetProcessTimes , but I have a problem implementing it with some kind of 'restarting': Normally, I would do it like this: #include "stdafx.h" #include <math.h> #include <windows.h> double cputimer() { FILETIME createTime; FILETIME exitTime; FILETIME kernelTime; FILETIME userTime; if ( GetProcessTimes( GetCurrentProcess( ), &createTime, &exitTime, &kernelTime, &userTime ) != -1 ) { SYSTEMTIME userSystemTime; if ( FileTimeToSystemTime( &userTime, &userSystemTime ) != -1 ) return (double)userSystemTime.wHour * 3600.0 + (double

How do I simulate 100% CPU usage?

十年热恋 提交于 2019-12-06 11:34:22
To simulate 100% CPU usage, I placed an infinite while loop in my code ( while (true) { } ) . This seemed to spike the CPU usage up to 30% (ordinarily it is 2% for the same program that I run without the while loop). Why does it not go above 30%? This is a dual core Intel i7 processor. The app is a simple console app running c# code on .net 4.0 private static void SimulateCPUSpike() { while(true) { } } CPU usage is a percentage of all CPU cores. If your code is only running a single thread, it cannot occupy more than one core. You need to make a separate thread for each core. ( Environment

Tensorflow same code but get different result from CPU device to GPU device

妖精的绣舞 提交于 2019-12-06 11:21:31
问题 I am trying to implement a program to test the Tensorflow performance on GPU device. Data test is MNIST data, supervised training using Multilayer perceptron(Neural networks). I followed this simple example but I change the number of performance batch gradient to 10000 for i in range(10000) : batch_xs, batch_ys = mnist.train.next_batch(100) sess.run(train_step,feed_dict={x : batch_xs, y_ : batch_ys}) if i % 500 == 0: print(i) Eventually, when I check the predict accuracy using this code

Are Intel x86_64 processors not only pipelined architecture, but also superscalar?

为君一笑 提交于 2019-12-06 11:04:10
Are Intel x86_64 processors not only pipelined architecture, but also superscalar? Pipelining - these two sequences execute in parallel (different stages of the same pipeline-unit in the same clock, for example ADD with 4 stages): stage1 -> stage2 -> stage3 -> stage4 -> nothing nothing -> stage1 -> stage2 -> stage3 -> stage4 Superscalar - these two sequences execute in parallel (two instructions can be launched to different pipeline-units in the same clock, for example ADD and MUL): ADD(stage1) -> ADD(stage2) -> ADD(stage3) MUL(stage1) -> MUL(stage2) -> MUL(stage3) Yes, contemporary Intel

Does a one cycle instruction take one cycle, even if RAM is slow?

二次信任 提交于 2019-12-06 10:38:45
问题 I am using an embedded RISC processor. There is one basic thing I have a problem figuring out. The CPU manual clearly states that the instruction ld r1, [p1] (in C: r1 = *p1) takes one cycle. Size of register r1 is 32 bits. However, the memory bus is only 16 bits wide. So how can it fetch all data in one cycle? 回答1: The clock times are assuming full width zero wait state memory. The time it takes for the core to execute that instruction is one clock cycle. There was a time when each

tensorflow build - CPU / MKL / Windows

梦想的初衷 提交于 2019-12-06 10:03:19
问题 Has anyone succeeded to build tensorflow python wheel with the following configuration: CPU (not GPU) OS: Windows 7 / server 2012 Using Intel MKL and/or mkl-dnn Python 3.6 I am struggling, for days now, trying to tweak bazel files and cmake files without success. Would like to know if someone succeeded and willing to share what he did . Thanks, Lior 回答1: Solution: 1 Installing TensorFlow from Source on windows is not generally supported. But you can try building this using bazel or tensorflow

Why each logical CPU has it's own CR3 register in case of multithreading?

北慕城南 提交于 2019-12-06 09:39:31
When we have a CPU that supports some form of multithreading, each logical CPU has it's own set of registers (as a minimum), including a CR3 register. Since we are working on the vitual address space of the same process when executing different threads and a context switch never happens (neither the TLB cache gets invalidated when switching threads of the same process), why do we need a CR3 register to point to the page table and page directory in the logical CPU? Isn't the value always the same as the value in the CR3 of the physcial CPU? Since we are working on the vitual address space of

I am trying to get an unique CPU ID

[亡魂溺海] 提交于 2019-12-06 09:22:13
问题 I am using the code below to get a unique CPU ID, i found various samples on the web using this. However. By chance I happen to own 2 Asus Laptops. One is a quad core i5 the other an heavy duty i7 octocore both are 64 bit machines.. To my big surprise they both produce the same "unique" CPU ID ???. So this code isnt working for me, are there other methods to get unique CPU ids or do i do something wrong here. What I hope to get is a number that specific for each CPU that is made string cpuID

Why use 1 instead of -1?

独自空忆成欢 提交于 2019-12-06 09:17:17
At 29min mark of http://channel9.msdn.com/Events/GoingNative/2013/Writing-Quick-Code-in-Cpp-Quickly Andrei Alexandrescu says when using constants to prefer 0 and mentions hardware knows how to handle it. I did some assembly and I know what he is talking about and about the zero flag on CPUs Then he says prefer the constant 1 rather then -1. -1 IIRC is not actually special but because it is negative the sign flag on CPUs would be set. 1 from my current understanding is simply a positive number there is no bit on the processor flag for it and no way to distinguish from 0 or other positive

how to make Java use all CPU power on a machine?

做~自己de王妃 提交于 2019-12-06 08:22:34
问题 I sometimes write code in Java, and I noticed that sometimes it uses more than 100% CPU on a multicore machine. I am now running some code on a multicore machine that has 33 CPUs (Amazon's EC2), and I want to make my Java process use all CPUs available, so that it will have very high utilization of the machine. Is that possible, or is it left up to Java to decide when to use more than 100% CPU? I do not wish to change the code to use multithreading. 回答1: Without using multiple threads or