Debian Codegraph @

c_api/gpu/DeviceUtils_c.cpp

raw
1 /*
2 * Copyright (c) Meta Platforms, Inc. and 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 // -*- c++ -*-
9
10 #include "DeviceUtils_c.h"
11 #include <faiss/gpu/utils/DeviceUtils.h>
12 #include "macros_impl.h"
13
14 /// Returns the number of available GPU devices
15 int faiss_get_num_gpus(int* p_output) {
16 try {
17 int output = faiss::gpu::getNumDevices();
18 *p_output = output;
19 }
20 CATCH_AND_HANDLE
21 }
22
23 /// Starts the CUDA profiler (exposed via SWIG)
24 int faiss_gpu_profiler_start() {
25 try {
26 faiss::gpu::profilerStart();
27 }
28 CATCH_AND_HANDLE
29 }
30
31 /// Stops the CUDA profiler (exposed via SWIG)
32 int faiss_gpu_profiler_stop() {
33 try {
34 faiss::gpu::profilerStop();
35 }
36 CATCH_AND_HANDLE
37 }
38
39 /// Synchronizes the CPU against all devices (equivalent to
40 /// cudaDeviceSynchronize for each device)
41 int faiss_gpu_sync_all_devices() {
42 try {
43 faiss::gpu::synchronizeAllDevices();
44 }
45 CATCH_AND_HANDLE
46 }