1#include <atomic>
2
3#include "caffe2/core/common.h"
4
5namespace caffe2 {
6
7// A global variable to mark if Caffe2 has cuda linked to the current runtime.
8// Do not directly use this variable, but instead use the HasCudaRuntime()
9// function below.
10std::atomic<bool> g_caffe2_has_cuda_linked{false};
11std::atomic<bool> g_caffe2_has_hip_linked{false};
12
13bool HasCudaRuntime() {
14 return g_caffe2_has_cuda_linked.load();
15}
16
17bool HasHipRuntime() {
18 return g_caffe2_has_hip_linked.load();
19}
20
21namespace internal {
22void SetCudaRuntimeFlag() {
23 g_caffe2_has_cuda_linked.store(true);
24}
25
26void SetHipRuntimeFlag() {
27 g_caffe2_has_hip_linked.store(true);
28}
29} // namespace internal
30
31const std::map<string, string>& GetBuildOptions() {
32#ifndef CAFFE2_BUILD_STRINGS
33#define CAFFE2_BUILD_STRINGS {}
34#endif
35 static const std::map<string, string> kMap = CAFFE2_BUILD_STRINGS;
36 return kMap;
37}
38
39} // namespace caffe2
40