diff options
author | avijit-nervana <avijit.chakraborty@intel.com> | 2018-09-14 09:21:08 -0700 |
---|---|---|
committer | avijit-nervana <avijit.chakraborty@intel.com> | 2018-09-14 09:21:08 -0700 |
commit | 41aaed7751690b0b3137dad2620656a698b3ceae (patch) | |
tree | 00fc1a7f6be0c3968f3e674a65ca4907110ddf2d /third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl | |
parent | c26c5e1217944448f1f4c2b97626fc4d7d6406d3 (diff) | |
parent | 95338704198205c1bdec1e344e103f1daf05df68 (diff) |
Merge branch 'master' into avijit/add-cpu-backend
Diffstat (limited to 'third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl')
-rwxr-xr-x | third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl b/third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl new file mode 100755 index 0000000000..5c6703aab4 --- /dev/null +++ b/third_party/toolchains/preconfig/ubuntu14.04/cuda9.0-cudnn7/cuda/build_defs.bzl @@ -0,0 +1,33 @@ +# Macros for building CUDA code. +def if_cuda(if_true, if_false = []): + """Shorthand for select()'ing on whether we're building with CUDA. + + Returns a select statement which evaluates to if_true if we're building + with CUDA enabled. Otherwise, the select statement evaluates to if_false. + + """ + return select({ + "@local_config_cuda//cuda:using_nvcc": if_true, + "@local_config_cuda//cuda:using_clang": if_true, + "//conditions:default": if_false + }) + + +def cuda_default_copts(): + """Default options for all CUDA compilations.""" + return if_cuda(["-x", "cuda", "-DGOOGLE_CUDA=1"] + []) + + +def cuda_is_configured(): + """Returns true if CUDA was enabled during the configure process.""" + return True + +def if_cuda_is_configured(x): + """Tests if the CUDA was enabled during the configure process. + + Unlike if_cuda(), this does not require that we are building with + --config=cuda. Used to allow non-CUDA code to depend on CUDA libraries. + """ + if cuda_is_configured(): + return x + return [] |