void ZombieObserver::go() {
  if (_rank == 0) {
    Log4CL::instance()->get_logger("root").log(INFO, "TICK BEGINS: " + boost::lexical_cast<string>(RepastProcess::instance()->getScheduleRunner().currentTick()));
  }
  
  synchronize<AgentPackage>(*this, *this, *this, RepastProcess::USE_LAST_OR_USE_CURRENT);
  AgentSet<Zombie> zombies;
  AgentSet<Human> humans; 
  
  if (work_per_rank > OMP_TASK_THRESHOLD) {
  	#pragma omp parallel num_threads(2)
 	{
  		#pragma omp single nowait
		{
  			#pragma omp task
  			{
  				get(zombies);
  			}
  			
  			#pragma omp task
  			{
  				get(humans);
  			}

  			#pragma omp taskwait
			zombies.ask(&Zombie::step);
            AgentId id(0,0,2);
            Zombie* z = who<Zombie>(id);
			humans.ask(&Human::step); 
  		}
  	}
  } else {
  	AgentSet<Zombie> zombies;
	AgentSet<Human> humans;
  	get(zombies);
  	get(humans);
  	zombies.ask(&Zombie::step);
  	AgentId id(0,0,2);
  	Zombie* z = who<Zombie>(id);
  	humans.ask(&Human::step);
 }

  if (_rank == 0) {
    Log4CL::instance()->get_logger("root").log(INFO, "TICK ENDS: " + boost::lexical_cast<string>(RepastProcess::instance()->getScheduleRunner().currentTick()));
  }
}
Esempio n. 2
0
void ZombieObserver::go() {
  if (_rank == 0) {
    Log4CL::instance()->get_logger("root").log(INFO, "TICK BEGINS: " + boost::lexical_cast<string>(RepastProcess::instance()->getScheduleRunner().currentTick()));
  }
  synchronize<AgentPackage>(*this, *this, *this, RepastProcess::USE_LAST_OR_USE_CURRENT);

  AgentSet<Zombie> zombies;
  get(zombies);
  zombies.ask(&Zombie::step);

  AgentId id(0,0,2);
  Zombie* z = who<Zombie>(id);

  AgentSet<Human> humans;
  get(humans);
  humans.ask(&Human::step);

  if (_rank == 0) {
    Log4CL::instance()->get_logger("root").log(INFO, "TICK ENDS: " + boost::lexical_cast<string>(RepastProcess::instance()->getScheduleRunner().currentTick()));
  }
}