Skip to content

Commit

Permalink
Enable branch prediction in TensorFlow
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 191788253
  • Loading branch information
jart authored and tensorflower-gardener committed Apr 5, 2018
1 parent c1990c0 commit f3c677e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tensorflow/core/platform/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,18 @@ limitations under the License.
#define TF_EXPORT __attribute__((visibility("default")))
#endif // COMPILER_MSVC

// GCC can be told that a certain branch is not likely to be taken (for
// instance, a CHECK failure), and use that information in static analysis.
// Giving it this information can help it optimize for the common case in
// the absence of better information (ie. -fprofile-arcs).
#if defined(COMPILER_GCC3)
#ifdef __has_builtin
#define TF_HAS_BUILTIN(x) __has_builtin(x)
#else
#define TF_HAS_BUILTIN(x) 0
#endif

// Compilers can be told that a certain branch is not likely to be taken
// (for instance, a CHECK failure), and use that information in static
// 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)
#define TF_PREDICT_FALSE(x) (__builtin_expect(x, 0))
#define TF_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#else
Expand Down

0 comments on commit f3c677e

Please sign in to comment.