コード例 #1
0
  void testit( bool rehash_on_fail = true )
  {
    execution_space::fence();

    uint32_t failed_count = 0;
    do {
      failed_count = 0;
      Kokkos::parallel_reduce(inserts, *this, failed_count);

      if (rehash_on_fail && failed_count > 0u) {
        const uint32_t new_capacity = map.capacity() + ((map.capacity()*3ull)/20u) + failed_count/collisions ;
        map.rehash( new_capacity );
      }
    } while (rehash_on_fail && failed_count > 0u);

    execution_space::fence();
  }
コード例 #2
0
  UnorderedMapTest( uint32_t arg_capacity, uint32_t arg_inserts, uint32_t arg_collisions)
    : capacity(arg_capacity)
    , inserts(arg_inserts)
    , collisions(arg_collisions)
    , seconds(0)
    , map(capacity)
    , histogram(map.get_histogram())
  {
    Kokkos::Timer wall_clock ;
    wall_clock.reset();

    value_type v = {};
    int loop_count = 0;
    do {
      ++loop_count;

      v = value_type();
      Kokkos::parallel_reduce(inserts, *this, v);

      if (v.failed_count > 0u) {
        const uint32_t new_capacity = map.capacity() + ((map.capacity()*3ull)/20u) + v.failed_count/collisions ;
        map.rehash( new_capacity );
      }
    } while (v.failed_count > 0u);

    seconds = wall_clock.seconds();

    switch (loop_count)
    {
    case 1u: std::cout << " \033[0;32m" << loop_count << "\033[0m "; break;
    case 2u: std::cout << " \033[1;31m" << loop_count << "\033[0m "; break;
    default: std::cout << " \033[0;31m" << loop_count << "\033[0m "; break;
    }
    std::cout << std::setprecision(2) << std::fixed << std::setw(5) << (1e9*(seconds/(inserts))) << "; " << std::flush;

    histogram.calculate();
    Device::fence();
  }