Example #1
0
int main() {

#if defined(HAVE_AVX512F_INSTRUCTIONS)
    avx512f_gather_init();
#endif

    for(int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for(uint64_t value = 0; value < 256; value += 1) {
            if(!check_constant(w,value)) return -1;
        }
    }
    printf("\n");
    for(int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for(int runstart = 0; runstart < w * (int) sizeof(uint64_t); runstart+= w / 33 + 1) {
            for(int endstart = runstart; endstart < w * (int) sizeof(uint64_t); endstart += w / 11 + 1) {
                if(!check_continuous(w,runstart,endstart)) return -1;
            }
        }
    }
    printf("\n");
    for (int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for (int step = 1; step < w * (int) sizeof(uint64_t);
                step += w / 33 + 1) {
            if (!check_step(w, step))
                return -1;

        }
    }
    printf("\n");
    for (int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for (int start = 0; start < w * (int) sizeof(uint64_t);
                start += w / 11 + 1) {
            if (!check_exponential_step(w, start))
                return -1;

        }
    }
    printf("\n");
    printf("Code looks ok.\n");
    return 0;
}
Example #2
0
int MovementModel::check_path(const UnitStack& stack, const Path& path) const {
    StackMovePoints points(stack);
    unsigned int step_num = 0;
    Point current_position = stack.position;
    while (step_num < path.size()) {
        Point next_position = path[step_num];
        if (distance_between(current_position, next_position) != 1)
            break;
        if (!check_step(stack, &points, path, step_num))
            break;
        current_position = next_position;
        step_num++;
    }
    return step_num;
}
int main()
{
  int i;
  tree_type tree;
  init_tree(tree);
  #pragma omp parallel
  #pragma omp single
  {
    #pragma omp task
      start_background_work();
    for (i = 0; i < max_steps; i++)
    {
        #pragma omp taskgroup
        {
           #pragma omp task
             compute_tree(tree);
        } // wait on tree traversal in this step
        check_step();
    }
  } // only now is background work required to be complete
  print_results();
  return 0;
}
void fixed_degree_task::make_randomization_step()
{
  undirected_graph& graph_ = gr_data_->graph_;
  std::future<edge> e1_future = pool_.enqueue([&]()->edge {return boost::random_edge(graph_, rand_generator_);});
  edge e2 = boost::random_edge(graph_, rand_generator_);
  vertex vs2 = boost::source(e2, graph_);
  vertex vt2 = boost::target(e2, graph_);
  edge e1 = e1_future.get();
  vertex vs1 = boost::source(e1, graph_);
  vertex vt1 = boost::target(e1, graph_);
  while(e1 == e2 || vs1 == vs2 || vt1 == vt2 || vs1 == vt2 || vt1 == vs2 ||
    boost::edge(vs1, vs2, graph_).second ||
    boost::edge(vt1, vt2, graph_).second)
  {
    //std::future<edge> e1_future = pool_.enqueue([&]()->edge {return boost::random_edge(graph_, rand_generator_);});
    e2 = boost::random_edge(graph_, rand_generator_);
    vs2 = boost::source(e2, graph_);
    vt2 = boost::target(e2, graph_);

    //e1 = e1_future.get();
    //vs1 = boost::source(e1, graph_);
    //vt1 = boost::target(e1, graph_);
  }
  assert(e1 != e2 && vs1 != vs2 && vt1 != vt2 &&
    !boost::edge(vs1, vs2, graph_).second &&
    !boost::edge(vt1, vt2, graph_).second);

  // removing edges
  boost::remove_edge(e1, graph_);
  boost::remove_edge(e2, graph_);
  assert(!boost::edge(vs1, vt1, graph_).second &&
    !boost::edge(vs2, vt2, graph_).second);
  
  int removed = 0;
  int added = 0;

  int removed1 = 0;
  int added1 = 0;

  std::future<void> result1 = pool_.enqueue([&]()
  {
    adjacency_iterator v, v_end;
    for(boost::tie(v, v_end) = boost::adjacent_vertices(vs1, graph_); v != v_end; ++v)
    {
      if(*v != vt1 && boost::edge(*v, vt1, graph_).second)
      {
        ++removed1;
      }
    }
  });

  std::future<void> result2 = pool_.enqueue([&]()
  {
    adjacency_iterator v, v_end;
    for(boost::tie(v, v_end) = boost::adjacent_vertices(vs1, graph_); v != v_end; ++v)
    {
      if(*v != vs2 && boost::edge(*v, vs2, graph_).second)
      {
        ++added1;
      }
    }
  });

  std::future<void> result3 = pool_.enqueue([&]()
  {
    adjacency_iterator v, v_end;
    for(boost::tie(v, v_end) = boost::adjacent_vertices(vt2, graph_); v != v_end; ++v)
    {
      if(*v != vs2 && boost::edge(*v, vs2, graph_).second)
      {
        ++removed;
      }
    }
  });

  adjacency_iterator v, v_end;
  for(boost::tie(v, v_end) = boost::adjacent_vertices(vt2, graph_); v != v_end; ++v)
  {
    if(*v != vt1 && boost::edge(*v, vt1, graph_).second)
    {
      ++added;
    }
  }

  result1.get();
  result2.get();
  result3.get();

  added += added1;
  removed += removed1;
  boost::add_edge(vs1, vs2, graph_);
  boost::add_edge(vt1, vt2, graph_);
  int delta = added - removed;

  if(check_step(delta))
  {
    num_triangles_ += delta;
  }
  else
  {
    // revert made changes
    boost::add_edge(vs1, vt1, graph_);
    boost::add_edge(vs2, vt2, graph_);
    boost::remove_edge(vs1, vs2, graph_);
    boost::remove_edge(vt1, vt2, graph_);
  }
}
void random_switch_task::make_randomization_step()
{
  undirected_graph& graph_ = gr_data_->graph_;
  size_t removed = 0;
  size_t added = 0;

  edge edge_to_remove;
  vertex source1, target1;
  std::future<void> result = pool_.enqueue([&]()
  {
    edge_to_remove = boost::random_edge(graph_, rand_generator_);
    source1 = boost::source(edge_to_remove, graph_);
    target1 = boost::target(edge_to_remove, graph_);
    adjacency_iterator v, v_end;
    for(boost::tie(v, v_end) = boost::adjacent_vertices(source1, graph_); v != v_end; ++v)
    {
      if(*v != target1 && boost::edge(*v, target1, graph_).second)
      {
        ++removed;
      }
    }
  });

  boost::graph_traits<undirected_graph>::edges_size_type added_edge_num = 0;
  std::pair<vertex, vertex> edge_to_add;
  assert(non_existing_edges_.size() > 0);
  added_edge_num = (*var_generator_)();
  edge_to_add = non_existing_edges_[added_edge_num];
  assert(!boost::edge(edge_to_add.first, edge_to_add.second, graph_).second);

  adjacency_iterator v, v_end;
  for(boost::tie(v, v_end) = boost::adjacent_vertices(edge_to_add.first, graph_); v != v_end; ++v)
  {
    if(boost::edge(*v, edge_to_add.second, graph_).second)
    {
      ++added;
    }
  }

  result.get();

  if((edge_to_add.first == source1 && boost::edge(edge_to_add.second, target1, graph_).second) ||
     (edge_to_add.first == target1 && boost::edge(edge_to_add.second, source1, graph_).second) ||
     (edge_to_add.second == source1 && boost::edge(edge_to_add.first, target1, graph_).second) ||
     (edge_to_add.second == target1 && boost::edge(edge_to_add.first, source1, graph_).second))
  {
    --added;
  }

  int delta = added - removed;
  if(!check_step(delta))
  {
    return;
  }
  boost::remove_edge(edge_to_remove, graph_);
  //std::pair<vertex, vertex> edge_to_add = non_existing_edges_[added_edge_num];
  boost::add_edge(edge_to_add.first, edge_to_add.second, graph_);
  non_existing_edges_[added_edge_num] = std::make_pair(source1, target1);
  num_triangles_ += delta;
  //non_existing_edges_.erase(non_existing_edges_.begin() + added_edge_num);
  //non_existing_edges_.push_back(std::make_pair(source1, target1));
}