Yangqing Jia | 91d76f5 | 2018-01-29 10:00:43 -0800 | [diff] [blame] | 1 | #include <atomic> |
| 2 | |
Yangqing Jia | 93e12e7 | 2017-08-23 18:17:18 -0700 | [diff] [blame] | 3 | #include "caffe2/core/common.h" |
| 4 | |
| 5 | namespace caffe2 { |
Yangqing Jia | 91d76f5 | 2018-01-29 10:00:43 -0800 | [diff] [blame] | 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}; |
bddppq | e5b9972 | 2018-06-04 09:04:30 -0700 | [diff] [blame] | 11 | std::atomic<bool> g_caffe2_has_hip_linked{false}; |
Yangqing Jia | 91d76f5 | 2018-01-29 10:00:43 -0800 | [diff] [blame] | 12 | |
| 13 | bool HasCudaRuntime() { |
| 14 | return g_caffe2_has_cuda_linked.load(); |
| 15 | } |
| 16 | |
bddppq | e5b9972 | 2018-06-04 09:04:30 -0700 | [diff] [blame] | 17 | bool HasHipRuntime() { |
| 18 | return g_caffe2_has_hip_linked.load(); |
| 19 | } |
| 20 | |
Yangqing Jia | 91d76f5 | 2018-01-29 10:00:43 -0800 | [diff] [blame] | 21 | namespace internal { |
| 22 | void SetCudaRuntimeFlag() { |
| 23 | g_caffe2_has_cuda_linked.store(true); |
| 24 | } |
bddppq | e5b9972 | 2018-06-04 09:04:30 -0700 | [diff] [blame] | 25 | |
| 26 | void SetHipRuntimeFlag() { |
| 27 | g_caffe2_has_hip_linked.store(true); |
| 28 | } |
Yangqing Jia | 91d76f5 | 2018-01-29 10:00:43 -0800 | [diff] [blame] | 29 | } // namespace internal |
Dmytro Dzhulgakov | 5527dd3 | 2017-10-04 02:29:01 -0700 | [diff] [blame] | 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 | |
Yangqing Jia | 93e12e7 | 2017-08-23 18:17:18 -0700 | [diff] [blame] | 39 | } // namespace caffe2 |