cpu

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

梦想与她 提交于 2019-11-26 16:50:51
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. unbeli cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l or simply grep -c ^processor /proc/cpuinfo which 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 ) uckelman Processing the contents of

How can I control my PC's fan speed using C++ in Vista?

人走茶凉 提交于 2019-11-26 16:47:38
问题 How can I use C++ to control CPU fan speed in Windows Vista Ultimate? I would like to use ACPI. 回答1: ACPI: You need to learn about and use the WMI - Windows system management interface. Here are a few resources that will give you clues on where to start: SetSpeed Method of the CIM_Fan Class WMI C++ Application Examples Example: Calling a Provider Method Note that some motherboards don't support fan speed changes, and even those that do may not expose this to the WMI. In the best case you may

VisualVM and Self Time

ぐ巨炮叔叔 提交于 2019-11-26 15:57:08
问题 I've been searching all over for a consistent and clear explanation of what 'self time' actually refers to in the VisualVM context and how does it differ to 'self time (cpu)'. Also does 'self time [%]' refer to self time or self time cpu. There doesn't appear to be much documentation on this or at least I haven't found it. So any thoughts/input will be appreciated. 回答1: Self Time is a wall-clock time spent in the method itself ( includes time waiting/sleeping ). Self Time (CPU) is a time

How to fast get Hardware-ID in C#?

一个人想着一个人 提交于 2019-11-26 15:05: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. HotTester 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; } For Hard disk ID and motherboard id details refer this-link To speed up this procedure, make sure

how to set CPU affinity of a particular pthread?

心已入冬 提交于 2019-11-26 14:57:49
I'd like to specify the cpu-affinity of a particular pthread. All the references I've found so far deal with setting the cpu-affinity of a process (pid_t) not a thread (pthread_t). I tried some experiments passing pthread_t's around and as expected they fail. Am I trying to do something impossible? If not, can you send a pointer please? Thanks a million. This is a wrapper I've made to make my life easier. Its effect is that the calling thread gets "stuck" to the core with id core_id : // core_id = 0, 1, ... n-1, where n is the system's number of cores int stick_this_thread_to_core(int core_id)

How can I get CPU load per core in C#?

徘徊边缘 提交于 2019-11-26 14:47:35
问题 How can I get CPU Load per core (quadcore cpu), in C#? Thanks :) 回答1: You can either use WMI or the System.Diagnostics namespace. From there you can grab any of the performance counters you wish (however it takes a second (1-1.5s) to initialize those - reading values is ok, only initialization is slow) Code can look then like this: using System.Diagnostics; public static Double Calculate(CounterSample oldSample, CounterSample newSample) { double difference = newSample.RawValue - oldSample

Assembly CPU frequency measuring algorithm

主宰稳场 提交于 2019-11-26 14:15:29
问题 What are the common algorithms being used to measure the processor frequency? 回答1: Intel CPUs after Core Duo support two Model-Specific registers called IA32_MPERF and IA32_APERF. MPERF counts at the maximum frequency the CPU supports, while APERF counts at the actual current frequency. The actual frequency is given by: You can read them with this flow ; read MPERF mov ecx, 0xe7 rdmsr mov mperf_var_lo, eax mov mperf_var_hi, edx ; read APERF mov ecx, 0xe8 rdmsr mov aperf_var_lo, eax mov aperf

Tensorflow: executing an ops with a specific core of a CPU

让人想犯罪 __ 提交于 2019-11-26 13:22:11
问题 It is currently possible to specify which CPU or GPU to use with the tf.device(...) function for specific ops, but is there anyway where you can specify a core of a CPU? 回答1: There's no API for pinning ops to a particular core at present, though this would make a good feature request. You could approximate this functionality by creating multiple CPU devices, each with a single-threaded threadpool, but this isn't guaranteed to maintain the locality of a core-pinning solution: with tf.device("

Detecting the number of processors

╄→尐↘猪︶ㄣ 提交于 2019-11-26 12:46:40
问题 How do you detect the number of physical processors/cores in .net? 回答1: System.Environment.ProcessorCount returns the number of logical processors http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx For physical processor count you'd probably need to use WMI - the following metadata is supported in XP/Win2k3 upwards (Functionality enabled in SP's prior to Vista/Win2k8). Win32_ComputerSystem.NumberOfProcessors returns physical count Win32_ComputerSystem

How to do I check CPU and Memory Usage in Java?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 12:08:31
I need to check CPU and memory usage for the server in java, anyone know how it could be done? Jeremy If you looking specifically for in JVM memory: 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("allocated memory: " + format.format(allocatedMemory / 1024) + "<br/>"); sb.append("max memory: " + format.format