PageRenderTime 27ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/list/openmp.html

https://github.com/clawpack/clawpack.github.com
HTML | 250 lines | 238 code | 11 blank | 1 comment | 0 complexity | 732d14972bb08f9971eaa076c52631bf MD5 | raw file
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Using OpenMP &#8212; Clawpack dev documentation</title>
  6. <link rel="stylesheet" href="_static/flasky.css" type="text/css" />
  7. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/base.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/layout.css" type="text/css" />
  10. <link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
  11. <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  12. <script src="_static/jquery.js"></script>
  13. <script src="_static/underscore.js"></script>
  14. <script src="_static/doctools.js"></script>
  15. <script src="_static/language_data.js"></script>
  16. <script async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  17. <link rel="shortcut icon" href="_static/clawicon.ico"/>
  18. <link rel="author" title="About these documents" href="about.html" />
  19. <link rel="index" title="Index" href="genindex.html" />
  20. <link rel="search" title="Search" href="search.html" />
  21. <link rel="next" title="Timing Statistics" href="timing.html" />
  22. <link rel="prev" title="User files required for the Fortran code" href="user_routines.html" />
  23. </head><body>
  24. <div id="main-wrapper" class="sphinx">
  25. <div id="header-wrapper">
  26. <section id="header">
  27. <!-- <h1><a href="http://clawpack.org/">Clawpack</a></h1> -->
  28. <h1><a href="http://clawpack.org/">Clawpack-5</a></h1>
  29. <nav>
  30. <ul>
  31. <li>
  32. <a href="contents.html">Docs</a>
  33. </li>
  34. <li>
  35. <a href="installing.html">Install</a>
  36. </li>
  37. <li>
  38. <a class="" href="http://clawpack.org/gallery">Gallery</a>
  39. </li>
  40. <li>
  41. <a class="" href="community.html">Community</a>
  42. </li>
  43. <li>
  44. <a class="active" href="http://github.com/clawpack">Source</a>
  45. </li>
  46. <li>
  47. <a class="" href="developers.html">Develop</a>
  48. </li>
  49. </ul>
  50. </nav>
  51. </section>
  52. <div class="decoration"></div>
  53. </div>
  54. <div class="related" role="navigation" aria-label="related navigation">
  55. <h3>Navigation</h3>
  56. <ul>
  57. <li class="right" style="margin-right: 10px">
  58. <a href="genindex.html" title="General Index"
  59. accesskey="I">index</a></li>
  60. <li class="right" >
  61. <a href="py-modindex.html" title="Python Module Index"
  62. >modules</a> |</li>
  63. <li class="right" >
  64. <a href="timing.html" title="Timing Statistics"
  65. accesskey="N">next</a> |</li>
  66. <li class="right" >
  67. <a href="user_routines.html" title="User files required for the Fortran code"
  68. accesskey="P">previous</a> |</li>
  69. <li class="nav-item nav-item-0"><a href="contents.html">Clawpack dev documentation</a> &#187;</li>
  70. </ul>
  71. </div>
  72. <div class="document">
  73. <div class="documentwrapper">
  74. <div class="bodywrapper">
  75. <div class="body" role="main">
  76. <div class="section" id="using-openmp">
  77. <span id="openmp"></span><h1>Using OpenMP<a class="headerlink" href="#using-openmp" title="Permalink to this headline"></a></h1>
  78. <p>The Clawpack Fortran Classic 3d code, AMRClaw 2d and 3d code,
  79. and GeoClaw codes include
  80. OpenMP directives for making use of multicore shared memory machines.</p>
  81. <p><strong>Note:</strong> Versions of gfortran before 4.6 are known to have OpenMP bugs.
  82. You should use a recent version or a different compiler if you want to use
  83. OpenMP.</p>
  84. <p>To invoke OpenMP you need to compile the entire code with appropriate
  85. compiler flags (see <a class="reference internal" href="fortran_compilers.html#fortran-compilers"><span class="std std-ref">Fortran Compilers</span></a>). For example, with gfortran
  86. and the bash shell you could do:</p>
  87. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">FFLAGS</span><span class="o">=</span><span class="s1">&#39;-O2 -fopenmp&#39;</span> <span class="c1"># or hardwire FFLAGS in the Makefile</span>
  88. <span class="n">make</span> <span class="n">new</span>
  89. </pre></div>
  90. </div>
  91. <p>in an application directory, which should recompile all of the library
  92. routines as well.</p>
  93. <p>Then you may want to specify how many threads OpenMP should split the work
  94. between, e.g.</p>
  95. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">OMP_NUM_THREADS</span><span class="o">=</span><span class="mi">2</span>
  96. </pre></div>
  97. </div>
  98. <p>If you do not set this environment variable some default for your system
  99. will be used.</p>
  100. <p>You may also need to increase the stack size if the code bombs for no
  101. apparent reason (and no useful error message):</p>
  102. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">OMP_STACKSIZE</span><span class="o">=</span><span class="mi">16</span><span class="n">M</span>
  103. </pre></div>
  104. </div>
  105. <p>and also:</p>
  106. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ulimit</span> <span class="o">-</span><span class="n">s</span> <span class="n">unlimited</span>
  107. </pre></div>
  108. </div>
  109. <p>On a Mac this isnt allowed and the best you can do is</p>
  110. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ulimit</span> <span class="o">-</span><span class="n">s</span> <span class="n">hard</span>
  111. </pre></div>
  112. </div>
  113. <p>To stop using OpenMP you could do:</p>
  114. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="n">FFLAGS</span><span class="o">=-</span><span class="n">O2</span> <span class="c1"># or hardwire FFLAGS in the Makefile</span>
  115. <span class="n">make</span> <span class="n">new</span>
  116. </pre></div>
  117. </div>
  118. <div class="section" id="using-openmp-with-amr">
  119. <span id="openmp-amr"></span><h2>Using OpenMP with AMR<a class="headerlink" href="#using-openmp-with-amr" title="Permalink to this headline"></a></h2>
  120. <p>The code in AMRClaw and GeoClaw is parallelized by splitting the list of
  121. patches that must be advanced in time between threads, and then each grid
  122. patch is handled by a single thread. For this reason good performance will
  123. be seen only when there are a sufficiently large number of patches at each
  124. level relative to the number of threads. For this reason it is recommended
  125. that the parameter <cite>max1d</cite> be set to 60 in the modules</p>
  126. <ul class="simple">
  127. <li><p><cite>$CLAW/amrclaw/src/2d/amr_module.f90</cite></p></li>
  128. <li><p><cite>$CLAW/amrclaw/src/3d/amr_module.f90</cite></p></li>
  129. </ul>
  130. <p>when OpenMP is used. This limits the size of any patch to have at most
  131. <cite>max1d</cite> grid cells in each direction. If OpenMP is not used, a larger value
  132. of <cite>max1d</cite> might give somewhat better performance since there is less
  133. overhead associated with passing boundary values in ghost cells and other
  134. per-patch work. However, this is generally negligible and <cite>max1d=60</cite> is the
  135. default value set in the code. If you do change this value, remember to
  136. recompile everything via:</p>
  137. <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">new</span>
  138. </pre></div>
  139. </div>
  140. </div>
  141. <div class="section" id="fixed-grid-output-in-geoclaw">
  142. <span id="openmp-fixedgrids"></span><h2>Fixed grid output in GeoClaw<a class="headerlink" href="#fixed-grid-output-in-geoclaw" title="Permalink to this headline"></a></h2>
  143. <p>The original fixed grid output routines are not thread safe and so OpenMP
  144. should not be used if you want to produce output on fixed grids.</p>
  145. <p>The newer fgmax routines that keep track of maxima on fixed grids should be
  146. thread safe, see <a class="reference internal" href="fgmax.html#fgmax"><span class="std std-ref">Fixed grid monitoring</span></a>.</p>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  153. <div class="sphinxsidebarwrapper">
  154. <p><a href="http://clawpack.org/">
  155. <img class="logo" src= "_static/clawlogo.jpg" alt="Logo"/>
  156. </a>
  157. <h2>Version dev</h2>
  158. </p>
  159. <h3><a href="contents.html">Table of Contents</a></h3>
  160. <ul>
  161. <li><a class="reference internal" href="#">Using OpenMP</a><ul>
  162. <li><a class="reference internal" href="#using-openmp-with-amr">Using OpenMP with AMR</a></li>
  163. <li><a class="reference internal" href="#fixed-grid-output-in-geoclaw">Fixed grid output in GeoClaw</a></li>
  164. </ul>
  165. </li>
  166. </ul>
  167. <h3>Related Topics</h3>
  168. <ul>
  169. <li><a href="contents.html">Documentation overview</a><ul>
  170. <li>Previous: <a href="user_routines.html" title="previous chapter">User files required for the Fortran code</a></li>
  171. <li>Next: <a href="timing.html" title="next chapter">Timing Statistics</a></li>
  172. </ul></li>
  173. </ul>
  174. <div class="widget navlinks">
  175. <h3>This Page</h3>
  176. <ul class="this-page-menu">
  177. <li><a href="_sources/openmp.rst.txt"
  178. rel="nofollow"
  179. target="_blank">Source .rst</a></li>
  180. <li><a href="https://github.com/clawpack/doc/blob/dev/doc/openmp.rst"
  181. rel="nofollow"
  182. target="_blank">Source on GitHub</a></li>
  183. <li><a href="https://github.com/clawpack/doc/commits/dev/doc/openmp.rst"
  184. rel="nofollow"
  185. target="_blank">History</a></li>
  186. <li><a href="https://github.com/clawpack/doc/edit/dev/doc/openmp.rst"
  187. rel="nofollow"
  188. target="_blank">Suggest Edits</a></li>
  189. <li><a href="https://github.com/clawpack/doc/issues/new/choose"
  190. rel="nofollow"
  191. target="_blank">Raise an Issue</a></li>
  192. </ul>
  193. </div>
  194. <div id="searchbox" style="display: none" role="search">
  195. <h3 id="searchlabel">Quick search</h3>
  196. <div class="searchformwrapper">
  197. <form class="search" action="search.html" method="get">
  198. <input type="text" name="q" aria-labelledby="searchlabel" />
  199. <input type="submit" value="Go" />
  200. </form>
  201. </div>
  202. </div>
  203. <script>$('#searchbox').show(0);</script>
  204. <h4>Latest Version</h4>
  205. <ul>
  206. <li><a href="../dev/openmp.html">dev</a></li>
  207. <li><a href="../v5.7.0/openmp.html">v5.7.0</a></li>
  208. </ul>
  209. <h4>Older Versions</h4>
  210. <ul>
  211. <li><a href="openmp.html">list</a></li>
  212. <li><a href="../v5.1.0/openmp.html">v5.1.0</a></li>
  213. <li><a href="../v5.2.0/openmp.html">v5.2.0</a></li>
  214. <li><a href="../v5.2.1/openmp.html">v5.2.1</a></li>
  215. <li><a href="../v5.3.0/openmp.html">v5.3.0</a></li>
  216. <li><a href="../v5.3.1/openmp.html">v5.3.1</a></li>
  217. <li><a href="../v5.4.0/openmp.html">v5.4.0</a></li>
  218. <li><a href="../v5.4.1/openmp.html">v5.4.1</a></li>
  219. <li><a href="../v5.5.0/openmp.html">v5.5.0</a></li>
  220. <li><a href="../v5.6.0/openmp.html">v5.6.0</a></li>
  221. </ul>
  222. </div>
  223. </div>
  224. <div class="clearer"></div>
  225. </div>
  226. <div class="footer">
  227. &copy; Copyright CC-BY 2020, The Clawpack Development Team.
  228. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
  229. </div>
  230. <script>
  231. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  232. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  233. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  234. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  235. ga('create', 'UA-44811544-1', 'auto');
  236. ga('send', 'pageview');
  237. </script>
  238. </body>
  239. </html>