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)

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

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

Atomic [2.8.5]
The atomic construct ensures that a specific storage location is updated atomically, rather than exposing it to the possibility of multiple, simultaneous writing threads.
atomic结构保证了一个特定存储位置被原子性的更新,而避免多线程同时写访问的可能性。
具体用法:
#pragma omp atomic [read | write | update | capture]
expression-stmt
#pragma omp atomic capture
structured-block

Flush [2.8.6]
The flush construct executes the OpenMP flush operation, which makes a thread’s temporary view of memory consistent with memory, and enforces an order on the memory operations of the variables.
flush结构执行了OpenMP刷出操作,使得线程的内存视图与实际内存一致,并且在变量的内存操作中强加一个顺序。
具体用法:
#pragma omp flush [(list)]

Ordered [2.8.7]
The ordered construct specifies a structured block in a loop region that will be executed in the order of the loop iterations. This sequentializes and orders the code within an ordered region while allowing code outside the region to run in parallel.
ordered结构规定了循环区域中的结构模块,会以循环迭代的顺序来执行。这使得在ordered区域内的代码序列化,同时允许区域外的代码并行运行。
具体用法:
#pragma omp ordered
structured-block

Threadprivate [2.9.2]
The threadprivate directive specifies that variables are replicated, with each thread having its own copy.
threadprivate定义规定了变量被复制而且每一个线程有该变量自己的拷贝。
具体用法:
#pragma omp threadprivate(list)
list:
其中的list可以是如下的:
A comma-separated list of file-scope, namespace-scope, or static block-scope variables that do not have incomplete types.
一个由逗号隔开的文件范围、命名空间范围或者静态块范围变量的序列,序列中没有不完整的类型。
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 9:28 pm

Runtime Library Routines
运行时库函数
Execution Environment Routines [3.2]
执行环境函数
Execution environment routines affect and monitor threads, processors, and the parallel environment.
执行环境函数影响并且监控了线程,处理器以及并行环境。

void omp_set_num_threads(int num_threads);
Affects the number of threads used for subsequent parallel regions that do not specify a num_threads clause.
影响了用于没有规定num_threads clause的后续并行区域的线程的数量。

int omp_get_num_threads(void);
Returns the number of threads in the current team.
返回当前线程伍中的线程的数量。

int omp_get_max_threads(void);
Returns maximum number of threads that could be used to form a new team using a parallel construct without a num_threads clause.
返回可用于使用parallel结构不加num_threads clause,来形成新线程伍的线程的最大数量。

int omp_get_thread_num(void);
Returns the ID of the encountering thread where ID ranges from zero to the size of the team minus 1.
返回thread的ID,ID的范围从0到线程伍的大小减1。

int omp_get_num_procs(void);
Returns the number of processors available to the program.
返回可用于程序的处理器的数目。

int omp_in_parallel(void);
Returns true if the call to the routine is enclosed by an active parallel region; otherwise, it returns false.
返回true,如果对函数的调用在活跃并行区域;否则,返回false。

void omp_set_dynamic(int dynamic_threads);
Enables or disables dynamic adjustment of the number of threads available by setting the value of the dyn-var ICV.
通过设置dyn-var ICV的值,来使能或使不能对于可用线程数量的动态调节。

int omp_get_dynamic(void);
Returns the value of the dyn-var ICV, determining whether dynamic adjustment of the number of threads is enabled or disabled.
返回dyn-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 9:46 pm

void omp_set_nested(int nested);
Enables or disables nested parallelism, by setting the nest-var ICV.
使能或使不能嵌套并行化,通过设置nest-var ICV。

int omp_get_nested(void);
Returns the value of the nest-var ICV, which determines if nested parallelism is enabled or disabled.
返回nest-var ICV的值,看看是否嵌套并行化被使能还是使不能。

void omp_set_schedule(omp_sched_t kind, int modifier);
Affects the schedule that is applied when runtime is used as schedule kind, by setting the value of the run-sched-var ICV.
影响了当runtime作为调度kind时的调度,通过设置run-sched-var ICV的值。
kind is one of static, dynamic, guided, auto, or an implementation-defined schedule.
kind是static、dynamic、guided、auto或implementation-defined 调度中的某一个。

void omp_get_schedule(omp_sched_t *kind, int *modifier);
Returns the value of run-sched-var ICV, which is the schedule applied when runtime schedule is used.
返回了当runtime调度被使用时的调度的run-sched-var ICV值。

int omp_get_thread_limit(void);
Returns the value of the thread-limit-var ICV, which is the maximum number of OpenMP threads available to the program.
反悔了thread-limit-var ICV的值,表明了对于程序的OpenMP 线程的最大数量。

void omp_set_max_active_levels(int max_levels);
Limits the number of nested active parallel regions, by setting max-active-levels-var ICV.
限制了嵌套的活动并行区域的数量,通过设置max-active-levels-var ICV。

int omp_get_max_active_levels(void);
Returns the value of max-active-levels-var ICV, which determines the maximum number of nested active parallel regions.
返回了max-active-levels-var ICV的值,表明了嵌套活动并行区域的最大数量。

int omp_get_level(void);
Returns the number of nested parallel regions enclosing the task that contains the call.
返回了包含了该调用的任务的嵌套并行区域的数量。

int omp_get_ancestor_thread_num(int level);
Returns, for a given nested level of the current thread, the thread number of the ancestor or the current thread.
对于当前线程的给定的嵌套层级,返回当前线程或其父线程的线程号。

int omp_get_team_size(int level);
Returns, for a given nested level of the current thread, the size of the thread team to which the ancestor or the current thread
belongs.
对于当前线程的给定的嵌套层级,返回当前线程或其父线程属于的线程伍的大小。

int omp_get_active_level(void);
Returns the number of nested, active parallel regions enclosing the task that contains the call.
返回了包含了该调用的任务的嵌套活动并行区域的数量。

int omp_in_final(void);
Returns true if the routine is executed in a final or included task region; otherwise, it returns false.
返回true,如果函数被执行在终点区域或者被包含的任务区域;否者,返回false。
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 9:51 pm

Lock Routines [3.3]
锁函数
Lock routines support synchronization with OpenMP locks.
锁函数支持OpenMP锁的同步。

void omp_init_lock(omp_lock_t *lock);
void omp_init_nest_lock(omp_nest_lock_t *lock);
These routines initialize an OpenMP lock.
这些函数初始化了OpenMP lock。

void omp_destroy_lock(omp_lock_t *lock);
void omp_destroy_nest_lock(omp_nest_lock_t *lock);
These routines ensure that the OpenMP lock is uninitialized.
这些函数确保了OpenMP lock是未初始化的。

void omp_set_lock(omp_lock_t *lock);
void omp_set_nest_lock(omp_nest_lock_t *lock);
These routines provide a means of setting an OpenMP lock.
这些函数提供了设置OpenMP锁的一种方式。

void omp_unset_lock(omp_lock_t *lock);
void omp_unset_nest_lock(omp_nest_lock_t *lock);
These routines provide a means of unsetting an OpenMP lock.
这些函数提供了解除OpenMP锁的一种方式。

int omp_test_lock(omp_lock_t *lock);
int omp_test_nest_lock(omp_nest_lock_t *lock);
These routines attempt to set an OpenMP lock but do not suspend execution of the task executing the routine.
这些函数尝试设置OpenMP锁但是不挂起执行该函数的任务的执行。

Timing Routines [3.4]
时间函数
Timing routines support a portable wall clock timer.
时间函数支持一个可移植的计时器。

double omp_get_wtime(void);
Returns elapsed wall clock time in seconds.
以秒为单位返回计时器的流逝时间。

double omp_get_wtick(void);
Returns the precision of the timer used by omp_get_wtime.
返回计时器的精确度。
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 9:53 pm

Data Types For Runtime Library Routines
运行时库函数的数据类型

omp_lock_t:
Represents a simple lock.
代表了一个简单的锁。

omp_nest_lock_t:
Represents a nestable lock.
代表了一个可嵌套的锁。

omp_sched_t:
Represents a schedule.
代表了一个调度。
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 10:16 pm

Clauses
子句
The set of clauses that is valid on a particular directive is described with the directive. Most clauses accept a comma-separated list of list items. All list items appearing in a clause must be visible.
在特定的指令上可用一套子句与指令一起被描述。多数子句接受逗号隔开的一个列表的子句项。所有的出现在子句中的列表项必须是可见的。

Data Sharing Attribute Clauses [2.9.3]
数据共享属性子句

Data-sharing attribute clauses apply only to variables whose names are visible in the construct on which the clause appears.
数据共享属性子句,仅应用于子句出现的结构中名字是可见的变量。

default(shared | none)
Controls the default data-sharing attributes of variables that are referenced in a parallel or task construct.
控制在并行或任务结构中引用的变量的默认数据共享属性。

shared(list)
Declares one or more list items to be shared by tasks generated by a parallel or task construct.
定义一个或多个列表项,被一个并行结构或任务结构产生的任务所共享。

private(list)
Declares one or more list items to be private to a task.
定义对于一个任务是私有的一个或多个列表项。

firstprivate(list)
Declares one or more list items to be private to a task, and initializes each of them with the value that the corresponding original item has when the construct is encountered.
定义对于一个任务是私有的一个或多个列表项,并且初始化他们每一个为在结构中相应原始项的值。

lastprivate(list)
Declares one or more list items to be private to an implicit task, and causes the corresponding original item to be updated after the end of the region.
定义对于一个明确任务是私有的一个或多个列表项,并且使得相应原始项在该区域末尾被更新。

reduction(operator:list)
Declares accumulation into the list items using the indicated associative operator. Accumulation occurs into a private copy for each list item which is then combined with the original item.
使用指定的相关运算符,定义了对列表项的累积。累积在每一个列表项的私有拷贝中发生,然后该列表项与原始项合并。

Operators for reduction (initialization values)
+ (0) | (0)
* (1) ^ (0)
- (0) && (1)
& (~0) || (0)
max (Least number in reduction list item type)
min (Largest number in reduction list item type)

Data Copying Clauses [2.9.4]
数据拷贝子句

These clauses support the copying of data values from private or threadprivate variables on one implicit task or thread to the corresponding variables on other implicit tasks or threads in the team.
这些子句支持从一个明确任务或线程的private或threadprivate变量到线程伍中其他确定任务或线程的相应变量的数据值的拷贝。

copyin(list)
Copies the value of the master thread’s threadprivate variable to the threadprivate variable of each other member of the team executing the parallel region.
从主线程的threadprivate变量到执行该并行区域的线程伍中的其他线程的threadprivate变量的值的拷贝。

copyprivate(list)
Broadcasts a value from the data environment of one implicit task to the data environments of the other implicit tasks belonging to the parallel region.
广播是从一个确定任务到属于并行区域的其他确定任务的数据环境的值的拷贝。
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 10:29 pm

Environment Variables
环境变量
Environment variables are described in section [4] of the API specification. Environment variable names are upper case, and the values assigned to them are case insensitive and may have leading and trailing white space.
环境变量名是大写的,赋给他们的值是大小写不明感的,而且可能在开头和结尾会有空格。

OMP_SCHEDULE type[,chunk]
Sets the run-sched-var ICV for the runtime schedule type and chunk size. Valid OpenMP schedule types are static, dynamic, guided, or auto. chunk is a positive integer that specifies chunk size.
为运行时调度类型和块大小设置run-sched-var ICV。可用的OpenMP调度类型有static、dynamic、guided或auto。chunk是规定块大小的正整数。

OMP_NUM_THREADS list
Sets the nthreads-var ICV for the number of threads to use for parallel regions.
为用于并行区域的线程的数量设置nthreads-var ICV。

OMP_DYNAMIC dynamic
Sets the dyn-var ICV for the dynamic adjustment of threads to use for parallel regions. Valid values for dynamic are true or false.
为并行区域使用的线程的动态调节设置dyn-var ICV。dynamic的可用值是true或false。

OMP_PROC_BIND bind
Sets the value of the global bind-var ICV. The value of this environment variable must be true or false.
设置全局bind-var ICV的值。这个环境变量的值必须是true或false。

OMP_NESTED nested
Sets the nest-var ICV to enable or to disable nested parallelism. Valid values for nested are true or false.
设置nest-var ICV来设置嵌套的并行化的能与不能。nested的可用值是true或false。

OMP_STACKSIZE size[B | K | M | G]
Sets the stacksize-var ICV that specifies the size of the stack for threads created by the OpenMP implementation. size is a positive integer that specifies stack size. If unit is not specified, size is measured in kilobytes (K).
设置stacksize-var ICV的值,规定了OpenMP实现创造的线程的栈大小。size是正整数,规定了栈大小。如果单位没有被规定,size是以千字节来计量的。

OMP_WAIT_POLICY policy
Sets the wait-policy-var ICV that controls the desired behavior of waiting threads. Valid values for policy are ACTIVE (waiting threads consume processor cycles while waiting) and PASSIVE.
设置wait-policy-var ICV,控制了等待中线程的行为。policy的可用值是ACTIVE(等待中线程占用处理器的时间片)或PASSIVE。

OMP_MAX_ACTIVE_LEVELS levels
Sets the max-active-levels-var ICV that controls the maximum number of nested active parallel regions.
设置max-active-level-var ICV ,控制了嵌套动态并行区域的最大数量。

OMP_THREAD_LIMIT limit
Sets the thread-limit-var ICV that controls the maximum number of threads participating in the OpenMP program.
设置thread-limit-var ICV,控制了OpenMP program中的线程的最大数量。
doom_ood
 
Posts: 20
Joined: Mon Feb 06, 2012 4:17 am

Previous

Return to OpenMP 3.1 API Specifications

Who is online

Users browsing this forum: No registered users and 1 guest

cron