Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > nonfree-release > by-pkgid > 9e74824375d82b5e6c4b187b256e94f6 > files > 147

python-pycuda-2014.1-6.mga5.nonfree.x86_64.rpm

<!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">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Built-in Utilities &mdash; PyCUDA 2014.1 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '2014.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="PyCUDA 2014.1 documentation" href="index.html" />
    <link rel="next" title="OpenGL" href="gl.html" />
    <link rel="prev" title="Device Interface" href="driver.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="gl.html" title="OpenGL"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="driver.html" title="Device Interface"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">PyCUDA 2014.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="built-in-utilities">
<h1>Built-in Utilities<a class="headerlink" href="#built-in-utilities" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-pycuda.autoinit">
<span id="automatic-initialization"></span><h2>Automatic Initialization<a class="headerlink" href="#module-pycuda.autoinit" title="Permalink to this headline">¶</a></h2>
<p>The module <a class="reference internal" href="#module-pycuda.autoinit" title="pycuda.autoinit"><tt class="xref py py-mod docutils literal"><span class="pre">pycuda.autoinit</span></tt></a>,  when imported, automatically performs
all the steps necessary to get CUDA ready for submission of compute kernels.
It uses <a class="reference internal" href="#pycuda.tools.make_default_context" title="pycuda.tools.make_default_context"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.tools.make_default_context()</span></tt></a> to create a compute context.</p>
<dl class="data">
<dt id="pycuda.autoinit.device">
<tt class="descclassname">pycuda.autoinit.</tt><tt class="descname">device</tt><a class="headerlink" href="#pycuda.autoinit.device" title="Permalink to this definition">¶</a></dt>
<dd><p>An instance of <a class="reference internal" href="driver.html#pycuda.driver.Device" title="pycuda.driver.Device"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.Device</span></tt></a> that was used for automatic
initialization.</p>
</dd></dl>

<dl class="data">
<dt id="pycuda.autoinit.context">
<tt class="descclassname">pycuda.autoinit.</tt><tt class="descname">context</tt><a class="headerlink" href="#pycuda.autoinit.context" title="Permalink to this definition">¶</a></dt>
<dd><p>A default-constructed instance of <a class="reference internal" href="driver.html#pycuda.driver.Context" title="pycuda.driver.Context"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.Context</span></tt></a>
on <a class="reference internal" href="#pycuda.autoinit.device" title="pycuda.autoinit.device"><tt class="xref py py-data docutils literal"><span class="pre">device</span></tt></a>. This context is created by calling
<a class="reference internal" href="#pycuda.tools.make_default_context" title="pycuda.tools.make_default_context"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.tools.make_default_context()</span></tt></a>.</p>
</dd></dl>

</div>
<div class="section" id="module-pycuda.tools">
<span id="choice-of-device"></span><h2>Choice of Device<a class="headerlink" href="#module-pycuda.tools" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="pycuda.tools.make_default_context">
<tt class="descclassname">pycuda.tools.</tt><tt class="descname">make_default_context</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.make_default_context" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="driver.html#pycuda.driver.Context" title="pycuda.driver.Context"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.Context</span></tt></a> instance chosen according to the
following rules:</p>
<blockquote>
<div><ul class="simple">
<li>If the environment variable <span class="target" id="index-0"></span><tt class="xref std std-envvar docutils literal"><span class="pre">CUDA_DEVICE</span></tt> is set, its integer
value is used as the device number.</li>
<li>If the file <tt class="file docutils literal"><span class="pre">.cuda-device</span></tt> is present in the user&#8217;s home directory,
the integer value of its contents is used as the device number.</li>
<li>Otherwise, all available CUDA devices are tried in a round-robin fashion.</li>
</ul>
</div></blockquote>
<p>An error is raised if this does not lead to a usable context.</p>
</dd></dl>

<dl class="function">
<dt id="pycuda.tools.get_default_device">
<tt class="descclassname">pycuda.tools.</tt><tt class="descname">get_default_device</tt><big>(</big><em>default=0</em><big>)</big><a class="headerlink" href="#pycuda.tools.get_default_device" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated. Use <a class="reference internal" href="#pycuda.tools.make_default_context" title="pycuda.tools.make_default_context"><tt class="xref py py-func docutils literal"><span class="pre">make_default_context()</span></tt></a>.</p>
<p>Return a <a class="reference internal" href="driver.html#pycuda.driver.Device" title="pycuda.driver.Device"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.Device</span></tt></a> instance chosen according to the
following rules:</p>
<blockquote>
<div><ul class="simple">
<li>If the environment variable <span class="target" id="index-1"></span><tt class="xref std std-envvar docutils literal"><span class="pre">CUDA_DEVICE</span></tt> is set, its integer
value is used as the device number.</li>
<li>If the file <tt class="file docutils literal"><span class="pre">.cuda-device</span></tt> is present in the user&#8217;s home directory,
the integer value of its contents is used as the device number.</li>
<li>Otherwise, <cite>default</cite> is used as the device number.</li>
</ul>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="kernel-caching">
<h2>Kernel Caching<a class="headerlink" href="#kernel-caching" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="pycuda.tools.context_dependent_memoize">
<tt class="descclassname">pycuda.tools.</tt><tt class="descname">context_dependent_memoize</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#pycuda.tools.context_dependent_memoize" title="Permalink to this definition">¶</a></dt>
<dd><p>This decorator caches the result of the decorated function, <em>if</em> a
subsequent occurs in the same <a class="reference internal" href="driver.html#pycuda.driver.Context" title="pycuda.driver.Context"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.Context</span></tt></a>.
This is useful for caching of kernels.</p>
</dd></dl>

<dl class="function">
<dt id="pycuda.tools.clear_context_caches">
<tt class="descclassname">pycuda.tools.</tt><tt class="descname">clear_context_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.clear_context_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>Empties all context-dependent memoization caches. Also releases
all held reference contexts. If it is important to you that the
program detaches from its context, you might need to call this
function to free all remaining references to your context.</p>
</dd></dl>

</div>
<div class="section" id="testing">
<h2>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="pycuda.tools.mark_cuda_test">
<tt class="descclassname">pycuda.tools.</tt><tt class="descname">mark_cuda_test</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#pycuda.tools.mark_cuda_test" title="Permalink to this definition">¶</a></dt>
<dd><p>This function, meant for use with <tt class="xref py py-mod docutils literal"><span class="pre">py.test</span></tt>, will mark <em>func</em> with a
&#8220;cuda&#8221; tag and make sure it has a CUDA context available when invoked.</p>
</dd></dl>

</div>
<div class="section" id="device-metadata-and-occupancy">
<h2>Device Metadata and Occupancy<a class="headerlink" href="#device-metadata-and-occupancy" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pycuda.tools.DeviceData">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">DeviceData</tt><big>(</big><em>dev=None</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData" title="Permalink to this definition">¶</a></dt>
<dd><p>Gives access to more information on a device than is available through
<a class="reference internal" href="driver.html#pycuda.driver.Device.get_attribute" title="pycuda.driver.Device.get_attribute"><tt class="xref py py-meth docutils literal"><span class="pre">pycuda.driver.Device.get_attribute()</span></tt></a>. If <cite>dev</cite> is <cite>None</cite>, it defaults
to the device returned by <a class="reference internal" href="driver.html#pycuda.driver.Context.get_device" title="pycuda.driver.Context.get_device"><tt class="xref py py-meth docutils literal"><span class="pre">pycuda.driver.Context.get_device()</span></tt></a>.</p>
<dl class="attribute">
<dt id="pycuda.tools.DeviceData.max_threads">
<tt class="descname">max_threads</tt><a class="headerlink" href="#pycuda.tools.DeviceData.max_threads" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.warp_size">
<tt class="descname">warp_size</tt><a class="headerlink" href="#pycuda.tools.DeviceData.warp_size" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.warps_per_mp">
<tt class="descname">warps_per_mp</tt><a class="headerlink" href="#pycuda.tools.DeviceData.warps_per_mp" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.thread_blocks_per_mp">
<tt class="descname">thread_blocks_per_mp</tt><a class="headerlink" href="#pycuda.tools.DeviceData.thread_blocks_per_mp" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.registers">
<tt class="descname">registers</tt><a class="headerlink" href="#pycuda.tools.DeviceData.registers" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.shared_memory">
<tt class="descname">shared_memory</tt><a class="headerlink" href="#pycuda.tools.DeviceData.shared_memory" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.smem_granularity">
<tt class="descname">smem_granularity</tt><a class="headerlink" href="#pycuda.tools.DeviceData.smem_granularity" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of threads that participate in banked, simultaneous access
to shared memory.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceData.smem_alloc_granularity">
<tt class="descname">smem_alloc_granularity</tt><a class="headerlink" href="#pycuda.tools.DeviceData.smem_alloc_granularity" title="Permalink to this definition">¶</a></dt>
<dd><p>The size of the smallest possible (non-empty) shared memory allocation.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceData.align_bytes">
<tt class="descname">align_bytes</tt><big>(</big><em>word_size=4</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData.align_bytes" title="Permalink to this definition">¶</a></dt>
<dd><p>The distance between global memory base addresses that
allow accesses of word-size <cite>word_size</cite> bytes to get coalesced.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceData.align">
<tt class="descname">align</tt><big>(</big><em>bytes</em>, <em>word_size=4</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData.align" title="Permalink to this definition">¶</a></dt>
<dd><p>Round up <cite>bytes</cite> to the next alignment boundary as given by <a class="reference internal" href="#pycuda.tools.DeviceData.align_bytes" title="pycuda.tools.DeviceData.align_bytes"><tt class="xref py py-meth docutils literal"><span class="pre">align_bytes()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceData.align_words">
<tt class="descname">align_words</tt><big>(</big><em>word_size</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData.align_words" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <cite>self.align_bytes(word_size)/word_size</cite>, while checking that the division
did not yield a remainder.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceData.align_dtype">
<tt class="descname">align_dtype</tt><big>(</big><em>elements</em>, <em>dtype_size</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData.align_dtype" title="Permalink to this definition">¶</a></dt>
<dd><p>Round up <cite>elements</cite> to the next alignment boundary
as given by <a class="reference internal" href="#pycuda.tools.DeviceData.align_bytes" title="pycuda.tools.DeviceData.align_bytes"><tt class="xref py py-meth docutils literal"><span class="pre">align_bytes()</span></tt></a>, where each element is assumed to be
<cite>dtype_size</cite> bytes large.</p>
</dd></dl>

<dl class="staticmethod">
<dt id="pycuda.tools.DeviceData.make_valid_tex_channel_count">
<em class="property">static </em><tt class="descname">make_valid_tex_channel_count</tt><big>(</big><em>size</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceData.make_valid_tex_channel_count" title="Permalink to this definition">¶</a></dt>
<dd><p>Round up <cite>size</cite> to a valid texture channel count.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pycuda.tools.OccupancyRecord">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">OccupancyRecord</tt><big>(</big><em>devdata</em>, <em>threads</em>, <em>shared_mem=0</em>, <em>registers=0</em><big>)</big><a class="headerlink" href="#pycuda.tools.OccupancyRecord" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculate occupancy for a given kernel workload characterized by</p>
<ul class="simple">
<li>thread count of <cite>threads</cite></li>
<li>shared memory use of <cite>shared_mem</cite> bytes</li>
<li>register use of <cite>registers</cite> 32-bit registers</li>
</ul>
<dl class="attribute">
<dt id="pycuda.tools.OccupancyRecord.tb_per_mp">
<tt class="descname">tb_per_mp</tt><a class="headerlink" href="#pycuda.tools.OccupancyRecord.tb_per_mp" title="Permalink to this definition">¶</a></dt>
<dd><p>How many thread blocks execute on each multiprocessor.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.OccupancyRecord.limited_by">
<tt class="descname">limited_by</tt><a class="headerlink" href="#pycuda.tools.OccupancyRecord.limited_by" title="Permalink to this definition">¶</a></dt>
<dd><p>What <a class="reference internal" href="#pycuda.tools.OccupancyRecord.tb_per_mp" title="pycuda.tools.OccupancyRecord.tb_per_mp"><tt class="xref py py-attr docutils literal"><span class="pre">tb_per_mp</span></tt></a> is limited by. One of <cite>&#8220;device&#8221;</cite>, <cite>&#8220;warps&#8221;</cite>,
<cite>&#8220;regs&#8221;</cite>, <cite>&#8220;smem&#8221;</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.OccupancyRecord.warps_per_mp">
<tt class="descname">warps_per_mp</tt><a class="headerlink" href="#pycuda.tools.OccupancyRecord.warps_per_mp" title="Permalink to this definition">¶</a></dt>
<dd><p>How many warps execute on each multiprocessor.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.OccupancyRecord.occupancy">
<tt class="descname">occupancy</tt><a class="headerlink" href="#pycuda.tools.OccupancyRecord.occupancy" title="Permalink to this definition">¶</a></dt>
<dd><p>A <cite>float</cite> value between 0 and 1 indicating how much of each multiprocessor&#8217;s
scheduling capability is occupied by the kernel.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="memory-pools">
<span id="mempool"></span><h2>Memory Pools<a class="headerlink" href="#memory-pools" title="Permalink to this headline">¶</a></h2>
<p>The functions <a class="reference internal" href="driver.html#pycuda.driver.mem_alloc" title="pycuda.driver.mem_alloc"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.driver.mem_alloc()</span></tt></a> and
<a class="reference internal" href="driver.html#pycuda.driver.pagelocked_empty" title="pycuda.driver.pagelocked_empty"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.driver.pagelocked_empty()</span></tt></a> can consume a fairly large amount of
processing time if they are invoked very frequently. For example, code based on
<a class="reference internal" href="array.html#pycuda.gpuarray.GPUArray" title="pycuda.gpuarray.GPUArray"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.gpuarray.GPUArray</span></tt></a> can easily run into this issue because a
fresh memory area is allocated for each intermediate result. Memory pools are a
remedy for this problem based on the observation that often many of the block
allocations are of the same sizes as previously used ones.</p>
<p>Then, instead of fully returning the memory to the system and incurring the
associated reallocation overhead, the pool holds on to the memory and uses it
to satisfy future allocations of similarly-sized blocks. The pool reacts
appropriately to out-of-memory conditions as long as all memory allocations
are made through it. Allocations performed from outside of the pool may run
into spurious out-of-memory conditions due to the pool owning much or all of
the available memory.</p>
<div class="section" id="device-based-memory-pool">
<h3>Device-based Memory Pool<a class="headerlink" href="#device-based-memory-pool" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="pycuda.tools.PooledDeviceAllocation">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">PooledDeviceAllocation</tt><a class="headerlink" href="#pycuda.tools.PooledDeviceAllocation" title="Permalink to this definition">¶</a></dt>
<dd><p>An object representing a <a class="reference internal" href="#pycuda.tools.DeviceMemoryPool" title="pycuda.tools.DeviceMemoryPool"><tt class="xref py py-class docutils literal"><span class="pre">DeviceMemoryPool</span></tt></a>-based allocation of
linear device memory.  Once this object is deleted, its associated device
memory is freed.
<a class="reference internal" href="#pycuda.tools.PooledDeviceAllocation" title="pycuda.tools.PooledDeviceAllocation"><tt class="xref py py-class docutils literal"><span class="pre">PooledDeviceAllocation</span></tt></a> instances can be cast to <a class="reference external" href="http://docs.python.org/dev/library/functions.html#int" title="(in Python v3.5)"><tt class="xref py py-class docutils literal"><span class="pre">int</span></tt></a>
(and <tt class="xref py py-class docutils literal"><span class="pre">long</span></tt>), yielding the starting address of the device memory
allocated.</p>
<dl class="method">
<dt id="pycuda.tools.PooledDeviceAllocation.free">
<tt class="descname">free</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PooledDeviceAllocation.free" title="Permalink to this definition">¶</a></dt>
<dd><p>Explicitly return the memory held by <em>self</em> to the associated memory pool.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.PooledDeviceAllocation.__len__">
<tt class="descname">__len__</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PooledDeviceAllocation.__len__" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the size of the allocated memory in bytes.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pycuda.tools.DeviceMemoryPool">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">DeviceMemoryPool</tt><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool" title="Permalink to this definition">¶</a></dt>
<dd><p>A memory pool for linear device memory as allocated using
<a class="reference internal" href="driver.html#pycuda.driver.mem_alloc" title="pycuda.driver.mem_alloc"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.driver.mem_alloc()</span></tt></a>. (see <a class="reference internal" href="#mempool"><em>Memory Pools</em></a>)</p>
<dl class="attribute">
<dt id="pycuda.tools.DeviceMemoryPool.held_blocks">
<tt class="descname">held_blocks</tt><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool.held_blocks" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of unused blocks being held by this pool.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.DeviceMemoryPool.active_blocks">
<tt class="descname">active_blocks</tt><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool.active_blocks" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of blocks in active use that have been allocated
through this pool.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceMemoryPool.allocate">
<tt class="descname">allocate</tt><big>(</big><em>size</em><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool.allocate" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <a class="reference internal" href="#pycuda.tools.PooledDeviceAllocation" title="pycuda.tools.PooledDeviceAllocation"><tt class="xref py py-class docutils literal"><span class="pre">PooledDeviceAllocation</span></tt></a> of <em>size</em> bytes.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceMemoryPool.free_held">
<tt class="descname">free_held</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool.free_held" title="Permalink to this definition">¶</a></dt>
<dd><p>Free all unused memory that the pool is currently holding.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.DeviceMemoryPool.stop_holding">
<tt class="descname">stop_holding</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.DeviceMemoryPool.stop_holding" title="Permalink to this definition">¶</a></dt>
<dd><p>Instruct the memory to start immediately freeing memory returned
to it, instead of holding it for future allocations.
Implicitly calls <a class="reference internal" href="#pycuda.tools.DeviceMemoryPool.free_held" title="pycuda.tools.DeviceMemoryPool.free_held"><tt class="xref py py-meth docutils literal"><span class="pre">free_held()</span></tt></a>.
This is useful as a cleanup action when a memory pool falls out
of use.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="memory-pool-for-pagelocked-memory">
<h3>Memory Pool for pagelocked memory<a class="headerlink" href="#memory-pool-for-pagelocked-memory" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="pycuda.tools.PooledHostAllocation">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">PooledHostAllocation</tt><a class="headerlink" href="#pycuda.tools.PooledHostAllocation" title="Permalink to this definition">¶</a></dt>
<dd><p>An object representing a <a class="reference internal" href="#pycuda.tools.PageLockedMemoryPool" title="pycuda.tools.PageLockedMemoryPool"><tt class="xref py py-class docutils literal"><span class="pre">PageLockedMemoryPool</span></tt></a>-based allocation of
linear device memory.  Once this object is deleted, its associated device
memory is freed.</p>
<dl class="method">
<dt id="pycuda.tools.PooledHostAllocation.free">
<tt class="descname">free</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PooledHostAllocation.free" title="Permalink to this definition">¶</a></dt>
<dd><p>Explicitly return the memory held by <em>self</em> to the associated memory pool.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.PooledHostAllocation.__len__">
<tt class="descname">__len__</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PooledHostAllocation.__len__" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the size of the allocated memory in bytes.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="pycuda.tools.PageLockedAllocator">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">PageLockedAllocator</tt><big>(</big><em>flags=0</em><big>)</big><a class="headerlink" href="#pycuda.tools.PageLockedAllocator" title="Permalink to this definition">¶</a></dt>
<dd><p>Specifies the set of <a class="reference internal" href="driver.html#pycuda.driver.host_alloc_flags" title="pycuda.driver.host_alloc_flags"><tt class="xref py py-class docutils literal"><span class="pre">pycuda.driver.host_alloc_flags</span></tt></a> used in its
associated <a class="reference internal" href="#pycuda.tools.PageLockedMemoryPool" title="pycuda.tools.PageLockedMemoryPool"><tt class="xref py py-class docutils literal"><span class="pre">PageLockedMemoryPool</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="pycuda.tools.PageLockedMemoryPool">
<em class="property">class </em><tt class="descclassname">pycuda.tools.</tt><tt class="descname">PageLockedMemoryPool</tt><big>(</big><em>allocator=PageLockedAllocator()</em><big>)</big><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool" title="Permalink to this definition">¶</a></dt>
<dd><p>A memory pool for pagelocked host memory as allocated using
<a class="reference internal" href="driver.html#pycuda.driver.pagelocked_empty" title="pycuda.driver.pagelocked_empty"><tt class="xref py py-func docutils literal"><span class="pre">pycuda.driver.pagelocked_empty()</span></tt></a>. (see <a class="reference internal" href="#mempool"><em>Memory Pools</em></a>)</p>
<dl class="attribute">
<dt id="pycuda.tools.PageLockedMemoryPool.held_blocks">
<tt class="descname">held_blocks</tt><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool.held_blocks" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of unused blocks being held by this pool.</p>
</dd></dl>

<dl class="attribute">
<dt id="pycuda.tools.PageLockedMemoryPool.active_blocks">
<tt class="descname">active_blocks</tt><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool.active_blocks" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of blocks in active use that have been allocated
through this pool.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.PageLockedMemoryPool.allocate">
<tt class="descname">allocate</tt><big>(</big><em>shape</em>, <em>dtype</em>, <em>order=&quot;C&quot;</em><big>)</big><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool.allocate" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an uninitialized (&#8220;empty&#8221;) <a class="reference external" href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.9)"><tt class="xref py py-class docutils literal"><span class="pre">numpy.ndarray</span></tt></a> with the given
<em>shape</em>, <em>dtype</em>, and <em>order</em>. This array will be backed by a
<a class="reference internal" href="#pycuda.tools.PooledHostAllocation" title="pycuda.tools.PooledHostAllocation"><tt class="xref py py-class docutils literal"><span class="pre">PooledHostAllocation</span></tt></a>, which can be found as the <tt class="docutils literal"><span class="pre">.base</span></tt>
attribute of the array.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.PageLockedMemoryPool.free_held">
<tt class="descname">free_held</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool.free_held" title="Permalink to this definition">¶</a></dt>
<dd><p>Free all unused memory that the pool is currently holding.</p>
</dd></dl>

<dl class="method">
<dt id="pycuda.tools.PageLockedMemoryPool.stop_holding">
<tt class="descname">stop_holding</tt><big>(</big><big>)</big><a class="headerlink" href="#pycuda.tools.PageLockedMemoryPool.stop_holding" title="Permalink to this definition">¶</a></dt>
<dd><p>Instruct the memory to start immediately freeing memory returned
to it, instead of holding it for future allocations.
Implicitly calls <a class="reference internal" href="#pycuda.tools.PageLockedMemoryPool.free_held" title="pycuda.tools.PageLockedMemoryPool.free_held"><tt class="xref py py-meth docutils literal"><span class="pre">free_held()</span></tt></a>.
This is useful as a cleanup action when a memory pool falls out
of use.</p>
</dd></dl>

</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Built-in Utilities</a><ul>
<li><a class="reference internal" href="#module-pycuda.autoinit">Automatic Initialization</a></li>
<li><a class="reference internal" href="#module-pycuda.tools">Choice of Device</a></li>
<li><a class="reference internal" href="#kernel-caching">Kernel Caching</a></li>
<li><a class="reference internal" href="#testing">Testing</a></li>
<li><a class="reference internal" href="#device-metadata-and-occupancy">Device Metadata and Occupancy</a></li>
<li><a class="reference internal" href="#memory-pools">Memory Pools</a><ul>
<li><a class="reference internal" href="#device-based-memory-pool">Device-based Memory Pool</a></li>
<li><a class="reference internal" href="#memory-pool-for-pagelocked-memory">Memory Pool for pagelocked memory</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="driver.html"
                        title="previous chapter">Device Interface</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="gl.html"
                        title="next chapter">OpenGL</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/util.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="gl.html" title="OpenGL"
             >next</a> |</li>
        <li class="right" >
          <a href="driver.html" title="Device Interface"
             >previous</a> |</li>
        <li><a href="index.html">PyCUDA 2014.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2008, Andreas Kloeckner.
      Last updated on Jan 22, 2015.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>