multicore

Why does a single threaded process execute on several processors/cores?

隐身守侯 提交于 2019-11-27 11:45:41
问题 Say I run a simple single-threaded process like the one below: public class SirCountALot { public static void main(String[] args) { int count = 0; while (true) { count++; } } } (This is Java because that's what I'm familiar with, but I suspect it doesn't really matter) I have an i7 processor (4 cores, or 8 counting hyperthreading), and I'm running Windows 7 64-bit so I fired up Sysinternals Process Explorer to look at the CPU usage, and as expected I see it is using around 20% of all

Python Global Interpreter Lock (GIL) workaround on multi-core systems using taskset on Linux?

喜你入骨 提交于 2019-11-27 11:23:16
So I just finished watching this talk on the Python Global Interpreter Lock (GIL) http://blip.tv/file/2232410 . The gist of it is that the GIL is a pretty good design for single core systems (Python essentially leaves the thread handling/scheduling up to the operating system). But that this can seriously backfire on multi-core systems and you end up with IO intensive threads being heavily blocked by CPU intensive threads, the expense of context switching, the ctrl-C problem[*] and so on. So since the GIL limits us to basically executing a Python program on one CPU my thought is why not accept

How do you make good use of multicore CPUs in your PHP/MySQL applications?

岁酱吖の 提交于 2019-11-27 10:48:31
I maintain a custom built CMS-like application. Whenever a document is submitted, several tasks are performed that can be roughly grouped into the following categories: MySQL queries. HTML content parsing. Search index updating. Category 1 includes updates to various MySQL tables relating to a document's content. Category 2 includes parsing of HTML content stored in MySQL LONGTEXT fields to perform some automatic anchor tag transformations. I suspect that a great deal of computation time is spent in this task. Category 3 includes updates to a simple MySQL-based search index using just a

Visual Studio 2010, how to build projects in parallel on multicore

牧云@^-^@ 提交于 2019-11-27 10:33:35
问题 I have a big solution with more than 40 projects. Almost half of them are test projects. In my project we use both Code Contracts, Code Analysis, Style Analysis. I want to be able to build the projects that are not dependent in parallel on my quad core CPU. How can I setup msbuild to build the projects in parallel? 回答1: In Visual Studio: Tools | Options | Projects and Solutions | Build and Run. This should default to your CPU count. From the command line: msbuild /maxcpucount[:n] (is n is not

How do I utilise all the cores for nmake?

左心房为你撑大大i 提交于 2019-11-27 09:58:05
问题 I just got a new quad core computer and noticed that nmake is only using 1 process. I used to use make which had the switch -j4 for launching 4 processes. What is the nmake equivalent? [edit] Based on the information below I have been able to add a command to my qmake project file: QMAKE_CXXFLAGS += /MP Which effectively did it for me. Many thanks. 回答1: According to MSDN, there's no such option for nmake . You can however make the compiler build multiple files in parallel by using the /MP

Which CPU architectures support Compare And Swap (CAS)?

瘦欲@ 提交于 2019-11-27 09:41:57
问题 just curious to know which CPU architectures support compare and swap atomic primitives? 回答1: Powerpc has more powerful primitives available: "lwarx" and "stwcx" lwarx loads a value from memory but remembers the location. Any other thread or cpu that touches that location will cause the "stwcx", a conditional store instruction, to fail. So the lwarx /stwcx combo allows you to implement atomic increment / decrement, compare and swap, and more powerful atomic operations like "atomic increment

Multiprocessing or Multithreading?

点点圈 提交于 2019-11-27 09:26:09
问题 I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes. When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the

multi core processing in for loop using numpy

六月ゝ 毕业季﹏ 提交于 2019-11-27 09:10:22
I calculated vector using numpy. How can I calculate vector using multicore and numpy? import numpy as np num_row, num_col = 6000, 13572 ss = np.ones((num_row, num_col), dtype=np.complex128) ph = np.random.standard_normal(num_row) fre = np.random.standard_normal(num_row) tau = np.random.standard_normal(num_col) for idx in range(num_row): ss[idx, :] *= np.exp(1j*(ph[idx] + fre[idx]*tau)) We could leverage broadcasting to have a NumPy based solution - ss = np.exp(1j*(ph[:,None] + fre[:,None]*tau)) Porting this over to numexpr to leverage fast transcendental operations alongwith multi-core

What is some example code for demonstrating multicore speedup in Python on Windows?

99封情书 提交于 2019-11-27 09:10:04
I'm using Python 3 on Windows and trying to construct a toy example, demonstrating how using multiple CPU cores can speed up computation. The toy example is rendering of the Mandelbrot fractal. So far: I have avoided threading, since the Global Interpreter Lock prohibits multicores in this context I'm ditching example code that won't work on Windows because it lacks the forking capability of Linux Trying to use the "multiprocessing" package. I declare p=Pool(8) (8 is my number of cores) and using p.starmap(..) to delegate work. This is supposed to produce multiple "subprocesses" which windows

Haskell lightweight threads overhead and use on multicores

心不动则不痛 提交于 2019-11-27 09:07:39
问题 I've been reading the "Real World Haskell" book, the chapter on concurrency and parallelism. My question is as follows: Since Haskell threads are really just multiple "virtual" threads inside one "real" OS-thread, does this mean that creating a lot of them (like 1000) will not have a drastic impact on performance? I.e., can we say that the overhead incurred from creating a Haskell thread with forkIO is (almost) negligible? Please bring pactical examples if possible. Doesn't the concept of