Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
GpuResources.cpp
1 /**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8
9 #include "GpuResources.h"
10 #include "utils/DeviceUtils.h"
11
12 namespace faiss { namespace gpu {
13
14 GpuResources::~GpuResources() {
15 }
16
17 cublasHandle_t
18 GpuResources::getBlasHandleCurrentDevice() {
19 return getBlasHandle(getCurrentDevice());
20 }
21
22 cudaStream_t
23 GpuResources::getDefaultStreamCurrentDevice() {
24 return getDefaultStream(getCurrentDevice());
25 }
26
27 std::vector<cudaStream_t>
28 GpuResources::getAlternateStreamsCurrentDevice() {
29 return getAlternateStreams(getCurrentDevice());
30 }
31
32 DeviceMemory&
33 GpuResources::getMemoryManagerCurrentDevice() {
34 return getMemoryManager(getCurrentDevice());
35 }
36
37 cudaStream_t
38 GpuResources::getAsyncCopyStreamCurrentDevice() {
39 return getAsyncCopyStream(getCurrentDevice());
40 }
41
42 void
43 GpuResources::syncDefaultStream(int device) {
44 CUDA_VERIFY(cudaStreamSynchronize(getDefaultStream(device)));
45 }
46
47 void
48 GpuResources::syncDefaultStreamCurrentDevice() {
49 syncDefaultStream(getCurrentDevice());
50 }
51
52 } } // namespace
faiss::gpu::GpuResources::getDefaultStreamCurrentDevice
cudaStream_t getDefaultStreamCurrentDevice()
Calls getDefaultStream with the current device.
Definition: GpuResources.cpp:23
faiss::gpu::GpuResources::getBlasHandle
virtual cublasHandle_t getBlasHandle(int device)=0
Returns the cuBLAS handle that we use for the given device.
faiss::gpu::GpuResources::getDefaultStream
virtual cudaStream_t getDefaultStream(int device)=0
faiss::gpu::GpuResources::getBlasHandleCurrentDevice
cublasHandle_t getBlasHandleCurrentDevice()
Calls getBlasHandle with the current device.
Definition: GpuResources.cpp:18
faiss::gpu::GpuResources::getMemoryManagerCurrentDevice
DeviceMemory & getMemoryManagerCurrentDevice()
Calls getMemoryManager for the current device.
Definition: GpuResources.cpp:33
faiss::gpu::GpuResources::syncDefaultStreamCurrentDevice
void syncDefaultStreamCurrentDevice()
Calls syncDefaultStream for the current device.
Definition: GpuResources.cpp:48
faiss::gpu::GpuResources::getAsyncCopyStreamCurrentDevice
cudaStream_t getAsyncCopyStreamCurrentDevice()
Calls getAsyncCopyStream for the current device.
Definition: GpuResources.cpp:38
faiss::gpu::GpuResources::getAlternateStreamsCurrentDevice
std::vector< cudaStream_t > getAlternateStreamsCurrentDevice()
Calls getAlternateStreams for the current device.
Definition: GpuResources.cpp:28
faiss::gpu::GpuResources::getAsyncCopyStream
virtual cudaStream_t getAsyncCopyStream(int device)=0
Returns the stream on which we perform async CPU &lt;-&gt; GPU copies.
faiss::gpu::GpuResources::syncDefaultStream
void syncDefaultStream(int device)
Definition: GpuResources.cpp:43
faiss::gpu::GpuResources::getMemoryManager
virtual DeviceMemory & getMemoryManager(int device)=0
Returns the temporary memory manager for the given device.
faiss::gpu::DeviceMemory
Manages temporary memory allocations on a GPU device.
Definition: DeviceMemory.h:44
faiss::gpu::GpuResources::getAlternateStreams
virtual std::vector< cudaStream_t > getAlternateStreams(int device)=0
Returns the set of alternative streams that we use for the given device.