void Setup()

in src/benchmarks/doubly_linked_list_benchmark.cc [141:211]


  void Setup(size_t thread_count) {
    stats.Initialize();

    if(FLAGS_sync == "cas") {
      dll = new CASDList;
    } else if(FLAGS_sync == "pcas") {
#ifdef PMEM
      if(FLAGS_clflush) {
        NVRAM::InitializeClflush();
      } else {
        NVRAM::InitializeSpin(FLAGS_write_delay_ns, FLAGS_emulate_write_bw);
      }
      dll = new CASDList();
#else
      LOG(FATAL) << "PMEM undefined";
#endif
    } else if(FLAGS_sync == "mwcas") {
      DescriptorPool* pool = new DescriptorPool(
        FLAGS_mwcas_desc_pool_size, FLAGS_threads);
      dll = new MwCASDList(pool);
    } else if(FLAGS_sync == "pmwcas") {
#ifdef PMEM
      Descriptor* pool_va = nullptr;
      if(FLAGS_clflush) {
        NVRAM::InitializeClflush();
      } else {
        NVRAM::InitializeSpin(FLAGS_write_delay_ns, FLAGS_emulate_write_bw);
      }
      DescriptorPool* pool = new DescriptorPool(
        FLAGS_mwcas_desc_pool_size, FLAGS_threads);
      dll = new MwCASDList(pool);
#else
      LOG(FATAL) << "PMEM undefined";
#endif
    } else {
      LOG(FATAL) << "wrong sync method";
    }

    // Populate the list on behalf of each thread
    uint64_t thread_index = 0;
    uint64_t local_insert = 0;
    if(dll->GetSyncMethod() == IDList::kSyncMwCAS) {
      MwCASMetrics::ThreadInitialize();
    }
    int32_t inserted = 0;
    for(int32_t i = 0; i < FLAGS_initial_size; ++i) {
      if(dll->GetSyncMethod() == IDList::kSyncMwCAS) {
        ((MwCASDList*)dll)->GetEpoch()->Protect();
      }
      uint64_t payload_base = thread_index << 32;
      auto* node = IDList::NewNode(nullptr, nullptr, sizeof(uint64_t));
      uint64_t val = local_insert | payload_base;
      memcpy(node->GetPayload(), (char *)&val, sizeof(uint64_t));
      local_insert += ++thread_index % FLAGS_threads == 0 ? 1 : 0;
      thread_index %= FLAGS_threads;
      auto s = dll->InsertBefore(dll->GetTail(), node, false);
      RAW_CHECK(s.ok(), "loading failed");
      inserted++;
      if(inserted % 10000 == 0) {
        LOG(INFO) << "Inserted " << inserted;
      }
      if(dll->GetSyncMethod() == IDList::kSyncMwCAS) {
        ((MwCASDList*)dll)->GetEpoch()->Unprotect();
      }
    }
    initial_local_insert = local_insert;
    if(dll->GetSyncMethod() == IDList::kSyncMwCAS) {
      MwCASMetrics::Uninitialize();
      MwCASMetrics::Initialize();
    }
  }