Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
GpuResources_c.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 // -*- c++ -*-
11
12 #include "gpu/GpuResources_c.h"
13 #include "gpu/GpuResources.h"
14 #include "macros_impl.h"
15
16 using faiss::gpu::GpuResources;
17
18 DEFINE_DESTRUCTOR(GpuResources)
19
20 int faiss_GpuResources_initializeForDevice(FaissGpuResources* res, int device) {
21 try {
22 reinterpret_cast<GpuResources*>(res)->initializeForDevice(device);
23 } CATCH_AND_HANDLE
24 }
25
26 int faiss_GpuResources_getBlasHandle(FaissGpuResources* res, int device, cublasHandle_t* out) {
27 try {
28 auto o = reinterpret_cast<GpuResources*>(res)->getBlasHandle(device);
29 *out = o;
30 } CATCH_AND_HANDLE
31 }
32
33 int faiss_GpuResources_getDefaultStream(FaissGpuResources* res, int device, cudaStream_t* out) {
34 try {
35 auto o = reinterpret_cast<GpuResources*>(res)->getDefaultStream(device);
36 *out = o;
37 } CATCH_AND_HANDLE
38 }
39
40 int faiss_GpuResources_getPinnedMemory(FaissGpuResources* res, void** p_buffer, size_t* p_size) {
41 try {
42 auto o = reinterpret_cast<GpuResources*>(res)->getPinnedMemory();
43 *p_buffer = o.first;
44 *p_size = o.second;
45 } CATCH_AND_HANDLE
46 }
47
48 int faiss_GpuResources_getAsyncCopyStream(FaissGpuResources* res, int device, cudaStream_t* out) {
49 try {
50 auto o = reinterpret_cast<GpuResources*>(res)->getAsyncCopyStream(device);
51 *out = o;
52 } CATCH_AND_HANDLE
53 }
54
55 int faiss_GpuResources_getBlasHandleCurrentDevice(FaissGpuResources* res, cublasHandle_t* out) {
56 try {
57 auto o = reinterpret_cast<GpuResources*>(res)->getBlasHandleCurrentDevice();
58 *out = o;
59 } CATCH_AND_HANDLE
60 }
61
62 int faiss_GpuResources_getDefaultStreamCurrentDevice(FaissGpuResources* res, cudaStream_t* out) {
63 try {
64 auto o = reinterpret_cast<GpuResources*>(res)->getDefaultStreamCurrentDevice();
65 *out = o;
66 } CATCH_AND_HANDLE
67 }
68
69 int faiss_GpuResources_syncDefaultStream(FaissGpuResources* res, int device) {
70 try {
71 reinterpret_cast<GpuResources*>(res)->syncDefaultStream(device);
72 } CATCH_AND_HANDLE
73 }
74
75 int faiss_GpuResources_syncDefaultStreamCurrentDevice(FaissGpuResources* res) {
76 try {
77 reinterpret_cast<GpuResources*>(res)->syncDefaultStreamCurrentDevice();
78 } CATCH_AND_HANDLE
79 }
80
81 int faiss_GpuResources_getAsyncCopyStreamCurrentDevice(FaissGpuResources* res, cudaStream_t* out) {
82 try {
83 auto o = reinterpret_cast<GpuResources*>(res)->getAsyncCopyStreamCurrentDevice();
84 *out = o;
85 } CATCH_AND_HANDLE
86 }
87
faiss::gpu::GpuResources
Definition: GpuResources.h:22