cpu

How can I do a CPU cache flush in x86 Windows?

感情迁移 提交于 2019-11-26 05:18:01
问题 I am interested in forcing a CPU cache flush in Windows (for benchmarking reasons, I want to emulate starting with no data in CPU cache), preferably a basic C implementation or Win32 call. Is there a known way to do this with a system call or even something as sneaky as doing say a large memcpy ? Intel i686 platform (P4 and up is okay as well). 回答1: Fortunately, there is more than one way to explicitly flush the caches. The instruction "wbinvd" writes back modified cache content and marks the

How to obtain the number of CPUs/cores in Linux from the command line?

非 Y 不嫁゛ 提交于 2019-11-26 04:56:53
问题 I have this script, but I do not know how to get the last element in the printout: cat /proc/cpuinfo | awk \'/^processor/{print $3}\' The last element should be the number of CPUs, minus 1. 回答1: grep -c ^processor /proc/cpuinfo will count the number of lines starting with "processor" in /proc/cpuinfo For systems with hyper-threading, you can use grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}' which should return (for example) 8 (whereas the command above would return 16 ) 回答2:

How to fast get Hardware-ID in C#?

∥☆過路亽.° 提交于 2019-11-26 04:09:31
问题 I need in my program to tie a license to a hardware ID. I tried use WMI, but it still slow. I need, for example, CPU, HDD, and motherboard info. 回答1: For more details refer to this link The following code will give you CPU ID: namespace required System.Management var mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor"); ManagementObjectCollection mbsList = mbs.Get(); string id = ""; foreach (ManagementObject mo in mbsList) { id = mo["ProcessorId"].ToString(); break; }

How can I measure CPU time and wall clock time on both Linux/Windows?

女生的网名这么多〃 提交于 2019-11-26 03:49:59
问题 I mean: how can I measure time my CPU spent on function execution and wall clock time it takes to run my function? (Im interested in Linux/Windows and both x86 and x86_64). See what I want to do (Im using C++ here but I would prefer C solution): int startcputime, endcputime, wcts, wcte; startcputime = cputime(); function(args); endcputime = cputime(); std::cout << \"it took \" << endcputime - startcputime << \" s of CPU to execute this\\n\"; wcts = wallclocktime(); function(args); wcte =

What does multicore assembly language look like?

柔情痞子 提交于 2019-11-26 03:19:02
问题 Once upon a time, to write x86 assembler, for example, you would have instructions stating \"load the EDX register with the value 5\", \"increment the EDX\" register, etc. With modern CPUs that have 4 cores (or even more), at the machine code level does it just look like there are 4 separate CPUs (i.e. are there just 4 distinct \"EDX\" registers) ? If so, when you say \"increment the EDX register\", what determines which CPU\'s EDX register is incremented? Is there a \"CPU context\" or \

How do I check CPU and Memory Usage in Java?

放肆的年华 提交于 2019-11-26 02:51:39
问题 I need to check CPU and memory usage for the server in java, anyone know how it could be done? 回答1: If you are looking specifically for memory in JVM: Runtime runtime = Runtime.getRuntime(); NumberFormat format = NumberFormat.getInstance(); StringBuilder sb = new StringBuilder(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); sb.append("free memory: " + format.format(freeMemory / 1024) + "<br/>"); sb.append(

FLOPS per cycle for sandy-bridge and haswell SSE2/AVX/AVX2

安稳与你 提交于 2019-11-26 02:42:04
问题 I\'m confused on how many flops per cycle per core can be done with Sandy-Bridge and Haswell. As I understand it with SSE it should be 4 flops per cycle per core for SSE and 8 flops per cycle per core for AVX/AVX2. This seems to be verified here, How do I achieve the theoretical maximum of 4 FLOPs per cycle? ,and here, Sandy-Bridge CPU specification. However the link below seems to indicate that Sandy-bridge can do 16 flops per cycle per core and Haswell 32 flops per cycle per core http://www

How to get overall CPU usage (e.g. 57%) on Linux [closed]

时光总嘲笑我的痴心妄想 提交于 2019-11-26 01:04:49
问题 I am wondering how you can get the system CPU usage and present it in percent using bash, for example. Sample output: 57% In case there is more than one core, it would be nice if an average percentage could be calculated. 回答1: Take a look at cat /proc/stat grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}' EDIT please read comments before copy-paste this or using this for any serious work. This was not tested nor used, it's an idea for people who do not want

How to get overall CPU usage (e.g. 57%) on Linux [closed]

雨燕双飞 提交于 2019-11-25 23:57:44
I am wondering how you can get the system CPU usage and present it in percent using bash, for example. Sample output: 57% In case there is more than one core, it would be nice if an average percentage could be calculated. vimdude Take a look at cat /proc/stat grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}' EDIT please read comments before copy-paste this or using this for any serious work. This was not tested nor used, it's an idea for people who do not want to install a utility or for something that works in any distribution. Some people think you can "apt

Micro fusion and addressing modes

北慕城南 提交于 2019-11-25 23:56:42
问题 I have found something unexpected (to me) using the Intel® Architecture Code Analyzer (IACA). The following instruction using [base+index] addressing addps xmm1, xmmword ptr [rsi+rax*1] does not micro-fuse according to IACA. However, if I use [base+offset] like this addps xmm1, xmmword ptr [rsi] IACA reports that it does fuse. Section 2-11 of the Intel optimization reference manual gives the following as an example \"of micro-fused micro-ops that can be handled by all decoders\" FADD DOUBLE