OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.

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结构。一个结构化模块是一个独立语句，或是一个在顶部有独立入口并且底部有独立出口的复合语句。

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

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来获得的。

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] ...}

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结构相关的结构模块仅被线程伍中的某一个线程（不一定是主线程）来执行。

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都有相同的意义和限制。

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机构的并行结构的一种快捷方式，该结构中没有其他的语句。

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

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