Recently, my colleague, Dick Bowler and I wrote a sample application that implements Conway's Game of Life. The purpose of the sample was to visually demonstrate the performance of a single threaded version of an algorithm vs. a scalable multi-threaded version. The app was to display two game boards side-by-side; the first board would have the computation for the next generation handled by a single thread and the second would be multi-threaded. We had fun implementing this sample and learned a few things along the way.
First, we decided to be adventurous and mix native C++ and C++/CLI. We planned to use C++/CLI for the user interface (to pick up the Windows Forms classes from the .NET Base Class Library) and C++ for the game board calculations. Second, we wanted to write code that would scale in performance as it ran on additional processor cores. To this end, we decided to use Intel's Threading Building Blocks library to implement the parallel algorithm code. Finally, we wanted the display to update in real time as the boards were recomputed so that the user could watch successive generations as they evolved.
Going in, as a longtime C/C++ developer, I was skeptical of C++/CLI, and I disliked the strange syntactic extensions to the language. It seemed like another "embrace and extend" tactic where the language would be altered into a proprietary dialect. However, after using C++/CLI for a bit, I must say that the combination worked OK for this application. I was able to manage the syntactic differences ("ref class," "gcnew," handles, etc) fairly easily and was able to easily mix native and managed types. I had access to the same Base Class Library as when using C# and yet could drop down to native C++ code when needed, without having to use COM interop. Overall, I still don’t like the syntactic changes, and the associated loss in portability, but the combination worked as well as we had hoped.
Previously, I have implemented sample programs that partition applications only at a high level - worker threads, user interface thread, etc - and have realized that while they are an improvement over entirely single-threaded applications, applications partitioned in this way will also hit a performance wall as the number of processors increases. Eventually, each of the applications threads could be running on its own processor core, and the application would receive no further benefit from additional processor cores. With the Game of Life sample, we intended to use the Threading Building Blocks to show how applications should continue to extract parallelism at the algorithmic level. In other words, if developers can code algorithms to be multi-threaded, the applications will scale further than those applications that just have high-level partitioning. Intel's Threading Building Blocks (TBB) library is a good tool for implementing parallel algorithms. The TBB library is available for multiple operating systems and compilers and allows developers to implement algorithm-level parallelism in a processor-independent way.
For me, getting the application to update the UI for successive generations was, surprisingly, the hardest part of the application. Each game board window was responsible for updating its contents every time a new board was computed. First, we tried to post a message to the window for it to update itself with the new board data. While this worked, the application UI effectively froze as incoming events were drowned in the requests for board updates. This was definitely unacceptable. After all, we have complained many times in this series of blogs about unresponsive applications :). After some thought we figured a way out: after computing the next board to display, draw directly into the board's graphic context (more like a computer game would as it draw successive frames) instead of posting a message to the window’s message queue.
Anyway, this series of samples has been fun, and we look forward to developing a few more. If you're interested in C++/CLI, TBB, or graphically representing the results of your algorithm in real time, check out the sample.
Michael Jeronimo
Thanks for the great illustrative TBB example, although it's partially written with horrible C++/CLI which I think you've done since you're using some MS Compiler/GUI toolkit.
I wonder if you can provide an alternative standard C++/Qt approach.
Thanks in advance,
Posted by: Yousef | May 29, 2008 at 07:57 PM
Don't be so hard on him. He probably doesn't know HOW to program without the Microsoft crutches. A better question, though, would have been to see it programmed with just C++ and boost in addition to the TBB version, like real programmers do.
Posted by: Mike Dean | October 14, 2009 at 08:29 AM
http://oppao.net/n-ona/
http://oppao.net/navi/
http://oppao.net/new-d2/
http://oppao.net/fd3/
http://oppao.net/soap2/
http://oppao.net/bg2/
http://oppao.net/host2/
http://oppao.net/lesson2/
http://oppao.net/op2/
http://oppao.net/fl3/
http://oppao.net/bb2/
http://oppao.net/s-este/
http://oppao.net/rd2/
http://oppao.net/kawa/
http://oppao.net/n-club2/
http://s-auc.net/
Posted by: オテモヤン | March 25, 2010 at 09:02 PM
I loved this film and the music. I thought it deserved a lot more attention than it seemed to receive. It was not in the Canadian theatres very long. Dare I say it was almost on equal footing with The Hours in the way the music flowed with the film? It seemed like a perfect fit.
Posted by: generic viagra | April 08, 2010 at 10:44 AM
The ESRB provides ratings of game content so that you can determine if
these indeed are appropriate for your kids. Here are the ratings for
the games you mentioned and the themes found in the material that
maybe of concern to parents.
Posted by: viagra no prescription | April 20, 2010 at 01:40 PM
Great tips! I look forward to the other two as well!
Posted by: cheap cialis | April 23, 2010 at 10:33 AM
i like this part of the blog:"Previously, I have implemented sample programs that partition applications only at a high level - worker threads, user interface thread, etc - and have realized that while they are an improvement over entirely single-threaded applications, applications partitioned in this way will also hit a performance wall as the number of processors increases" is very good
Posted by: propecia | April 26, 2010 at 08:37 AM
Anyway, this series of samples has been fun, and we look forward to developing a few more. If you're interested in C++/CLI, TBB, or graphically representing the results of your algorithm in real time, check out the sample.
Michael Jeronimo
Posted by: hairy pussy | May 17, 2010 at 06:41 AM
test
test
wafhlwaofhlohlhflhflh
http://flwfhlwehflh.com/
Posted by: tetetetetete | May 23, 2010 at 07:06 AM
For some people the highways became a funny trip and never think of care they must to have every time they go over there. I do expect some separation of views between the introverts and extroverts, but don't know if your unscientific poll will be able to discern that distinction. Should be interesting to see your next post reveals.
Posted by: viagra online | August 18, 2010 at 03:02 PM
Do you have a viable business but lack the necessary finances to get it off it’s feet?
Posted by: RamonGustav | August 23, 2010 at 11:25 PM
I think you are not quite right and you should still studying the matter.
Posted by: Buy_Viagra | September 16, 2010 at 01:14 AM
Do you have a viable business but lack the necessary finances to get it off it’s feet?
Posted by: Music_master | September 24, 2010 at 09:51 AM
buy cialis buy cialis at a discount buy cialis brand buy cialis by the pill buy cialis canada buy cialis cheap buy cialis cheaper online buy cialis mexico buy cialis omline buy cialis online 20mg buy cialis online site buy cialis online viagra buy cialis pharmacy buy cialis pills generic
Posted by: Hot_cialis | October 29, 2010 at 09:00 PM
i'm thinking of which of the 2 should i get?? the 15 or the 17 one.
Posted by: ugg bailey button triplet | November 18, 2010 at 05:38 PM
buy cialis buy cialis at a discount buy cialis brand buy cialis by the pill buy cialis canada buy cialis cheap buy cialis cheaper online buy cialis mexico buy cialis omline buy cialis online 20mg buy cialis online site buy cialis online viagra buy cialis pharmacy buy cialis pills generic
Posted by: RX-order | November 19, 2010 at 04:47 PM
You write well will be waiting for your new publications.
Posted by: Antivirus_man | December 05, 2010 at 01:34 PM
strengthen cooperation, especially in the six-party talks framework to strengthen cooperation in order to emphasize the implementation of UN http://www.laptopbattery-wholesale.com/ wholesale laptop battery
Posted by: cheap laptop battery | December 12, 2010 at 06:29 PM
I liked your site, you are very interesting to write. Merry Christmas and Happy New Year!
Posted by: JOBS_frend | December 25, 2010 at 01:47 PM
Happy New Year! Happiness and success in 2011.
Posted by: school_dubl | December 28, 2010 at 05:55 PM
Fabulous, out of this world…great man, you have proved the world that innovation is not lost from the universe. I am so influenced by your way of expression; I think I will work to improve mine…great going dude!!!
Posted by: zenegra | January 03, 2011 at 12:53 AM
well!!! got it
Posted by: supra shoes | January 06, 2011 at 01:17 AM
Hi Merry Christmas and Happy New Year, a cool site I like
Posted by: Realestate | January 10, 2011 at 09:05 AM
Nice,Thanks for such a great post and the review, I am totally impressed!
Posted by: Generic Viagra | January 11, 2011 at 09:32 PM
Happy New Year! Happiness and success in 2011.
Posted by: Rental | January 14, 2011 at 12:07 PM