Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel Programming and C++

I've been writing a lot recently about Parallel computing and programming and I do notice that there are a lot of patterns that come up when it comes to parallel computing. Noting that Microsoft already has released a library along with the Microsoft Visual C++ 2010 Community Technical Preview (named Parallel Patterns Library) I'm wondering what are the common parallel programming patterns you have been using and encountering that may be worth remembering? Do you have any idioms you follow and patterns that you seem to keep popping up as you write parallel programs with C++?

like image 974
Dean Michael Avatar asked Nov 01 '08 17:11

Dean Michael


People also ask

What is parallel programming in C?

Parallel programming is the process of using a set of resources to solve a problem in less time by dividing the work. Using parallel programming in C is important to increase the performance of the software.

What is an example of parallel programming?

With parallel programming, a developer writes code with specialized software to make it easy for them to run their program across on multiple nodes or processors. A simple example of where parallel programming could be used to speed up processing is recoloring an image.

What is meant by parallel programming?

Parallel processing is a method in computing of running two or more processors (CPUs) to handle separate parts of an overall task. Breaking up different parts of a task among multiple processors will help reduce the amount of time to run a program.

Is parallel programming a hard course?

Programming parallel computers, consisting of multiple powerful processing elements, is a hard task.


1 Answers

Patterns:

  • Produce/Consumer

    • One Thread produces data
    • One Thread consumes the data
  • Loop parallelism

    • If you can show that each loop is independent
      each iteration can be done in a sperate thread
  • Re-Draw Thread

    • Other threads do work and update data structures but one thread re-draws screen.
  • Main-Event Thread

    • Multiple threads can be generating events
    • One thread has to processes the events (as order is important)
    • Should try separate the Event Thread/Re-Draw Thread
      This (helps) prevents the UI from freezing
      But may cause excessive re-draws if not done carefully.
  • Work Group

    • A set of threads waits for jobs on a que.
    • Thread extract one work item from queue (waiting if none is available).
      Thread works on one work item until complete
      Once completed thread returns to queue.
like image 163
Martin York Avatar answered Nov 09 '22 14:11

Martin York