Description: Upstream_f506183dd148d97e3378eb994b2ac9c948ef0ada_builtin_expect_NVCC_build_failure
 Don't add branch prediction hints when compiling under nvcc.
 .
 As seen in #19203, the `__builtin_expect` compiler builtin isn't recognized as
 a builtin in nvcc8, leading to compilation failures of the form
 .
 /tensorflow/core/kernels/gather_functor_gpu.cu.h(57): error: calling a
 __host__ function("__builtin_expect") from a __global__ 
 function("tensorflow::GatherOpKernel< ::Eigen::half, int, (bool)1> ") is
 not allowed
 .
 when attempting to build TensorFlow.
 .
 This change fixes things by adding an additional check for `__NVCC__`, and
 avoiding any branch prediction hints in that case.
 .
 PiperOrigin-RevId: 197067418
 .
 python-tensorflow-cuda (1.7.1-1) unstable; urgency=medium
 .
   * New upstream release.
   * Bump bazel build dep, wants >= 0.11.1, << 0.12 (others fail):
     https://github.com/tensorflow/tensorflow/issues/22527
   * Remove Fix_TensorRT_lib_version_detection patch.
   * Drop --config=tensorrt from bazel arguments, not needed anymore.
   * Does not build on Jessie/Xenial:
     https://github.com/tensorflow/tensorflow/issues/18039
   * Apply upstream 3eb314bbcdc6e850eefc21c7ecbd91e28bd04a70 to fix CUDA < 9
     detection.
   * Apply upstream f506183dd148d97e3378eb994b2ac9c948ef0ada to fix NVCC
     build failure with CUDA < 9.
   * Symlink libdevice/* files to nvvm folder to fix CUDA detection.
   * Remove Python 3.7 from PY3VER, not supported upstream for the moment.
Author: Adam Cecile <acecile@le-vert.net>

---
Origin: upstream, https://github.com/zheng-xq/tensorflow/commit/f506183dd148d97e3378eb994b2ac9c948ef0ada
Bug: https://github.com/tensorflow/tensorflow/issues/19249
Forwarded: not-needed
Reviewed-By: TensorFlow  upstream
Last-Update: 2018-10-03

--- python-tensorflow-cuda-1.7.1.orig/tensorflow/core/platform/macros.h
+++ python-tensorflow-cuda-1.7.1/tensorflow/core/platform/macros.h
@@ -78,7 +78,11 @@ limitations under the License.
 // analysis. Giving it this information can help it optimize for the
 // common case in the absence of better information (ie.
 // -fprofile-arcs).
-#if TF_HAS_BUILTIN(__builtin_expect) || (defined(__GNUC__) && __GNUC__ >= 3)
+//
+// We need to disable this for GPU builds, though, since nvcc8 and older
+// don't recognize `__builtin_expect` as a builtin, and fail compilation.
+#if (!defined(__NVCC__)) && \
+    (TF_HAS_BUILTIN(__builtin_expect) || (defined(__GNUC__) && __GNUC__ >= 3))
 #define TF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
 #define TF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
 #else
