Top Banner
OPEN MP Shared Memory Multiprocessing Programming Presenter : 백백백 windage.co.kr [email protected]
17

Open MP

Apr 30, 2015

Download

Technology

Woonhyuk Baek

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Open MP

OPEN MPShared Memory Multiprocessing Programming

Presenter : 백운혁windage.co.kr

[email protected]

Page 2: Open MP

● Agenda

• Background• Multiprocessing Programming• Preference• Programming Model• Parallel Section• Clauses• Synchronization

Page 3: Open MP

● Background

Parallel has no semantic impact

Concurrency has a substantial semantic impact

Page 4: Open MP

● Background

• Symmetric Multi Processor(SMP)– Shared Memory Multiprocessing Programming– OpenMP

• Massively Parallel Processor(MPP)– Message Passing Interface Programming– MPI

Page 5: Open MP

● Background

Page 6: Open MP

● Multiprocessing Programming

Page 7: Open MP

● Multiprocessing Programming

• General Threading Model– Main thread executes the program’s main function– Main thread creates subthreads, witch execute other

functions in the program.– Subthreads can also create additional threads.

Page 8: Open MP

● Multiprocessing Programming

• Benefits– Increased performance and better resource utilization

• Even on single processor systems – for hiding latency and increasing throughput

– IPC thread shared memory is more efficient

• Risk– Increases complexity of the application– Difficult to debug (data races, deadlocks, etc.)

Page 9: Open MP

● OpenMP Preference (later VS2005)

Page 10: Open MP

● OpenMP Preference (later GCC 4.2)

Page 11: Open MP

● Programming Model

• Generate multi-thread code by referencing directive code

• Compiler is required to support openMP

• To eliminate synchronization and dependency

Page 12: Open MP

Section3

JoinFork

Section1

JoinFork

Section2

JoinFork

Programming Model

Page 13: Open MP

● Parallel Section (for)

#pragma omp for [clause [clause …] ] { for loop}

Fork

for loop

Join

Page 14: Open MP

● Parallel Section (sections)

#pragma omp sections [clause [clause …] ] { [#progma omp section] structured code block}

Fork

sections

Join

Page 15: Open MP

● Clauses

• private(var1, …)– to block sharing selected values with threads

• shared(var1, …)– to share selected values with threads

• schedule(type [, chunk_size])– to divide work with threads for equality

• static• dynamic

Page 16: Open MP

● Synchronization (critical section)

• Declaring critical section in parallel section

• Running only single thread at moment

#pragma omp critical [(name)]{ structured code block}

Page 17: Open MP

OPEN MPShared Memory Multiprocessing Programming

[email protected]

https://computing.llnl.gov/tutorials/openMP/