Skip to content

Commit

Permalink
Change DoNotOptimize declaration to not conflict (AcademySoftwareFoun…
Browse files Browse the repository at this point in the history
…dation#3444)

More care with "forceinline" so it doesn't interfere with the
"optnone" on some platforms.
  • Loading branch information
lgritz committed Jun 18, 2022
1 parent 430d7d6 commit cc670d9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/include/OpenImageIO/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
#include <OpenImageIO/timer.h>


#if (((OIIO_GNUC_VERSION && NDEBUG) || OIIO_CLANG_VERSION >= 30500 || OIIO_APPLE_CLANG_VERSION >= 70000 || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)) \
&& (defined(__x86_64__) || defined(__i386__))) \
|| defined(_MSC_VER)
#define OIIO_DONOTOPT_FORECINLINE OIIO_FORCEINLINE
#else
#define OIIO_DONOTOPT_FORECINLINE inline
#endif


OIIO_NAMESPACE_BEGIN

/// DoNotOptimize(val) is a helper function for timing benchmarks that fools
Expand All @@ -23,10 +32,10 @@ OIIO_NAMESPACE_BEGIN
/// May not work on all platforms. References:
/// * Chandler Carruth's CppCon 2015 talk
/// * Folly https://github.com/facebook/folly/blob/master/folly/Benchmark.h
/// * Google Benchmark https://github.com/google/benchmark/blob/master/include/benchmark/benchmark_api.h
/// * Google Benchmark https://github.com/google/benchmark/blob/main/include/benchmark/benchmark.h

template <class T>
OIIO_FORCEINLINE T const& DoNotOptimize (T const &val);
OIIO_DONOTOPT_FORECINLINE T const& DoNotOptimize (T const &val);


/// clobber_all_memory() is a helper function for timing benchmarks that
Expand Down

0 comments on commit cc670d9

Please sign in to comment.