Faiss
 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 // Copyright 2004-present Facebook. All Rights Reserved.
10 
11 #include "GpuResources.h"
12 #include "utils/DeviceUtils.h"
13 
14 namespace faiss { namespace gpu {
15 
16 GpuResources::~GpuResources() {
17 }
18 
19 cublasHandle_t
21  return getBlasHandle(getCurrentDevice());
22 }
23 
24 cudaStream_t
26  return getDefaultStream(getCurrentDevice());
27 }
28 
29 std::vector<cudaStream_t>
31  return getAlternateStreams(getCurrentDevice());
32 }
33 
36  return getMemoryManager(getCurrentDevice());
37 }
38 
39 cudaStream_t
41  return getAsyncCopyStream(getCurrentDevice());
42 }
43 
44 void
46  CUDA_VERIFY(cudaStreamSynchronize(getDefaultStream(device)));
47 }
48 
49 void
51  syncDefaultStream(getCurrentDevice());
52 }
53 
54 } } // namespace
cudaStream_t getDefaultStreamCurrentDevice()
Calls getDefaultStream with the current device.
virtual cublasHandle_t getBlasHandle(int device)=0
Returns the cuBLAS handle that we use for the given device.
virtual cudaStream_t getDefaultStream(int device)=0
cublasHandle_t getBlasHandleCurrentDevice()
Calls getBlasHandle with the current device.
DeviceMemory & getMemoryManagerCurrentDevice()
Calls getMemoryManager for the current device.
void syncDefaultStreamCurrentDevice()
Calls syncDefaultStream for the current device.
cudaStream_t getAsyncCopyStreamCurrentDevice()
Calls getAsyncCopyStream for the current device.
std::vector< cudaStream_t > getAlternateStreamsCurrentDevice()
Calls getAlternateStreams for the current device.
virtual cudaStream_t getAsyncCopyStream(int device)=0
Returns the stream on which we perform async CPU &lt;-&gt; GPU copies.
void syncDefaultStream(int device)
virtual DeviceMemory & getMemoryManager(int device)=0
Returns the temporary memory manager for the given device.
Manages temporary memory allocations on a GPU device.
Definition: DeviceMemory.h:46
virtual std::vector< cudaStream_t > getAlternateStreams(int device)=0
Returns the set of alternative streams that we use for the given device.