并行作业之openMP笔记(1)

1 Work-Sharing Constructs(工作共享结构)

  • A work-sharing construct divides the execution of the enclosed code region among the members of the team that encounter it.
    工作共享结构将封闭代码区域的执行划分给遇到它的团队成员。
  • Work-sharing constructs do not launch new threads.
    工作共享结构不会启动新线程。
  • There is no implied barrier upon entry to a work-sharing construct, however there is an implied barrier at the end of a work sharing construct.
    在进入工作共享结构是没有隐含的屏障,但是在工作共享结构的末尾有一个隐含的屏障。

1.1 Types of Work-Sharing Constructs(工作共享结构的类型):

  • DO/for - shares iterations of a loop across the team. Represents a type of “data parallelism”.
    DO/for - 整个团队的循环迭代。表示一种“数据并行性”。
  • SECTIONS - breaks work into separate, discrete sections. Each section is executed by a thread. Can be used to implement a type of “functional parallelism”.
    SECTIONS - 把工作分成单独的、不连续的部分。每个部分由一个线程执行。可以以用来实现一种“函数并行化”。
  • SINGLE - serializes a section of code
    SINGLE - 序列化一段代码。

1.1.1 DO/for Directive(DO/for 指令)

Purpose(目的)

  • The DO/for directive specifies that the iterations of the loop immediately following it must be executed in parallel by the team. This assumes a parallel region has already been initiated, otherwise it executes in serial on a single processor.
    DO/for 指令指定紧随其后的循环迭代必须由团队并行执行。这假定已经启动了并行区域,否则它将在单个处理器上串行执行。

Format(格式)

#pragma omp for [clause ...]  newline 
                schedule (type [,chunk]) 
                ordered
                private (list) 
                firstprivate (list) 
                lastprivate (list) 
                shared (list) 
                reduction (operator: list) 
                collapse (n) 
                nowait

   for_loop

Clauses(子句)

  • SCHEDULE: Describes how iterations of the loop are divided among the
    threads in the team. The default schedule is implementation
    dependent. For a discussion on how one type of scheduling may be more
    optimal than others, see http://openmp.org/forum/viewtopic.php?f=3&t=83.
    SCHEDULE:描述循环迭代如何在团队中的线程之间进行分配。默认的调度室依赖于实现的。有关如何使一种调度比其他更优的讨论,请参见上面链接。

  • STATIC: Loop iterations are divided into pieces of size chunk and then statically assigned to threads. If chunk is not specified, the iterations are evenly (if possible) divided contiguously among the threads.
    STATIC:循环迭代被分成小块,然后静态地分配给线程。如果没有指定chunk,则迭代是均匀地(如果可能)在线程之间连续地划分。
    static

  • DYNAMIC: Loop iterations are divided into pieces of size chunk, and dynamically scheduled among the threads; when a thread finishes one chunk, it is dynamically assigned another. The default chunk size is 1.
    DYNAMIC:循环迭代被分成小块,并在线程之间动态调度;当一个线程完成一个块时。它被动态地分配给另一个块。默认块大小为1.
    dynamic

  • GUIDED: Iterations are dynamically assigned to threads in blocks as threads request them until no blocks remain to be assigned. Similar to DYNAMIC except that the block size decreases each time a parcel of work is given to a thread.
    GUIDED:当线程请求迭代时,迭代被动态地分配给块中的线程,直到没有剩余的块需要分配为止。于DYNAMIC类似,只是每次将一个工作包分配给一个线程时,快的大小就会减少。

The size of the initial block is proportional to: number_of_iterations / number_of_threads.
初始块的大小与 number_of_iterations / number_of_threads 成比例。

Subsequent blocks are proportional to number_of_iterations_remaining / number_of_threads.
后续块与number_of_iterations_remaining / number_of_threads 成比例。</

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值