<divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment"> * Copyright (c) Facebook, Inc. and its affiliates.</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment"> * This source code is licensed under the MIT license found in the</span></div>
<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * LICENSE file in the root directory of this source tree.</span></div>
<divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="comment">/// Default implementation of GpuResources that allocates a cuBLAS</span></div>
<divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment">/// stream and 2 streams for use, as well as temporary memory</span></div>
<divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="comment"> /// Disable allocation of temporary memory; all temporary memory</span></div>
<divclass="line"><aname="l00028"></a><spanclass="lineno"> 28</span> <spanclass="comment"> /// requests will call cudaMalloc / cudaFree at the point of use</span></div>
<divclass="line"><aname="l00031"></a><spanclass="lineno"> 31</span> <spanclass="comment"> /// Specify that we wish to use a certain fixed size of memory on</span></div>
<divclass="line"><aname="l00032"></a><spanclass="lineno"> 32</span> <spanclass="comment"> /// all devices as temporary memory. This is the upper bound for the GPU</span></div>
<divclass="line"><aname="l00033"></a><spanclass="lineno"> 33</span> <spanclass="comment"> /// memory that we will reserve. We will never go above 1.5 GiB on any GPU;</span></div>
<divclass="line"><aname="l00034"></a><spanclass="lineno"> 34</span> <spanclass="comment"> /// smaller GPUs (with <= 4 GiB or <= 8 GiB) will use less memory than that.</span></div>
<divclass="line"><aname="l00035"></a><spanclass="lineno"> 35</span> <spanclass="comment"> /// To avoid any temporary memory allocation, pass 0.</span></div>
<divclass="line"><aname="l00038"></a><spanclass="lineno"> 38</span> <spanclass="comment"> /// Set amount of pinned memory to allocate, for async GPU <-> CPU</span></div>
<divclass="line"><aname="l00042"></a><spanclass="lineno"> 42</span> <spanclass="comment"> /// Called to change the stream for work ordering</span></div>
<divclass="line"><aname="l00045"></a><spanclass="lineno"> 45</span> <spanclass="comment"> /// Called to change the work ordering streams to the null stream</span></div>
<divclass="line"><aname="l00046"></a><spanclass="lineno"> 46</span> <spanclass="comment"> /// for all devices</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment"> /// Enable or disable the warning about not having enough temporary memory</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment"> /// when cudaMalloc gets called</span></div>
<divclass="line"><aname="l00072"></a><spanclass="lineno"> 72</span> <spanclass="comment"> /// Have GPU resources been initialized for this device yet?</span></div>
<divclass="line"><aname="l00075"></a><spanclass="lineno"> 75</span> <spanclass="comment"> /// Adjust the default temporary memory allocation based on the total GPU</span></div>
<divclass="line"><aname="l00080"></a><spanclass="lineno"> 80</span> <spanclass="comment"> /// Our default stream that work is ordered on, one per each device</span></div>
<divclass="line"><aname="l00083"></a><spanclass="lineno"> 83</span> <spanclass="comment"> /// This contains particular streams as set by the user for</span></div>
<divclass="line"><aname="l00084"></a><spanclass="lineno"> 84</span> <spanclass="comment"> /// ordering, if any</span></div>
<divclass="line"><aname="l00087"></a><spanclass="lineno"> 87</span> <spanclass="comment"> /// Other streams we can use, per each device</span></div>
<divclass="line"><aname="l00090"></a><spanclass="lineno"> 90</span> <spanclass="comment"> /// Async copy stream to use for GPU <-> CPU pinned memory copies</span></div>
<divclass="line"><aname="l00096"></a><spanclass="lineno"> 96</span> <spanclass="comment"> /// Temporary memory provider, per each device</span></div>
<divclass="line"><aname="l00099"></a><spanclass="lineno"> 99</span> <spanclass="comment"> /// Pinned memory allocation for use with this GPU</span></div>
<divclass="line"><aname="l00103"></a><spanclass="lineno"> 103</span> <spanclass="comment"> /// Another option is to use a specified amount of memory on all</span></div>
<divclass="line"><aname="l00107"></a><spanclass="lineno"> 107</span> <spanclass="comment"> /// Amount of pinned memory we should allocate</span></div>
<divclass="line"><aname="l00110"></a><spanclass="lineno"> 110</span> <spanclass="comment"> /// Whether or not a warning upon cudaMalloc is generated</span></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_a5924b424c36dba8300866f1b98c438cb"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#a5924b424c36dba8300866f1b98c438cb">faiss::gpu::StandardGpuResources::setDefaultStream</a></div><divclass="ttdeci">void setDefaultStream(int device, cudaStream_t stream)</div><divclass="ttdoc">Called to change the stream for work ordering. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00155">StandardGpuResources.cpp:155</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_a7560435c7f45fd59d94ee947330a58da"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#a7560435c7f45fd59d94ee947330a58da">faiss::gpu::StandardGpuResources::getBlasHandle</a></div><divclass="ttdeci">cublasHandle_t getBlasHandle(int device) override</div><divclass="ttdoc">Returns the cuBLAS handle that we use for the given device. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00262">StandardGpuResources.cpp:262</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_adb2729678638ed89f7b8b38470f96056"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#adb2729678638ed89f7b8b38470f96056">faiss::gpu::StandardGpuResources::initializeForDevice</a></div><divclass="ttdeci">void initializeForDevice(int device) override</div><divclass="ttdoc">Internal system calls. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00190">StandardGpuResources.cpp:190</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_adf89d4731c826df889f51fe42287b15d"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#adf89d4731c826df889f51fe42287b15d">faiss::gpu::StandardGpuResources::getAsyncCopyStream</a></div><divclass="ttdeci">cudaStream_t getAsyncCopyStream(int device) override</div><divclass="ttdoc">Returns the stream on which we perform async CPU &lt;-&gt; GPU copies. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00290">StandardGpuResources.cpp:290</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_a35da92117dd4b47ee773444af716d634"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#a35da92117dd4b47ee773444af716d634">faiss::gpu::StandardGpuResources::getMemoryManager</a></div><divclass="ttdeci">DeviceMemory & getMemoryManager(int device) override</div><divclass="ttdoc">Returns the temporary memory manager for the given device. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00279">StandardGpuResources.cpp:279</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1DeviceMemory_html"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1DeviceMemory.html">faiss::gpu::DeviceMemory</a></div><divclass="ttdoc">Manages temporary memory allocations on a GPU device. </div><divclass="ttdef"><b>Definition:</b><ahref="DeviceMemory_8h_source.html#l00044">DeviceMemory.h:44</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_ae7418f127cac2ac663ac0ae2e6f88e8d"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#ae7418f127cac2ac663ac0ae2e6f88e8d">faiss::gpu::StandardGpuResources::getPinnedMemory</a></div><divclass="ttdeci">std::pair< void *, size_t > getPinnedMemory() override</div><divclass="ttdoc">Returns the available CPU pinned memory buffer. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00285">StandardGpuResources.cpp:285</a></div></div>
<divclass="ttc"id="classfaiss_1_1gpu_1_1StandardGpuResources_html_a9ebf68604864cb890a4c2e3d0a6f9952"><divclass="ttname"><ahref="classfaiss_1_1gpu_1_1StandardGpuResources.html#a9ebf68604864cb890a4c2e3d0a6f9952">faiss::gpu::StandardGpuResources::getAlternateStreams</a></div><divclass="ttdeci">std::vector< cudaStream_t > getAlternateStreams(int device) override</div><divclass="ttdoc">Returns the set of alternative streams that we use for the given device. </div><divclass="ttdef"><b>Definition:</b><ahref="StandardGpuResources_8cpp_source.html#l00274">StandardGpuResources.cpp:274</a></div></div>