Skip to content

Commit

Permalink
Use word size rather than 64 for random assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdmalone committed Sep 8, 2023
1 parent 4e193f0 commit 9268beb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/stim/mem/simd_bits.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,21 @@ template <size_t W>
void set_random_words_to_all_set(
simd_bits<W> &bits, size_t num_bits, std::mt19937_64 &rng, std::uniform_real_distribution<double> &dist_real) {
bits.randomize(num_bits, rng);
size_t max_bit = 64;
for (size_t iword = 0; iword < bits.num_u64_padded(); iword++) {
size_t max_bit = W;
for (size_t iword = 0; iword < bits.num_simd_words; iword++) {
double r = dist_real(rng);
if (iword == bits.num_u64_padded() - 1) {
max_bit = num_bits - 64 * iword;
if (iword == bits.num_simd_words - 1) {
max_bit = num_bits - W * iword;
}
if (r < 1.0 / 3.0) {
double rall = dist_real(rng);
if (rall > 0.5) {
for (size_t k = 0; k < max_bit; k++) {
bits[iword * 64 + k] = 1;
bits[iword * W + k] = 1;
}
} else {
for (size_t k = 0; k < max_bit; k++) {
bits[iword * 64 + k] = 0;
bits[iword * W + k] = 0;
}
}
}
Expand Down Expand Up @@ -358,7 +358,7 @@ TEST_EACH_WORD_SIZE_W(simd_bits, fuzz_add_assignment, {
m1.invert_bits();
ASSERT_EQ(m1, ref);
}
// // a + (b + c) == (a + b) + c
// a + (b + c) == (a + b) + c
for (int i = 0; i < 10; i++) {
std::uniform_int_distribution dist_bits(1, 1200);
int num_bits = dist_bits(rng);
Expand Down

0 comments on commit 9268beb

Please sign in to comment.