Skip to content

Commit a50a729

Browse files
committed
Update rng.hpp
1 parent a12b17a commit a50a729

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
{
1818
cxx: $(brew --prefix llvm@15)/bin/clang++,
1919
pkgs: llvm@15 gcc@11,
20-
extra-flags: "-femulated-tls -stdlib=libstdc++ -stdlib++-isystem $(brew --prefix gcc@11)/include/c++/11 -cxx-isystem $(brew --prefix gcc@11)/include/c++/11/aarch64-apple-darwin23",
20+
extra-flags: "-femulated-tls -stdlib=libstdc++ -stdlib++-isystem $(brew --prefix gcc@11)/include/c++/11 -cxx-isystem $(brew --prefix gcc@11)/include/c++/11/aarch64-apple-darwin23 -fsanitize=address -g -fno-omit-frame-pointer",
2121
linker-flags: "-L$(brew --prefix gcc@11)/lib/gcc/11"
2222
}
2323
]

src/utility/rng.hpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <cstddef>
3030
#include <concepts>
3131

32+
#include <iostream>
33+
3234

3335
#ifndef GAPP_SEED
3436
# define GAPP_SEED 0x3da99432ab975d26LL
@@ -457,6 +459,8 @@ namespace gapp::rng
457459
template<std::integral IntType>
458460
GAPP_NOINLINE small_vector<IntType> sampleUniqueSet(IntType lbound, IntType ubound, size_t count)
459461
{
462+
std::cout << "sampleUniqueSet\n";
463+
460464
std::unordered_set<IntType> selected(count);
461465
small_vector<IntType> numbers(count);
462466

@@ -477,20 +481,29 @@ namespace gapp::rng
477481
{
478482
const size_t range_len = detail::range_length(lbound, ubound);
479483

484+
std::cout << "Sample unique lbound: " << lbound << ", ubound: " << ubound << ", count: " << count << "\n";
485+
480486
GAPP_ASSERT(ubound >= lbound);
481487
GAPP_ASSERT(range_len >= count);
482488

483-
const bool select_many = (count > 0.6 * range_len);
484-
const bool huge_range = (range_len >= 65536);
489+
const bool select_many = std::cmp_greater_equal(count, size_t(0.6 * range_len));
490+
const bool huge_range = std::cmp_greater_equal(range_len, 65536);
485491

486-
if (huge_range) [[unlikely]] return rng::sampleUniqueSet(lbound, ubound, count);
492+
std::cout << "Range len: " << range_len << ", huge_range: " << huge_range << "\n";
493+
std::cout << "select many: " << select_many << "\n";
494+
495+
if (huge_range) return rng::sampleUniqueSet(lbound, ubound, count);
496+
497+
std::cout << "Sample unique small\n";
487498

488499
small_vector<IntType> numbers(count);
489500

490501
thread_local detail::dynamic_bitset is_selected;
491502
is_selected.resize(range_len);
492503
is_selected.fill(select_many);
493504

505+
std::cout << "Allocated\n";
506+
494507
if (!select_many)
495508
{
496509
IntType limit = ubound - detail::promoted_t<IntType>(count);

0 commit comments

Comments
 (0)