moogs
moogs

Reputation: 8202

Parallel API for C/C++ on Windows

We're developing something for the Windows platform and we'd like to harness the multiple cores present in PCs nowadays.

I know that in VS2010, there is the Concurrency Runtime. It's still on Beta, though. For the meantime that we do need to release quality code now, what is a good option for an API that will allow smooth transition later. Other suggestions?

Upvotes: 3

Views: 2229

Answers (5)

Michael J
Michael J

Reputation: 7939

Short answer: hire a programmer with good threading experience.

Working with multi threads on multi cores is hard. There is no substitute for experience.

Visual C++ (any recent version) has the tools for developing parallel software, but there are complexities such as data synchronisation that make it very tricky for the inexperienced. The Concurrency Runtime stuff is an attempt to hide the complexity and let the compiler do the work. It may work very well, but the jury is still out. For now, you can get good results with the existing tools, but you need the expertise.

Consider hiring a good contractor to help get the architecture right and train your own staff up to speed.

Upvotes: 1

Shane Powell
Shane Powell

Reputation: 14148

I know of:

  • Intel Thread Building Block library (open source)
  • C++0x thread library support (cross platform sometime in the future)
  • Just Software implementation of the C++0x thread library - allows you to have a head start on using the new c++ thread library in vs 2008.
  • OpenMP - build into most C++ compilers these days, including VS 2008.
  • pthreads for win32 - POSIX threads so they are cross platform for any POSIX complaint OS.
  • WIN32 threading API

I would recommend the Intel Thread Building Blocks as it's a higher level of abstraction over most of the other multi-threaded API's. It's also open source so you can download and see how some of the stuff is done. Upcomming versions are meant to use the windows Concurrency Runtime if it's available. I've also read that Intel have submitted TBB to be included into the C++ standard.

pthreads and the Win32 API are lower level primitives that require you to understand the multi-threaded environment a lot better. If you know what you are doing, these tools give you the most control.

I have yet to use the new c++ threading support but they look to be on the same level or a little higher as pthreads. Just Software has some interesting articles on how to use the new c++ thread library.

I have only read about OpenMP and I'm not sure what it's like to use.

You may like to read Joe Duffy's Concurrent Programming on Windows book.

Herb Sutter also posts lots of articles under the title Effective Concurrency.

Hope that helps.

Upvotes: 2

stephan
stephan

Reputation: 10265

I suggest using OpenMP while waiting. It is implemented for most compilers, relatively easy to add to existing code, and to use later on with other APIs.

Upvotes: 2

Paul Nathan
Paul Nathan

Reputation: 40299

I have always liked pthreads. It maps pretty well onto the other threading models I've run into, and I've found it relatively easy to program(as compared to, say, MPI).

However, it's not as high-level as the Concurrency Runtime.

I've also heard some noise about OpenMP, but havn't looked into it.

Upvotes: 1

Jesse Hall
Jesse Hall

Reputation: 6787

Intel's Thread Building Block library has a parallel task system that is similar (at a high level) to the Concurrency Runtime. API details will differ, but the work you do to break your program into small tasks that run independently will carry over.

Upvotes: 1

Related Questions