没有合适的资源?快使用搜索试试~ 我知道了~
首页OpenMP Application Program Interface Version 4.0
OpenMP Application Program Interface Version 4.0
需积分: 11 12 下载量 119 浏览量
更新于2023-03-16
收藏 1.6MB PDF 举报
The collection of compiler directives, library routines, and environment variables described in this document collectively define the specification of the OpenMP Application Program Interface (OpenMP API) for shared-memory parallelism in C, C++ and Fortran programs. This specification provides a model for parallel programming that is portable across shared memory architectures from different vendors. Compilers from numerous vendors support the OpenMP API. More information about the OpenMP API can be found at the following web site
资源详情
资源推荐
OpenMP
Application Program
Interface
Version 4.0 - July 2013
Copyright © 1997-2013 OpenMP Architecture Review Board.
Permission to copy without fee all or part of this material is granted,
provided the OpenMP Architecture Review Board copyright notice and
the title of this document appear. Notice is given that copying is by
permission of OpenMP Architecture Review Board.
This page is intentionally blank.
i
CONTENTS
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Threading Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 OpenMP Language Terminology . . . . . . . . . . . . . . . . . . . . . 2
1.2.3 Synchronization Terminology . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.4 Tasking Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.5 Data Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.2.6 Implementation Terminology . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3 Execution Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.4.1 Structure of the OpenMP Memory Model . . . . . . . . . . . . . . . 17
1.4.2 Device Data Environments . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.4.3 The Flush Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.4.4 OpenMP Memory Consistency . . . . . . . . . . . . . . . . . . . . . . 20
1.5 OpenMP Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.6 Normative References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.7 Organization of this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2. Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.1 Directive Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.1.1 Fixed Source Form Directives . . . . . . . . . . . . . . . . . . . . . . . 27
2.1.2 Free Source Form Directives . . . . . . . . . . . . . . . . . . . . . . . . 28
2.1.3 Stand-Alone Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2 Conditional Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.2.1 Fixed Source Form Conditional Compilation Sentinels . . . . 32
ii OpenMP API • Version 4.0 - July 2013
2.2.2 Free Source Form Conditional Compilation Sentinel . . . . . . 33
2.3 Internal Control Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.3.1 ICV Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.3.2 ICV Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.3.3 Modifying and Retrieving ICV Values . . . . . . . . . . . . . . . . . . 37
2.3.4 How ICVs are Scoped . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.3.5 ICV Override Relationships . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.4 Array Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.5 parallel Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.5.1 Determining the Number of Threads
for a parallel Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5.2 Controlling OpenMP Thread Affinity . . . . . . . . . . . . . . . . . . . 49
2.6 Canonical Loop Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
2.7 Worksharing Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.7.1 Loop Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.7.2 sections Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2.7.3 single Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.7.4 workshare Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.8 SIMD Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
2.8.1 simd construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
2.8.2 declare simd construct . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
2.8.3 Loop SIMD construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
2.9 Device Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
2.9.1 target data Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
2.9.2 target Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
2.9.3 target update Construct . . . . . . . . . . . . . . . . . . . . . . . . . 81
2.9.4 declare target Directive . . . . . . . . . . . . . . . . . . . . . . . . . 83
2.9.5 teams Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
2.9.6 distribute Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
2.9.7 distribute simd Construct . . . . . . . . . . . . . . . . . . . . . . . 91
iii
2.9.8 Distribute Parallel Loop Construct . . . . . . . . . . . . . . . . . . . . 92
2.9.9 Distribute Parallel Loop SIMD Construct . . . . . . . . . . . . . . . 94
2.10 Combined Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
2.10.1 Parallel Loop Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
2.10.2 parallel sections Construct . . . . . . . . . . . . . . . . . . . . . 97
2.10.3 parallel workshare Construct . . . . . . . . . . . . . . . . . . . . 99
2.10.4 Parallel Loop SIMD Construct . . . . . . . . . . . . . . . . . . . . . . . 100
2.10.5 target teams construct . . . . . . . . . . . . . . . . . . . . . . . . . . 101
2.10.6 teams distribute Construct . . . . . . . . . . . . . . . . . . . . . . 102
2.10.7 teams distribute simd Construct . . . . . . . . . . . . . . . . . 104
2.10.8 target teams distribute Construct . . . . . . . . . . . . . . . 105
2.10.9 target teams distribute simd Construct . . . . . . . . . . 106
2.10.10 Teams Distribute Parallel Loop Construct . . . . . . . . . . . . . . 107
2.10.11 Target Teams Distribute Parallel Loop Construct . . . . . . . . . 109
2.10.12 Teams Distribute Parallel Loop SIMD Construct . . . . . . . . . 110
2.10.13 Target Teams Distribute Parallel Loop SIMD Construct . . . . 111
2.11 Tasking Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
2.11.1 task Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
2.11.2 taskyield Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
2.11.3 Task Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
2.12 Master and Synchronization Constructs . . . . . . . . . . . . . . . . . . . . . . 120
2.12.1 master Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
2.12.2 critical Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
2.12.3 barrier Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
2.12.4 taskwait Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
2.12.5 taskgroup Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
2.12.6 atomic Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
2.12.7 flush Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
2.12.8 ordered Construct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
2.13 Cancellation Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
剩余319页未读,继续阅读
nudtxiaobai
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 保险服务门店新年工作计划PPT.pptx
- 车辆安全工作计划PPT.pptx
- ipqc工作总结PPT.pptx
- 车间员工上半年工作总结PPT.pptx
- 保险公司员工的工作总结PPT.pptx
- 报价工作总结PPT.pptx
- 冲压车间实习工作总结PPT.pptx
- ktv周工作总结PPT.pptx
- 保育院总务工作计划PPT.pptx
- xx年度现代教育技术工作总结PPT.pptx
- 出纳的年终总结PPT.pptx
- 贝贝班班级工作计划PPT.pptx
- 变电值班员技术个人工作总结PPT.pptx
- 大学生读书活动策划书PPT.pptx
- 财务出纳月工作总结PPT.pptx
- 大学生“三支一扶”服务期满工作总结(2)PPT.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功