Архитектура Аудит Военная наука Иностранные языки Медицина Металлургия Метрология
Образование Политология Производство Психология Стандартизация Технологии


Describe the OpenMP programming model and compile programs with OpenMP.



Describe the OpenMP programming model and compile programs with OpenMP.

Shared Memory Model: OpenMP is designed for multi-processor/core, shared memory machines.

Thread Based Parallelism:

  • OpenMP programs accomplish parallelism exclusively through the use of threads.
  • A thread of execution is the smallest unit of processing that can be scheduled by an operating system. The idea of a subroutine that can be scheduled to run autonomously might help explain what a thread is.
  • Threads exist within the resources of a single process. Without the process, they cease to exist.
  • Typically, the number of threads match the number of machine processors/cores. However, the actual use of threads is up to the application.

Explicit Parallelism:

  • OpenMP is an explicit (not automatic) programming model, offering the programmer full control over parallelization.
  • Parallelization can be as simple as taking a serial program and inserting compiler directives....
  • Or as complex as inserting subroutines to set multiple levels of parallelism, locks and even nested locks.

Compiler Directive Based:

  • Most OpenMP parallelism is specified through the use of compiler directives which are imbedded in C/C++ or Fortran source code.

#pragma omp parallel default(shared) private(beta,pi)

Make definition of the classification of computer architectures, classification of parallel computing systems

Symmetric multiprocessing (SMP) involves a symmetric multiprocessor system hardware and software architecture where two or more identical processors connect to a single, shared main memory, have full access to all I/O devices, and are controlled by a single operating system instance that treats all processors equally, reserving none for special purposes.

Critically evaluate Synchronization in OpenMP.

Only one thread at a time can enter a critical region. It is high level synch.

There are two pragmas for critical sections: critical and atomic . The second one is more limited but has performance advantages.

The typical application of a critical section is to update a variable:

#pragma omp parallel{ int mytid = omp_get_thread_num(); double tmp = some_function(mytid);#pragma omp critical sum += tmp;}

 

 

Define the concepts of Stream, thread, process. Describe flow differences (filament) from the process.

Processes

· Process : "An execution stream in the context of a particular process state." 1.Execution stream: a sequence of instructions (only one thing happens at a time). 2.Process state: everything that can affect, or be affected by, the process: code, data, call stack, open files, network connections, etc.

· Is a process the same as a program?

· Uniprogramming system: only supports a single process. Simplifies some parts of OS, but many other things are hard to do. 1.Some early personal computer operating systems were uniprogramming (e.g. MS-DOS), but these systems are almost unheard of today. 2.This is not called "uniprocessing": that refers to a system with only one processor.

· Virtually all modern operating systems are multiprogramming systems: multiple processes can exist simultaneously and share the machine.

Threads

· Most modern operating systems also support threads: multiple execution streams within a single process 1.Threads share process state such as memory, open files, etc. 2.Each thread has a separate stack for procedure calls (in shared memory) 3.Thread is unit of sequential execution

· Why support threads? 1.Concurrent execution on multiprocessors 2.Manage I/O more efficiently: some threads wait for I/O while others compute 3.Most common usage for threads: large server applications

 

 

Parameters.

clause is any of the following clauses:

if (exp). When the if argument is specified, the program code executes in parallel only if the scalar expression represented by exp evaluates to a nonzero value at run time.

private (list). Declares the scope of the data variables in list to be private to each thread. Data variables in list are separated by commas.

num_threads (int_exp). The value of int_exp is an integer expression that specifies the number of threads to use for the parallel region.

shared (list). Declares the scope of the comma-separated data variables in list to be shared across all threads.

Describe the OpenMP programming model and compile programs with OpenMP.

Shared Memory Model: OpenMP is designed for multi-processor/core, shared memory machines.

Thread Based Parallelism:

  • OpenMP programs accomplish parallelism exclusively through the use of threads.
  • A thread of execution is the smallest unit of processing that can be scheduled by an operating system. The idea of a subroutine that can be scheduled to run autonomously might help explain what a thread is.
  • Threads exist within the resources of a single process. Without the process, they cease to exist.
  • Typically, the number of threads match the number of machine processors/cores. However, the actual use of threads is up to the application.

Explicit Parallelism:

  • OpenMP is an explicit (not automatic) programming model, offering the programmer full control over parallelization.
  • Parallelization can be as simple as taking a serial program and inserting compiler directives....
  • Or as complex as inserting subroutines to set multiple levels of parallelism, locks and even nested locks.

Compiler Directive Based:

  • Most OpenMP parallelism is specified through the use of compiler directives which are imbedded in C/C++ or Fortran source code.

#pragma omp parallel default(shared) private(beta,pi)


Поделиться:



Последнее изменение этой страницы: 2019-04-01; Просмотров: 337; Нарушение авторского права страницы


lektsia.com 2007 - 2024 год. Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав! (0.012 с.)
Главная | Случайная страница | Обратная связь