More on Concurrency vs Parallelism

A reader asked why concurrency programming is not a super-set of parallel programming since the parallel entities are also concurrent. Well, it is just like black-white vs color photography. Though black and white are two colors, the techniques in taking good black-white pictures are different from those for color pictures. One need to think and see differently in terms of contrast, texture, lighting and even composition.

Now back to our programming world. Recently while I was working on the OpenMP profiling, I fixed a concurrency bug that was related to asynchronous signals and had nothing to do with parallelism. I used a data structure to store the OpenMP context of a thread. Since an OpenMP context can be described in a tuple <current parallel region, current task region, OpenMP state, user callstack>, the data structure has several 64-bit long fields. One challenge is to update the context data structure atomically, i.e. when my program needs to report the OpenMP context, it should report a consistent context. For example, it should not report a thread is in a new parallel region but is still in an old task region. The atomicity here has nothing to do with parallelism here - the context data is thread private, so there is no sharing between different threads and there is no data race. The atomicity issue happens when a profiling signal (SIGPROF) comes while the program is in the middle of updating the fields of the context data structure. At the signal handler, the program needs to report the context and need to report them consistently. In the end, I had to crafted a way to update all the fields atomically (asynchronously safe) without masking out the SIGPROF.

Here is another interesting discussion on concurrency vs parallelism. I checked the manual. The exact wording used is "The maximum number of active threads per multiprocessor is 768".

Comments:

[Trackback] 说实话在翻译POSA的时候,我不想用这两个词:并发、并行,而宁愿保留原文。但是对于一本讲分布式计算的书,如果我如此固执,里面会多出大量的英文——虽然现在已经是很多了。实际上,我在译文中也做了灵活的处理...

Posted by 勇敢的鸵鸟 on January 29, 2009 at 10:51 PM PST #

Thanks for your information, i have read it, very good!

Posted by tiffany & co Bracelet on November 12, 2009 at 02:44 PM PST #

with a elegant Chanel Watches on your wrist, you will immediately add up your current fashion quotient and help you obtain more confidence. There are different kinds of styles and designs of Replica Chanel Watches that are available in the market and you can always pick out one for any occasion. These Chanel Fake Watches would not add an excessive burden to your monthly bills since they are relatively very affordable.Chanel j12 Watch is obtaining more and more popularity in recent years. A wide range of fashionable styles and unique designs of these wonderful Chanel watch can be

Posted by chanel j12 watch on March 10, 2010 at 11:10 AM PST #

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Posted by omega watches on March 11, 2010 at 09:52 AM PST #

Tomorrow is Sarah's birthday

Posted by thomas sabo on September 05, 2010 at 06:19 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

yuanlin

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today