blob: aede3497486a9c05a2905771348728984ce35cb9 [file] [log] [blame]
Yangqing Jia91d76f52018-01-29 10:00:43 -08001#include <atomic>
2
Yangqing Jia93e12e72017-08-23 18:17:18 -07003#include "caffe2/core/common.h"
4
5namespace caffe2 {
Yangqing Jia91d76f52018-01-29 10:00:43 -08006
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};
bddppqe5b99722018-06-04 09:04:30 -070011std::atomic<bool> g_caffe2_has_hip_linked{false};
Yangqing Jia91d76f52018-01-29 10:00:43 -080012
13bool HasCudaRuntime() {
14 return g_caffe2_has_cuda_linked.load();
15}
16
bddppqe5b99722018-06-04 09:04:30 -070017bool HasHipRuntime() {
18 return g_caffe2_has_hip_linked.load();
19}
20
Yangqing Jia91d76f52018-01-29 10:00:43 -080021namespace internal {
22void SetCudaRuntimeFlag() {
23 g_caffe2_has_cuda_linked.store(true);
24}
bddppqe5b99722018-06-04 09:04:30 -070025
26void SetHipRuntimeFlag() {
27 g_caffe2_has_hip_linked.store(true);
28}
Yangqing Jia91d76f52018-01-29 10:00:43 -080029} // namespace internal
Dmytro Dzhulgakov5527dd32017-10-04 02:29:01 -070030
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
Yangqing Jia93e12e72017-08-23 18:17:18 -070039} // namespace caffe2