cpu

Measure CPU time on Windows using GetProcessTimes

人走茶凉 提交于 2020-01-14 02:09:26
问题 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 (

Why use 1 instead of -1?

谁都会走 提交于 2020-01-13 19:26:11
问题 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

How does Spectre attack read the cache it tricked CPU to load?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-12 13:55:13
问题 I understand the part of the paper where they trick the CPU to speculatively load the part of the victim memory into the CPU cache. Part I do not understand is how they retrieve it from cache. 回答1: They don't retrieve it directly (out of bounds read bytes are not "retired" by the CPU and cannot be seen by the attacker in the attack). A vector of attack is to do the "retrieval" a bit at a time. After the CPU cache has been prepared (flushing the cache where it has to be), and has been "taught"

Why doesn't the instruction reorder issue occur on a single CPU core?

点点圈 提交于 2020-01-12 10:35:27
问题 From this post: Two threads being timesliced on a single CPU core won't run into a reordering problem. A single core always knows about its own reordering and will properly resolve all its own memory accesses. Multiple cores however operate independently in this regard and thus won't really know about each other's reordering. Why can't the instruction reorder issue occur on a single CPU core? This article doesn't explain it. EXAMPLE : The following pictures are picked from Memory Reordering

move from pandas to dask to utilize all local cpu cores

做~自己de王妃 提交于 2020-01-12 08:50:39
问题 Recently I stumbled upon http://dask.pydata.org/en/latest/ As I have some pandas code which only runs on a single core I wonder how to make use of my other CPU cores. Would dask work well to use all (local) CPU cores? If yes how compatible is it to pandas? Could I use multiple CPUs with pandas? So far I read about releasing the GIL but that all seems rather complicated. 回答1: Would dask work well to use all (local) CPU cores? Yes. how compatible is it to pandas? Pretty compatible. Not 100%.

CPU dependent code: how to avoid function pointers?

我只是一个虾纸丫 提交于 2020-01-12 06:15:27
问题 I have performance critical code written for multiple CPUs. I detect CPU at run-time and based on that I use appropriate function for the detected CPU. So, now I have to use function pointers and call functions using these function pointers: void do_something_neon(void); void do_something_armv6(void); void (*do_something)(void); if(cpu == NEON) { do_something = do_something_neon; }else{ do_something = do_something_armv6; } //Use function pointer: do_something(); ... Not that it matters, but I

android - what is message queue native poll once in android?

人盡茶涼 提交于 2020-01-12 03:10:01
问题 I know that threads have a message queue and handlers are able to push runnables or messages to them, but when I profile my android application using Android Studio tools, there is an strange process: android.os.MessageQueue.nativePollOnce It uses the CPU more than all other processes. What is it and how can I reduce the time that the CPU spends on that? You can find the profiler result in the below. 回答1: Short answer: The nativePollOnce method is used to "wait" till the next Message becomes

Command to find information about CPUs on a UNIX machine

此生再无相见时 提交于 2020-01-11 17:13:02
问题 Do you know if there is a UNIX command that will tell me what the CPU configuration for my Sun OS UNIX machine is? I am also trying to determine the memory configuration. Is there a UNIX command that will tell me that? 回答1: There is no standard Unix command, AFAIK. I haven't used Sun OS, but on Linux, you can use this: cat /proc/cpuinfo Sorry that it is Linux, not Sun OS. There is probably something similar though for Sun OS. 回答2: The nproc command shows the number of processing units

Command to find information about CPUs on a UNIX machine

风流意气都作罢 提交于 2020-01-11 17:10:13
问题 Do you know if there is a UNIX command that will tell me what the CPU configuration for my Sun OS UNIX machine is? I am also trying to determine the memory configuration. Is there a UNIX command that will tell me that? 回答1: There is no standard Unix command, AFAIK. I haven't used Sun OS, but on Linux, you can use this: cat /proc/cpuinfo Sorry that it is Linux, not Sun OS. There is probably something similar though for Sun OS. 回答2: The nproc command shows the number of processing units

How is the BIOS ROM mapped into address space on PC?

馋奶兔 提交于 2020-01-11 15:30:12
问题 The x86 CPU begins execution at physical address 0xFFFFFFF0. There at the end of the address space the BIOS ROM is located. The first instruction the CPU executes from the ROM is far jump which causes the CS segment to be reloaded so the next instruction is executed from within the physical region 0x000F0000 - 0x000FFFFF. What causes the ROM to respond on both regions? Is there some special address decoding logic on PC? I found comment in Bochs source code that states that last 128K of BIOS