Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
GpuResources.cpp
1 /**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD+Patents license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9
10 #include "GpuResources.h"
11 #include "utils/DeviceUtils.h"
12
13 namespace faiss { namespace gpu {
14
15 GpuResources::~GpuResources() {
16 }
17
18 cublasHandle_t
19 GpuResources::getBlasHandleCurrentDevice() {
20 return getBlasHandle(getCurrentDevice());
21 }
22
23 cudaStream_t
24 GpuResources::getDefaultStreamCurrentDevice() {
25 return getDefaultStream(getCurrentDevice());
26 }
27
28 std::vector<cudaStream_t>
29 GpuResources::getAlternateStreamsCurrentDevice() {
30 return getAlternateStreams(getCurrentDevice());
31 }
32
33 DeviceMemory&
34 GpuResources::getMemoryManagerCurrentDevice() {
35 return getMemoryManager(getCurrentDevice());
36 }
37
38 cudaStream_t
39 GpuResources::getAsyncCopyStreamCurrentDevice() {
40 return getAsyncCopyStream(getCurrentDevice());
41 }
42
43 void
44 GpuResources::syncDefaultStream(int device) {
45 CUDA_VERIFY(cudaStreamSynchronize(getDefaultStream(device)));
46 }
47
48 void
49 GpuResources::syncDefaultStreamCurrentDevice() {
50 syncDefaultStream(getCurrentDevice());
51 }
52
53 } } // namespace
faiss::gpu::GpuResources::getDefaultStreamCurrentDevice
cudaStream_t getDefaultStreamCurrentDevice()
Calls getDefaultStream with the current device.
Definition: GpuResources.cpp:24
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:19
faiss::gpu::GpuResources::getMemoryManagerCurrentDevice
DeviceMemory & getMemoryManagerCurrentDevice()
Calls getMemoryManager for the current device.
Definition: GpuResources.cpp:34
faiss::gpu::GpuResources::syncDefaultStreamCurrentDevice
void syncDefaultStreamCurrentDevice()
Calls syncDefaultStream for the current device.
Definition: GpuResources.cpp:49
faiss::gpu::GpuResources::getAsyncCopyStreamCurrentDevice
cudaStream_t getAsyncCopyStreamCurrentDevice()
Calls getAsyncCopyStream for the current device.
Definition: GpuResources.cpp:39
faiss::gpu::GpuResources::getAlternateStreamsCurrentDevice
std::vector< cudaStream_t > getAlternateStreamsCurrentDevice()
Calls getAlternateStreams for the current device.
Definition: GpuResources.cpp:29
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:44
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:45
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.