📄 22.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif;} a.at-term { font-style: italic; } </style> <title>OpenMP Directives</title> <meta name="Generator" content="ATutor"> <meta name="Keywords" content=""></head><body> <p>OpenMP directives are inserted at key locations in the source code. These directives take the form of comments in Fortran and #pragmas in C/C++. The compiler interprets the directives and creates the necessary code to parallelize the indicated tasks/regions.</p>
<p>For example, the serial code</p>
<code><pre>void main(){
double x[1000];
for (int i=0; i<1000; i++){
big_calc(x[i]);
}
}</pre></code>
<p>could be parallelized as</p>
<code><pre>void main(){
double x[1000];
<b>#pragma omp parallel for</b>
for (int i=0; i<1000; i++){
big_calc(x[i]);
}
}</pre></code>
<p>In this example, the directive causes a team of threads to be created and the loop iterations to be split up and distributed between them.</p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -