Example #1
0
int main(int argc, char** argv) {
  if (argc < 3) {
    std::cerr << "<num threads> <sqrt grid size>\n";
    return 1;
  }
  unsigned int numThreads = atoi(argv[1]);
  int n = atoi(argv[2]);

  numThreads = Galois::setActiveThreads(numThreads);
  std::cout << "Using " << numThreads << " threads and " << n << " x " << n << " torus\n";

  Graph graph;
  constructTorus(graph, n, n);

  Galois::Timer T;
  T.start();
  // Unlike Galois::for_each, Galois::for_each_local initially assigns work
  // based on which thread created each node (Galois::for_each uses a simple
  // blocking of the iterator range to initialize work, but the iterator order
  // of a Graph is implementation-defined). 
  Galois::for_each_local(graph, IncrementNeighbors(graph));
  T.stop();

  std::cout << "Elapsed time: " << T.get() << " milliseconds\n";

  // Verify
  int count = std::count_if(graph.begin(), graph.end(), ValueEqual(graph, 4));
  if (count != n * n) {
    std::cerr << "Expected " << n * n << " nodes with value = 4 but found " << count << " instead.\n";
    return 1;
  } else {
    std::cout << "Correct!\n";
  }

  return 0;
}
Example #2
0
bool pjson::operator!=(const Value& lhs, const Value& rhs)
{
    return !boost::apply_visitor(ValueEqual(), lhs.get(), rhs.get());
}