1 | #include <atomic> |
---|---|
2 | |
3 | #include "caffe2/core/common.h" |
4 | |
5 | namespace 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. |
10 | std::atomic<bool> g_caffe2_has_cuda_linked{false}; |
11 | std::atomic<bool> g_caffe2_has_hip_linked{false}; |
12 | |
13 | bool HasCudaRuntime() { |
14 | return g_caffe2_has_cuda_linked.load(); |
15 | } |
16 | |
17 | bool HasHipRuntime() { |
18 | return g_caffe2_has_hip_linked.load(); |
19 | } |
20 | |
21 | namespace internal { |
22 | void SetCudaRuntimeFlag() { |
23 | g_caffe2_has_cuda_linked.store(true); |
24 | } |
25 | |
26 | void SetHipRuntimeFlag() { |
27 | g_caffe2_has_hip_linked.store(true); |
28 | } |
29 | } // namespace internal |
30 | |
31 | const 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 |