Esempio n. 1
0
int		parse_parameters(int parameters_nb, char **parameters,
				 t_game	*game_properties, t_server_info *server_info)
{
  t_parse_arg	tmp;
  char		p;

  bzero(&tmp, sizeof(t_parse_arg));
  if (parameters_nb < 12)
    return (error_print_usage());
  while (*parameters)
    {
      if ((p = what_parameter(*parameters)) == 0 || !(*++parameters))
	return (error_print_usage());
      if (p == 'n')
	{
	  while (*parameters && !what_parameter(*parameters))
	    {
	      create_team(game_properties, *parameters);
	      ++parameters;
	    }
	}
      else
	{
	  fill_parse_struct(p, &tmp, parameters);
	  ++parameters;
	}
    }
  return (argument_checker(&tmp, game_properties, server_info));
}
Esempio n. 2
0
/*
	指导语句:	#pragma omp for
	结构功能:	for预初始化函数(有parallel时)
	函数功能:	预初始化一个任务共享结构
*/
void GOMP_parallel_loop_guided_start(void *p1, void *p2, unsigned p3, long p4, long p5, long p6, long p7)
{
	TaskInfo old_task;
	Record_Event Event = Event_init ();
	Event.event_name = "GOMP_parallel_loop_guided_start";
	Event.eid = 212;
	Event.type = NONE;
	Event.omp_rank = get_thread_num ();
	Event.omp_level = get_level ();
	Event.p_rank = omp_get_ancestor_thread_num (get_level () - 1);
	
	old_task = current_task;

	//If current task is not exist, create a new task
	if (current_task.flag == 0)
	{
		current_task = create_itask ();
		Event.task_state_start = TASK_CREATE;
	}
	else
		Event.task_state_start = TASK_SUSPEND;

	create_team (current_task);
	
	Event.p_task_id_start = current_task.task_parent_id;
	Event.task_id_start = current_task.task_id;

	GOMP_parallel_loop_guided_start_real=(void(*)(void*,void*,unsigned, long, long, long, long)) dlsym (RTLD_NEXT, "GOMP_parallel_loop_guided_start");
	if (GOMP_parallel_loop_guided_start_real != NULL)
	{
		pardo_uf = (void(*)(void*))p1;
		pardo_uf_id++;

		/*if (PAPI == PAPI_ON)
			retVal = PAPI_thread_init(get_thread_num());
		if (retVal != PAPI_OK)
			ERROR_RETURN(retVal);*/
		
		Event.starttime=gettime();
		GOMP_parallel_loop_guided_start_real (callme_pardo, p2, p3, p4, p5, p6, p7);
		Event.endtime=gettime();
	}
	else
	{
		printf_d("GOMP_parallel_loop_guided_start is not hooked! exiting!!\n");
	}

	Event.p_task_id_end = current_task.task_parent_id;
	Event.task_id_end = current_task.task_id;
	
	if (old_task.flag == 0)
		Event.task_state_end = TASK_START;
	else
		Event.task_state_end = TASK_RESUME;

	Record(&Event, OMPI_TRACE);
}
Esempio n. 3
0
/*
	指导语句:	#pragma omp parallel
	结构功能:	parallel开始函数
	函数功能:	初始化一个parallel并行结构
*/
void GOMP_parallel_start (void *p1, void *p2, unsigned p3)
{
	TaskInfo old_task;

	Record_Event Event = Event_init ();										//初始化
	Event.event_name = "GOMP_parallel_start";								//获取函数名
	Event.eid = 200;
	Event.type = NONE;
	Event.omp_rank = get_thread_num ();										//获取线程编号
	Event.omp_level = get_level ();
	Event.p_rank = omp_get_ancestor_thread_num (get_level () - 1);

	old_task = current_task;

	//If current task is not exist, create a new task
	if (current_task.flag == 0)
	{
		current_task = create_itask ();
		Event.task_state_start = TASK_CREATE;
	}
	else
		Event.task_state_start = TASK_SUSPEND;

	create_team (current_task);
	
	Event.p_task_id_start = current_task.task_parent_id;
	Event.task_id_start = current_task.task_id;

	/*dlsym函数返回 GOMP_parallel_start 在动态链接库中的下一个地址,供调用使用*/
	GOMP_parallel_start_real = (void(*)(void*,void*,unsigned))dlsym (RTLD_NEXT, "GOMP_parallel_start");
	if (GOMP_parallel_start_real != NULL)
	{	
		par_uf = (void(*)(void*))p1;										//调用子函数的包装函数
		par_uf_id++;
		
		Event.starttime = gettime();										//获取开始时间
		GOMP_parallel_start_real (callme_par, p2, p3);						//调用OpenMP库中的GOMP_parallel_start()实现功能
		Event.endtime = gettime ();											//获取结束时间
	}
	else
	{
		printf_d ("GOMP_parallel_start is not hooked! exiting!!\n");
	}

	Event.p_task_id_end = current_task.task_parent_id;
	Event.task_id_end = current_task.task_id;
	
	if (old_task.flag == 0)
		Event.task_state_end = TASK_START;
	else
		Event.task_state_end = TASK_RESUME;
	Record (&Event, OMPI_TRACE);
}
Esempio n. 4
0
TeamRelations::TeamRelations() {
	player_team = create_team();
	enemy_team = create_team();
}
Esempio n. 5
0
/*
 * create_match_state
 *
 * TODO: Fill this function block in once we tie down what this actually does.
 *
 * Returns: A pointer to the new object or NULL on failure.
 */
MATCH_STATE *create_match_state(unsigned int hard_cap,
                                unsigned int game_length_s,
                                char *disc_graphic_filename,
                                char *grass_tile_filename,
                                char *offensive_xml_file,
                                char *defensive_xml_file,
                                int (*state_callback)(AUTOMATON_STATE ***, int),
                                int (*event_callback)(AUTOMATON_EVENT ***))
{
  MATCH_STATE *state;

  /*
   * Allocate the memory for the new object.
   */
  state = (MATCH_STATE *) DT_MALLOC(sizeof(MATCH_STATE));

  /*
   * Set the throw to null to start, this will be created when the user starts
   * a throw.
   */
  state->match_throw = create_throw();

  /*
   * Create a disc object for this game.
   */
  state->disc = create_disc(disc_graphic_filename);

  /*
   * The disc path starts as null so that we know when the first one has
   * been created.
   */
  state->disc_path = NULL;

  /*
   * Initialise the pitch objects associated with the match.
   */
  state->pitch = create_pitch(grass_tile_filename);

  /*
   * Initialise the camera handler associated with the match.
   */
  state->camera_handler = create_camera_handler();

  /*
   * Initialise the input handlers for the mouse and the keyboard.
   */
  state->key_input_state = create_key_input_state();
  state->mouse_input_state = create_mouse_input_state();

  /*
   * Initialise the animation handler. This does not load any animations as this
   * is done by the load_animation_data function.
   */
  state->animation_handler = create_animation_handler();

  /*
   * Create the timer objects for use in the game.
   */
  state->match_stats = create_match_stats(game_length_s,
                                          hard_cap);

  /*
   * Create the automaton handler, passing in the location of the two xml files
   * means that this whole structure is constructed here. This will tell us
   * what the default states are for the two teams.
   */
  state->automaton_handler = create_automaton_handler(offensive_xml_file,
                                                      defensive_xml_file,
                                                      state_callback,
                                                      event_callback,
                                                      state);
  if (NULL == state->automaton_handler)
  {
    destroy_match_state(state);
    state = NULL;
    goto EXIT_LABEL;
  }

  /*
   * Create the teams.
   */
  state->teams[0] = create_team();
  state->teams[1] = create_team();
  state->players_per_team = PLAYERS_PER_TEAM;
  create_players(state->teams,
                 state->players_per_team,
                 state->automaton_handler);

EXIT_LABEL:

  return(state);
}