Open MP

677 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
677
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Open MP

  1. 1.
  2. 2. Agenda<br />Background<br />Multiprocessing Programming<br />Preference<br />Programming Model<br />Parallel Section<br />Clauses<br />Synchronization<br />
  3. 3. Background<br />Parallel has no semantic impact<br />Concurrency has a substantial semantic impact<br />
  4. 4. Background<br />Symmetric Multi Processor(SMP)<br />Shared Memory Multiprocessing Programming<br />OpenMP<br />Massively Parallel Processor(MPP)<br />Message Passing Interface Programming<br />MPI<br />
  5. 5. Background<br />
  6. 6. Multiprocessing Programming<br />
  7. 7. Multiprocessing Programming<br />General Threading Model<br />Main thread executes the program’s main function<br />Main thread creates subthreads, witch execute other functions in the program.<br />Subthreads can also create additional threads.<br />
  8. 8. Multiprocessing Programming<br />Benefits<br />Increased performance and better resource utilization<br />Even on single processor systems – for hiding latency and increasing throughput<br />IPC thread shared memory is more efficient<br />Risk<br />Increases complexity of the application<br />Difficult to debug (data races, deadlocks, etc.)<br />
  9. 9. OpenMP Preference (later VS2005)<br />
  10. 10. OpenMP Preference (later GCC 4.2)<br />
  11. 11. Programming Model<br />Generate multi-thread code by referencing directive code <br />Compiler is required to support openMP<br />To eliminate synchronization and dependency<br />
  12. 12. Programming Model<br />
  13. 13. Parallel Section (for)<br />#pragmaomp for [clause [clause …] ] <br />{<br /> for loop<br />}<br />
  14. 14. Parallel Section (sections)<br />#pragmaomp sections [clause [clause …] ] {<br /> [#progmaomp section]<br /> structured code block<br />}<br />
  15. 15. Clauses<br />private(var1, …)<br /> to block sharing selected values with threads<br />shared(var1, …)<br />to share selected values with threads <br />schedule(type [, chunk_size])<br />to divide work with threads for equality<br />static<br />dynamic<br />
  16. 16. Synchronization (critical section)<br />Declaring critical section in parallel section<br />Running only single thread at moment<br />#pragmaomp critical [(name)]<br />{<br /> structured code block<br />}<br />
  17. 17. https://computing.llnl.gov/tutorials/openMP/<br />

×