Download build/_deps/catch2-src/include/internal/benchmark/catch_optimizer.hpp from camenduru/thrust: direct link, hf CLI and curl.
- Browser
- Download file 2.19 kB
-
https://huggingface.co/camenduru/thrust/resolve/main/build/_deps/catch2-src/include/internal/benchmark/catch_optimizer.hpp
- Command line
-
hf download hf://camenduru/thrust/build/_deps/catch2-src/include/internal/benchmark/catch_optimizer.hpp
-
curl -L -o catch_optimizer.hpp https://huggingface.co/camenduru/thrust/resolve/main/build/_deps/catch2-src/include/internal/benchmark/catch_optimizer.hpp
2.19 kB
| /* | |
| * Created by Joachim on 16/04/2019. | |
| * Adapted from donated nonius code. | |
| * | |
| * Distributed under the Boost Software License, Version 1.0. (See accompanying | |
| * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| */ | |
| // Hinting the optimizer | |
| namespace Catch { | |
| namespace Benchmark { | |
| template <typename T> | |
| inline void keep_memory(T* p) { | |
| asm volatile("" : : "g"(p) : "memory"); | |
| } | |
| inline void keep_memory() { | |
| asm volatile("" : : : "memory"); | |
| } | |
| namespace Detail { | |
| inline void optimizer_barrier() { keep_memory(); } | |
| } // namespace Detail | |
| template <typename T> | |
| inline void keep_memory(T* p) { | |
| // thanks @milleniumbug | |
| *reinterpret_cast<char volatile*>(p) = *reinterpret_cast<char const volatile*>(p); | |
| } | |
| // TODO equivalent keep_memory() | |
| namespace Detail { | |
| inline void optimizer_barrier() { | |
| std::atomic_thread_fence(std::memory_order_seq_cst); | |
| } | |
| } // namespace Detail | |
| template <typename T> | |
| inline void deoptimize_value(T&& x) { | |
| keep_memory(&x); | |
| } | |
| template <typename Fn, typename... Args> | |
| inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type { | |
| deoptimize_value(std::forward<Fn>(fn) (std::forward<Args...>(args...))); | |
| } | |
| template <typename Fn, typename... Args> | |
| inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type { | |
| std::forward<Fn>(fn) (std::forward<Args...>(args...)); | |
| } | |
| } // namespace Benchmark | |
| } // namespace Catch | |