[libc-commits] [libc] [libc] DRAFT: Add Generic and NVPTX Sin Benchmark (PR #99795)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Sat Jul 20 20:51:24 PDT 2024
================
@@ -102,6 +105,56 @@ class Benchmark {
return benchmark(options, func);
}
};
+
+// We want our random values to be approximately
+// |real value| <= 2^(max_exponent) * (1 + (random 52 bits) * 2^-52) <
+// 2^(max_exponent + 1)
+// The largest integer that can be stored in a double is 2^53
+static constexpr int MAX_EXPONENT = 52;
+static constexpr int RANDOM_INPUT_SIZE = 1024;
+static cpp::array<double, RANDOM_INPUT_SIZE> random_input;
+
+static double get_rand() {
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<double>;
+ uint64_t bits = LIBC_NAMESPACE::rand();
----------------
jhuber6 wrote:
I also wonder if we should make a reeantrant version of `rand` so we can have a state private to each thread instead of the shared state.
I.e.
`val = rand_r(&state)`
https://github.com/llvm/llvm-project/pull/99795
More information about the libc-commits
mailing list