26.html

来自「国外MPI教材」· HTML 代码 · 共 28 行

HTML
28
字号
<!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>Thread ID in a Parallel Region</title>	<meta name="Generator" content="ATutor">	<meta name="Keywords" content=""></head><body> <p>Each thread can be identified by its thread number, or <em><a href="../glossary.html#rank" target="body" class="at-term">rank</a></em>, which is an integer from 0 (the master thread) to the total number of threads minus one. A thread can determine its rank by calling the routine omp_get_thread_num().</p>

<p>Threads can execute different paths of statements in the parallel region, typically by branching on the thread number.  For example:</p>

<code><pre>#pragma omp parallel
{
   myid = omp_get_thread_num();
   if (myid == 0)
     do_something();
   else
      do_something_else(myid);
}</pre></code>
  
<p>The parallel sections construct discussed in Section 3.11, OpenMP Synchronization Constructs, is another way of assigning different blocks of code to different threads.</p></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?