[68532f3] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
| 6 | <head> |
---|
| 7 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
| 8 | |
---|
| 9 | <title>3.7. OpenCL model evaluator — Sasmodels</title> |
---|
| 10 | |
---|
| 11 | <link rel="stylesheet" href="../_static/haiku-site.css" type="text/css" /> |
---|
| 12 | <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
---|
| 13 | |
---|
| 14 | <script type="text/javascript"> |
---|
| 15 | var DOCUMENTATION_OPTIONS = { |
---|
| 16 | URL_ROOT: '../', |
---|
| 17 | VERSION: '0.9', |
---|
| 18 | COLLAPSE_INDEX: false, |
---|
| 19 | FILE_SUFFIX: '.html', |
---|
| 20 | HAS_SOURCE: true |
---|
| 21 | }; |
---|
| 22 | </script> |
---|
| 23 | <script type="text/javascript" src="../_static/jquery.js"></script> |
---|
| 24 | <script type="text/javascript" src="../_static/underscore.js"></script> |
---|
| 25 | <script type="text/javascript" src="../_static/doctools.js"></script> |
---|
| 26 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
---|
| 27 | <link rel="top" title="Sasmodels" href="../index.html" /> |
---|
| 28 | <link rel="up" title="3. Reference" href="index.html" /> |
---|
| 29 | <link rel="next" title="3.8. Ctypes model evaluator" href="kerneldll.html" /> |
---|
| 30 | <link rel="prev" title="3.6. Model parser" href="generate.html" /> |
---|
| 31 | </head> |
---|
| 32 | <body> |
---|
| 33 | <div class="header"><h1 class="heading"><a href="../index.html"> |
---|
| 34 | <span>Home</span></a></h1> |
---|
| 35 | <h2 class="heading"><span>3.7. OpenCL model evaluator</span></h2> |
---|
| 36 | </div> |
---|
| 37 | <div class="topnav"> |
---|
| 38 | |
---|
| 39 | <p> |
---|
| 40 | «  <a href="generate.html">3.6. Model parser</a> |
---|
| 41 |   ::   |
---|
| 42 | <a class="uplink" href="../index.html">Contents</a> |
---|
| 43 |   ::   |
---|
| 44 | <a href="kerneldll.html">3.8. Ctypes model evaluator</a>  Â» |
---|
| 45 | </p> |
---|
| 46 | |
---|
| 47 | </div> |
---|
| 48 | <div class="content"> |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | <div class="section" id="opencl-model-evaluator"> |
---|
| 52 | <h1>3.7. OpenCL model evaluator<a class="headerlink" href="#opencl-model-evaluator" title="Permalink to this headline">¶</a></h1> |
---|
| 53 | <div class="section" id="module-sasmodels.kernelcl"> |
---|
| 54 | <span id="sasmodels-kernelcl"></span><h2>3.7.1. <a class="reference internal" href="#module-sasmodels.kernelcl" title="sasmodels.kernelcl"><tt class="xref py py-mod docutils literal"><span class="pre">sasmodels.kernelcl</span></tt></a><a class="headerlink" href="#module-sasmodels.kernelcl" title="Permalink to this headline">¶</a></h2> |
---|
| 55 | <p>GPU support through OpenCL</p> |
---|
| 56 | <p>There should be a single GPU environment running on the system. This |
---|
| 57 | environment is constructed on the first call to <tt class="xref py py-func docutils literal"><span class="pre">env()</span></tt>, and the |
---|
| 58 | same environment is returned on each call.</p> |
---|
| 59 | <p>After retrieving the environment, the next step is to create the kernel. |
---|
| 60 | This is done with a call to <tt class="xref py py-meth docutils literal"><span class="pre">GpuEnvironment.make_kernel()</span></tt>, which |
---|
| 61 | returns the type of data used by the kernel.</p> |
---|
| 62 | <p>Next a <tt class="xref py py-class docutils literal"><span class="pre">GpuData</span></tt> object should be created with the correct kind |
---|
| 63 | of data. This data object can be used by multiple kernels, for example, |
---|
| 64 | if the target model is a weighted sum of multiple kernels. The data |
---|
| 65 | should include any extra evaluation points required to compute the proper |
---|
| 66 | data smearing. This need not match the square grid for 2D data if there |
---|
| 67 | is an index saying which q points are active.</p> |
---|
| 68 | <p>Together the GpuData, the program, and a device form a <a class="reference internal" href="#sasmodels.kernelcl.GpuKernel" title="sasmodels.kernelcl.GpuKernel"><tt class="xref py py-class docutils literal"><span class="pre">GpuKernel</span></tt></a>. |
---|
| 69 | This kernel is used during fitting, receiving new sets of parameters and |
---|
| 70 | evaluating them. The output value is stored in an output buffer on the |
---|
| 71 | devices, where it can be combined with other structure factors and form |
---|
| 72 | factors and have instrumental resolution effects applied.</p> |
---|
| 73 | <dl class="class"> |
---|
| 74 | <dt id="sasmodels.kernelcl.GpuEnvironment"> |
---|
| 75 | <em class="property">class </em><tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">GpuEnvironment</tt><a class="headerlink" href="#sasmodels.kernelcl.GpuEnvironment" title="Permalink to this definition">¶</a></dt> |
---|
| 76 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
| 77 | <p>GPU context, with possibly many devices, and one queue per device.</p> |
---|
| 78 | <dl class="method"> |
---|
| 79 | <dt id="sasmodels.kernelcl.GpuEnvironment.compile_program"> |
---|
| 80 | <tt class="descname">compile_program</tt><big>(</big><em>name</em>, <em>source</em>, <em>dtype</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuEnvironment.compile_program" title="Permalink to this definition">¶</a></dt> |
---|
| 81 | <dd></dd></dl> |
---|
| 82 | |
---|
| 83 | <dl class="method"> |
---|
| 84 | <dt id="sasmodels.kernelcl.GpuEnvironment.release_program"> |
---|
| 85 | <tt class="descname">release_program</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuEnvironment.release_program" title="Permalink to this definition">¶</a></dt> |
---|
| 86 | <dd></dd></dl> |
---|
| 87 | |
---|
| 88 | </dd></dl> |
---|
| 89 | |
---|
| 90 | <dl class="class"> |
---|
| 91 | <dt id="sasmodels.kernelcl.GpuInput"> |
---|
| 92 | <em class="property">class </em><tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">GpuInput</tt><big>(</big><em>q_vectors</em>, <em>dtype=dtype('float32')</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuInput" title="Permalink to this definition">¶</a></dt> |
---|
| 93 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
| 94 | <p>Make q data available to the gpu.</p> |
---|
| 95 | <p><em>q_vectors</em> is a list of q vectors, which will be <em>[q]</em> for 1-D data, |
---|
| 96 | and <em>[qx, qy]</em> for 2-D data. Internally, the vectors will be reallocated |
---|
| 97 | to get the best performance on OpenCL, which may involve shifting and |
---|
| 98 | stretching the array to better match the memory architecture. Additional |
---|
| 99 | points will be evaluated with <em>q=1e-3</em>.</p> |
---|
| 100 | <p><em>dtype</em> is the data type for the q vectors. The data type should be |
---|
| 101 | set to match that of the kernel, which is an attribute of |
---|
| 102 | <tt class="xref py py-class docutils literal"><span class="pre">GpuProgram</span></tt>. Note that not all kernels support double |
---|
| 103 | precision, so even if the program was created for double precision, |
---|
| 104 | the <em>GpuProgram.dtype</em> may be single precision.</p> |
---|
| 105 | <p>Call <a class="reference internal" href="#sasmodels.kernelcl.GpuInput.release" title="sasmodels.kernelcl.GpuInput.release"><tt class="xref py py-meth docutils literal"><span class="pre">release()</span></tt></a> when complete. Even if not called directly, the |
---|
| 106 | buffer will be released when the data object is freed.</p> |
---|
| 107 | <dl class="method"> |
---|
| 108 | <dt id="sasmodels.kernelcl.GpuInput.release"> |
---|
| 109 | <tt class="descname">release</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuInput.release" title="Permalink to this definition">¶</a></dt> |
---|
| 110 | <dd></dd></dl> |
---|
| 111 | |
---|
| 112 | </dd></dl> |
---|
| 113 | |
---|
| 114 | <dl class="class"> |
---|
| 115 | <dt id="sasmodels.kernelcl.GpuKernel"> |
---|
| 116 | <em class="property">class </em><tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">GpuKernel</tt><big>(</big><em>kernel</em>, <em>info</em>, <em>q_input</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuKernel" title="Permalink to this definition">¶</a></dt> |
---|
| 117 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
| 118 | <p>Callable SAS kernel.</p> |
---|
| 119 | <p><em>kernel</em> is the GpuKernel object to call.</p> |
---|
| 120 | <p><em>info</em> is the module information</p> |
---|
| 121 | <p><em>q_input</em> is the DllInput q vectors at which the kernel should be |
---|
| 122 | evaluated.</p> |
---|
| 123 | <p>The resulting call method takes the <em>pars</em>, a list of values for |
---|
| 124 | the fixed parameters to the kernel, and <em>pd_pars</em>, a list of (value,weight) |
---|
| 125 | vectors for the polydisperse parameters. <em>cutoff</em> determines the |
---|
| 126 | integration limits: any points with combined weight less than <em>cutoff</em> |
---|
| 127 | will not be calculated.</p> |
---|
| 128 | <p>Call <a class="reference internal" href="#sasmodels.kernelcl.GpuKernel.release" title="sasmodels.kernelcl.GpuKernel.release"><tt class="xref py py-meth docutils literal"><span class="pre">release()</span></tt></a> when done with the kernel instance.</p> |
---|
| 129 | <dl class="method"> |
---|
| 130 | <dt id="sasmodels.kernelcl.GpuKernel.release"> |
---|
| 131 | <tt class="descname">release</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuKernel.release" title="Permalink to this definition">¶</a></dt> |
---|
| 132 | <dd></dd></dl> |
---|
| 133 | |
---|
| 134 | </dd></dl> |
---|
| 135 | |
---|
| 136 | <dl class="class"> |
---|
| 137 | <dt id="sasmodels.kernelcl.GpuModel"> |
---|
| 138 | <em class="property">class </em><tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">GpuModel</tt><big>(</big><em>source</em>, <em>info</em>, <em>dtype=dtype('float32')</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuModel" title="Permalink to this definition">¶</a></dt> |
---|
| 139 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
| 140 | <p>GPU wrapper for a single model.</p> |
---|
| 141 | <p><em>source</em> and <em>info</em> are the model source and interface as returned |
---|
| 142 | from <tt class="xref py py-func docutils literal"><span class="pre">gen.make()</span></tt>.</p> |
---|
| 143 | <p><em>dtype</em> is the desired model precision. Any numpy dtype for single |
---|
| 144 | or double precision floats will do, such as ‘f’, ‘float32’ or ‘single’ |
---|
| 145 | for single and ‘d’, ‘float64’ or ‘double’ for double. Double precision |
---|
| 146 | is an optional extension which may not be available on all devices.</p> |
---|
| 147 | <dl class="method"> |
---|
| 148 | <dt id="sasmodels.kernelcl.GpuModel.make_input"> |
---|
| 149 | <tt class="descname">make_input</tt><big>(</big><em>q_vectors</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuModel.make_input" title="Permalink to this definition">¶</a></dt> |
---|
| 150 | <dd><p>Make q input vectors available to the model.</p> |
---|
| 151 | <p>Note that each model needs its own q vector even if the case of |
---|
| 152 | mixture models because some models may be OpenCL, some may be |
---|
| 153 | ctypes and some may be pure python.</p> |
---|
| 154 | </dd></dl> |
---|
| 155 | |
---|
| 156 | <dl class="method"> |
---|
| 157 | <dt id="sasmodels.kernelcl.GpuModel.release"> |
---|
| 158 | <tt class="descname">release</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.GpuModel.release" title="Permalink to this definition">¶</a></dt> |
---|
| 159 | <dd></dd></dl> |
---|
| 160 | |
---|
| 161 | </dd></dl> |
---|
| 162 | |
---|
| 163 | <dl class="function"> |
---|
| 164 | <dt id="sasmodels.kernelcl.compile_model"> |
---|
| 165 | <tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">compile_model</tt><big>(</big><em>context</em>, <em>source</em>, <em>dtype</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.compile_model" title="Permalink to this definition">¶</a></dt> |
---|
| 166 | <dd><p>Build a model to run on the gpu.</p> |
---|
| 167 | <p>Returns the compiled program and its type. The returned type will |
---|
| 168 | be float32 even if the desired type is float64 if any of the |
---|
| 169 | devices in the context do not support the cl_khr_fp64 extension.</p> |
---|
| 170 | </dd></dl> |
---|
| 171 | |
---|
| 172 | <dl class="function"> |
---|
| 173 | <dt id="sasmodels.kernelcl.environment"> |
---|
| 174 | <tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">environment</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.environment" title="Permalink to this definition">¶</a></dt> |
---|
| 175 | <dd><p>Returns a singleton <a class="reference internal" href="#sasmodels.kernelcl.GpuEnvironment" title="sasmodels.kernelcl.GpuEnvironment"><tt class="xref py py-class docutils literal"><span class="pre">GpuEnvironment</span></tt></a>.</p> |
---|
| 176 | <p>This provides an OpenCL context and one queue per device.</p> |
---|
| 177 | </dd></dl> |
---|
| 178 | |
---|
| 179 | <dl class="function"> |
---|
| 180 | <dt id="sasmodels.kernelcl.get_warp"> |
---|
| 181 | <tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">get_warp</tt><big>(</big><em>kernel</em>, <em>queue</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.get_warp" title="Permalink to this definition">¶</a></dt> |
---|
| 182 | <dd><p>Return the size of an execution batch for <em>kernel</em> running on <em>queue</em>.</p> |
---|
| 183 | </dd></dl> |
---|
| 184 | |
---|
| 185 | <dl class="function"> |
---|
| 186 | <dt id="sasmodels.kernelcl.has_double"> |
---|
| 187 | <tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">has_double</tt><big>(</big><em>device</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.has_double" title="Permalink to this definition">¶</a></dt> |
---|
| 188 | <dd><p>Return true if device supports double precision.</p> |
---|
| 189 | </dd></dl> |
---|
| 190 | |
---|
| 191 | <dl class="function"> |
---|
| 192 | <dt id="sasmodels.kernelcl.make_result"> |
---|
| 193 | <tt class="descclassname">sasmodels.kernelcl.</tt><tt class="descname">make_result</tt><big>(</big><em>self</em>, <em>size</em><big>)</big><a class="headerlink" href="#sasmodels.kernelcl.make_result" title="Permalink to this definition">¶</a></dt> |
---|
| 194 | <dd></dd></dl> |
---|
| 195 | |
---|
| 196 | </div> |
---|
| 197 | </div> |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | </div> |
---|
| 201 | <div class="bottomnav"> |
---|
| 202 | |
---|
| 203 | <p> |
---|
| 204 | «  <a href="generate.html">3.6. Model parser</a> |
---|
| 205 |   ::   |
---|
| 206 | <a class="uplink" href="../index.html">Contents</a> |
---|
| 207 |   ::   |
---|
| 208 | <a href="kerneldll.html">3.8. Ctypes model evaluator</a>  Â» |
---|
| 209 | </p> |
---|
| 210 | |
---|
| 211 | </div> |
---|
| 212 | |
---|
| 213 | <div class="footer"> |
---|
| 214 | © Copyright 2014, sasview team. |
---|
| 215 | Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. |
---|
| 216 | </div> |
---|
| 217 | </body> |
---|
| 218 | </html> |
---|