forked from OSchip/llvm-project
07e984bc52
In D125283, we ensured that integer distributions would not compile when used with arbitrary unsupported types. This effectively enforced what the Standard mentions here: http://eel.is/c++draft/rand#req.genl-1.5. However, this also had the effect of breaking some users that were using integer distributions with unsupported types like int8_t. Since we already support using __int128_t in those distributions, it is reasonable to also support smaller types like int8_t and its unsigned variant. This commit implements that, adds tests and documents the extension. Note that we voluntarily don't add support for instantiating these distributions with bool and char, since those are not integer types. However, it is trivial to replace uses of these random distributions on char using int8_t. It is also interesting to note that in the process of adding tests for smaller types, I discovered that our distributions sometimes don't provide as faithful a distribution when instantiated with smaller types, so I had to relax a couple of tests. In particular, we do a really bad job at implementing the negative binomial, geometric and poisson distributions for small types. I think this all boils down to the algorithm we use in std::poisson_distribution, however I am running out of time to investigate that and changing the algorithm would be an ABI break (which might be reasonable). As part of this patch, I also added a mitigation for a very likely integer overflow bug we were hitting in our tests in negative_binomial_distribution. I also filed http://llvm.org/PR56656 to track fixing the problematic distributions with int8_t and uint8_t. Supersedes D125283. Differential Revision: https://reviews.llvm.org/D126823 |
||
---|---|---|
.. | ||
bernoulli_distribution.h | ||
binomial_distribution.h | ||
cauchy_distribution.h | ||
chi_squared_distribution.h | ||
clamp_to_integral.h | ||
default_random_engine.h | ||
discard_block_engine.h | ||
discrete_distribution.h | ||
exponential_distribution.h | ||
extreme_value_distribution.h | ||
fisher_f_distribution.h | ||
gamma_distribution.h | ||
generate_canonical.h | ||
geometric_distribution.h | ||
independent_bits_engine.h | ||
is_seed_sequence.h | ||
is_valid.h | ||
knuth_b.h | ||
linear_congruential_engine.h | ||
log2.h | ||
lognormal_distribution.h | ||
mersenne_twister_engine.h | ||
negative_binomial_distribution.h | ||
normal_distribution.h | ||
piecewise_constant_distribution.h | ||
piecewise_linear_distribution.h | ||
poisson_distribution.h | ||
random_device.h | ||
ranlux.h | ||
seed_seq.h | ||
shuffle_order_engine.h | ||
student_t_distribution.h | ||
subtract_with_carry_engine.h | ||
uniform_int_distribution.h | ||
uniform_random_bit_generator.h | ||
uniform_real_distribution.h | ||
weibull_distribution.h |