OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Version)

Discuss the OpenMP 3.1 API Specifications with the OpenMP Arch. Review Board. (Read Only)

OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Version)

Postby doom_ood » Mon Feb 06, 2012 4:36 am

OpenMP 3.1 API C/C++ Syntax Quick Reference Card
OpenMP 3.1 API C/C++ 语法规范速查页
OpenMP Application Program Interface (API) is a portable, scalable model that gives shared-memory parallel programmers a simple and flexible interface for developing parallel applications for platforms ranging from the desktop to the supercomputer.
OpenMP应用程序API是可移植、可调节的模型,它提供给共享内存的并行程序员一个简单和灵活的接口,来开发并行应用,使其运行在从桌面到超级计算机的各种平台。
OpenMP supports multi-platform shared-memory parallel programming in C/C++ and Fortran on all architectures, including Unix platforms and Windows NT platforms. A separate OpenMP reference card for Fortran is also available.
OpenMP支持多平台共享内存的并行编程,使用C/C++语言和Fortran语言在包括Unix和Windows NT在内的各种架构上编写。除此之外,还有一个独立的为Fortran语言编写的OpenMP速查页。
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 4:44 am

Directives
指令
An OpenMP executable directive applies to the succeeding structured block or an OpenMP Construct. A structured-block is a single statement or a compound statement with a single entry at the top and a single exit at the bottom.
一个OpenMP可执行指令应用于连续的结构化模块或OpenMP结构。一个结构化模块是一个独立语句,或是一个在顶部有独立入口并且底部有独立出口的复合语句。
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 4:48 am

Parallel [2.4]
The parallel construct forms a team of threads and starts parallel execution.
parallel结构形成线程的伍,并且开始并行执行。

具体用法:
#pragma omp parallel [clause[ [, ]clause] ...]
structured-block

clause:
其中的clause可以是如下的:
if(scalar-expression)
num_threads(integer-expression)
default(shared | none)
private(list)
firstprivate(list)
shared(list)
copyin(list)
reduction(operator: list)
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 5:52 am

Loop [2.5.1]
The loop construct specifies that the iterations of loops will be distributed among and executed by the encountering team of threads.
循环结构规定了,循环的迭代会被分布在线程伍之间并且被他们来执行。
具体用法:
#pragma omp for [clause[ [, ]clause] ...]
for-loops

clause:
其中的clause可以是如下的:
private(list)
firstprivate(list)
lastprivate(list)
reduction(operator: list)
schedule(kind[, chunk_size])
collapse(n)
ordered
nowait

kind:
schedule中的kind可以是如下的:
• static: Iterations are divided into chunks of size chunk_size. Chunks are assigned to threads in the team in round-robin fashion in order of thread number.
static静态:迭代被分为大小为chunk_size的块。块根据线程号为顺序采用轮询的房事被分配给线程伍中的线程。
• dynamic: Each thread executes a chunk of iterations then requests another chunk until no chunks remain to be distributed.
dynamic动态:每一个线程执行了一块的迭代,然后请求另一个块直到没有待分配的块剩余为止。
• guided: Each thread executes a chunk of iterations then requests another chunk until no chunks remain to be assigned. The chunk sizes start large and shrink to the indicated chunk_size as chunks are scheduled.
guided导引:每一个线程执行了一块迭代,然后请求另一个块直到没有待分配的块剩余。块大小开始很大,但随着调度过程慢慢缩减到指明的chunk_size大小。
• auto: The decision regarding scheduling is delegated to the compiler and/or runtime system.
auto自动:调度决定委派给编译器或者运行时系统。
• runtime: The schedule and chunk size are taken from the run-sched-var ICV.
runtime运行时:调度和块大小是从run-shed-var ICV来获得的。
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 5:54 am

Sections [2.5.2]
The sections construct contains a set of structured blocks that are to be distributed among and executed by the encountering team of threads.
section结构包含了一套分配在结构伍之间并且被其执行的结构模块。
#pragma omp sections [clause[[,] clause] ...]
{
[#pragma omp section]
structured-block
[#pragma omp section
structured-block]
...
}

clause:
其中的clause可以是如下的:
private(list)
firstprivate(list)
lastprivate(list)
reduction(operator: list)
nowait
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 5:58 am

Single [2.5.3]
The single construct specifies that the associated structured block is executed by only one of the threads in the team (not necessarily the master thread), in the context of its implicit task.
single结构规定了,在明确任务的背景下,与该single结构相关的结构模块仅被线程伍中的某一个线程(不一定是主线程)来执行。

#pragma omp single [clause[ [, ]clause] ...]
structured-block

clause:
其中的clause可以是如下的:
private(list)
firstprivate(list)
copyprivate(list)
nowait
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 6:08 am

Parallel Loop [2.6.1]
The parallel loop construct is a shortcut for specifying a parallel construct containing one or more associated loops and no other statements.
parallel loop结构是规定包含了一个或多个循环的一种快捷方式,该结构中没有其他的语句。

#pragma omp parallel for [clause[ [, ]clause] ...]
for-loop

clause:
其中的clause可以是如下的:
Any accepted by the parallel or for directives, except the nowait clause, with identical meanings and restrictions.
任何被parallel或for指令接受的clause,并且对除了nowait之外的clause都有相同的意义和限制。

Simple Parallel Loop Example
简单的并行循环例程
The following example demonstrates how to parallelize a simple loop using the parallel loop construct.
下面的例子展示了如何使用并行循环结构使一个简单的循环并行化。
void simple(int n, float *a, float *b)
{
int i;
#pragma omp parallel for
for (i=1; i<n; i++) /* i is private by default */
b[i] = (a[i] + a[i-1]) / 2.0;
}
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 6:12 am

Parallel Sections [2.6.2]
The parallel sections construct is a shortcut for specifying a parallel construct containing one sections construct and no other statements.
parallel loop结构是用来规定一个包含了一个section机构的并行结构的一种快捷方式,该结构中没有其他的语句。

#pragma omp parallel sections [clause[ [, ]clause] ...]
{
[#pragma omp section]
structured-block
[#pragma omp section
structured-block]
...
}
clause:
其中的clause可以是如下的:
Any of the clauses accepted by the parallel or sections directives, except the nowait clause, with identical meanings and restrictions.
任何被parallel或section指令接受的clause,并且对除了nowait之外的clause都有相同的意义和限制。
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 6:19 am

Task [2.7.1]
The task construct defines an explicit task. The data environment of the task is created according to the data-sharing attribute clauses on the task construct and any defaults that apply.
task结构定义了一个明确的任务。任务的数据环境,根据task结构和任何适用的默认结构上的数据共享属性clause来产生。
具体用法:
#pragma omp task [clause[ [, ]clause] ...]
structured-block

clause:
其中的clause可以是如下的:
if(scalar-expression)
final(scalar-expression)
untied
default(shared | none)
mergeable
private(list)
firstprivate(list)
shared(list)
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Re: OpenMP 3.1 API C/C++ Syntax Quick Reference(Chinese Vers

Postby doom_ood » Mon Feb 06, 2012 6:28 am

Taskyield [2.7.2]
The taskyield construct specifies that the current task can be suspended in favor of execution of a different task.
taskyield结构规定了,当前任务可以在不同任务的执行中被挂起。
具体用法:
#pragma omp taskyield

Master [2.8.1]
The master construct specifies a structured block that is executed by the master thread of the team. There is no implied barrier either on entry to, or exit from, the master construct.
master结构规定了一个被线程伍中的主线程执行的结构模块。在master结构中没有不成文的入口或出口。
具体用法:
#pragma omp master
structured-block

Critical [2.8.2]
The critical construct restricts execution of the associated structured block to a single thread at a time.
critical结构,在某一个时间把与之相关的结构模块的执行限制到了单一线程。
具体用法:
#pragma omp critical [(name)]
structured-block

Barrier [2.8.3]
The barrier construct specifies an explicit barrier at the point at which the construct appears.
barrier结构规定了一个在该结构出现位置的明确的障碍。
具体用法:
#pragma omp barrier

Taskwait [2.8.4]
The taskwait construct specifies a wait on the completion of child tasks of the current task.
taskwait结构规定了在当前任务的子任务完成时等待。
具体用法:
#pragma omp taskwait
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Next

Return to OpenMP 3.1 API Specifications

Who is online

Users browsing this forum: No registered users and 0 guests